Skip to content

Commit

Permalink
Fix existing issue with react-dom-webpack-server bundle treeshaking
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson committed Mar 20, 2023
1 parent a0712ac commit f29548e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions scripts/rollup/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const sizes = require('./plugins/sizes-plugin');
const useForks = require('./plugins/use-forks-plugin');
const stripUnusedImports = require('./plugins/strip-unused-imports');
const dynamicImports = require('./plugins/dynamic-imports');
const disableDomPropertyTreeshake = require('./plugins/disable-domproperty-treeshake');
const Packaging = require('./packaging');
const {asyncRimRaf} = require('./utils');
const codeFrame = require('@babel/code-frame');
Expand Down Expand Up @@ -333,6 +334,7 @@ function getPlugins(
bundleType === RN_FB_PROFILING;
const shouldStayReadable = isFBWWWBundle || isRNBundle || forcePrettyOutput;
return [
disableDomPropertyTreeshake(),
// Keep dynamic imports as externals
dynamicImports(),
{
Expand Down
25 changes: 25 additions & 0 deletions scripts/rollup/plugins/disable-domproperty-treeshake.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';

module.exports = function disableTreeshake() {
return {
name: 'scripts/rollup/plugins/disable-treeshake',
transform(code, id) {
// Fix issue with `react-dom-webpack-server` bundles accidentally
// stripping out the `properties` object and not filling it out
if (id.endsWith('DOMProperty.js')) {
return {
code,
map: null,
moduleSideEffects: 'no-treeshake',
};
}
return null;
},
};
};

0 comments on commit f29548e

Please sign in to comment.