Skip to content

Commit 0120bb1

Browse files
committed
Fix existing issue with react-dom-webpack-server bundle treeshaking
1 parent dcb4b49 commit 0120bb1

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

scripts/rollup/build.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const sizes = require('./plugins/sizes-plugin');
2020
const useForks = require('./plugins/use-forks-plugin');
2121
const stripUnusedImports = require('./plugins/strip-unused-imports');
2222
const dynamicImports = require('./plugins/dynamic-imports');
23+
const disableDomPropertyTreeshake = require('./plugins/disable-domproperty-treeshake');
2324
const Packaging = require('./packaging');
2425
const {asyncRimRaf} = require('./utils');
2526
const codeFrame = require('@babel/code-frame');
@@ -333,6 +334,7 @@ function getPlugins(
333334
bundleType === RN_FB_PROFILING;
334335
const shouldStayReadable = isFBWWWBundle || isRNBundle || forcePrettyOutput;
335336
return [
337+
disableDomPropertyTreeshake(),
336338
// Keep dynamic imports as externals
337339
dynamicImports(),
338340
{
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
'use strict';
8+
9+
module.exports = function disableTreeshake() {
10+
return {
11+
name: 'scripts/rollup/plugins/disable-treeshake',
12+
transform(code, id) {
13+
// Fix issue with `react-dom-webpack-server` bundles accidentally
14+
// stripping out the `properties` object and not filling it out
15+
if (id.endsWith('DOMProperty.js')) {
16+
return {
17+
code,
18+
map: null,
19+
moduleSideEffects: 'no-treeshake',
20+
};
21+
}
22+
return null;
23+
},
24+
};
25+
};

0 commit comments

Comments
 (0)