diff --git a/scripts/rollup/build.js b/scripts/rollup/build.js index 130749b574b2f..ea93de1a61afe 100644 --- a/scripts/rollup/build.js +++ b/scripts/rollup/build.js @@ -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'); @@ -333,6 +334,7 @@ function getPlugins( bundleType === RN_FB_PROFILING; const shouldStayReadable = isFBWWWBundle || isRNBundle || forcePrettyOutput; return [ + disableDomPropertyTreeshake(), // Keep dynamic imports as externals dynamicImports(), { diff --git a/scripts/rollup/plugins/disable-domproperty-treeshake.js b/scripts/rollup/plugins/disable-domproperty-treeshake.js new file mode 100644 index 0000000000000..e5a7e1fcdb6f7 --- /dev/null +++ b/scripts/rollup/plugins/disable-domproperty-treeshake.js @@ -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; + }, + }; +};