From 25e6d44453d97d6ed6355ee77b087c93c03e46dc Mon Sep 17 00:00:00 2001 From: Jan Kassens Date: Fri, 3 May 2024 14:08:45 -0400 Subject: [PATCH] Bundle config: Rename `global` to `hasteFileName` in bundle config The whole bundle config is pretty confusing to me, I took a look and here's a few things that could be simplified. This config is now only used for determining the file name for "haste" style bundles for FB and RN builds. In the past it was also used for UMD builds that we no longer build. Also removes a bunch of parameters to wrappers that were completely unused. --- scripts/rollup/build.js | 14 +---- scripts/rollup/bundles.js | 109 ++++++++----------------------------- scripts/rollup/wrappers.js | 101 ++++++++++++++++------------------ 3 files changed, 72 insertions(+), 152 deletions(-) diff --git a/scripts/rollup/build.js b/scripts/rollup/build.js index 2ade58493a5f..5903d1b00d04 100644 --- a/scripts/rollup/build.js +++ b/scripts/rollup/build.js @@ -199,13 +199,7 @@ let getRollupInteropValue = id => { return 'esModule'; }; -function getRollupOutputOptions( - outputPath, - format, - globals, - globalName, - bundleType -) { +function getRollupOutputOptions(outputPath, format, globals, bundleType) { const isProduction = isProductionBundleType(bundleType); return { @@ -214,7 +208,6 @@ function getRollupOutputOptions( globals, freeze: !isProduction, interop: getRollupInteropValue, - name: globalName, sourcemap: false, esModule: false, exports: 'auto', @@ -351,7 +344,6 @@ function getPlugins( filename, packageName, bundleType, - globalName, moduleType, pureExternalModules, bundle @@ -424,7 +416,6 @@ function getPlugins( return Wrappers.wrapWithTopLevelDefinitions( source, bundleType, - globalName, filename, moduleType, bundle.wrapWithModuleBoundaries @@ -488,7 +479,6 @@ function getPlugins( return Wrappers.wrapWithLicenseHeader( source, bundleType, - globalName, filename, moduleType ); @@ -651,7 +641,6 @@ async function createBundle(bundle, bundleType) { filename, packageName, bundleType, - bundle.global, bundle.moduleType, pureExternalModules, bundle @@ -674,7 +663,6 @@ async function createBundle(bundle, bundleType) { mainOutputPath, format, peerGlobals, - bundle.global, bundleType ); diff --git a/scripts/rollup/bundles.js b/scripts/rollup/bundles.js index f6dc4438fabe..2d9955d5e372 100644 --- a/scripts/rollup/bundles.js +++ b/scripts/rollup/bundles.js @@ -77,7 +77,7 @@ const bundles = [ ], moduleType: ISOMORPHIC, entry: 'react', - global: 'React', + hasteFileName: 'React', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: true, externals: ['ReactNativeInternalFeatureFlags'], @@ -90,7 +90,6 @@ const bundles = [ entry: 'react/src/ReactServer.js', name: 'react.react-server', condition: 'react-server', - global: 'React', minifyWithProdErrorCodes: true, wrapWithModuleBoundaries: false, externals: [], @@ -109,7 +108,7 @@ const bundles = [ ], moduleType: ISOMORPHIC, entry: 'react/jsx-runtime', - global: 'JSXRuntime', + hasteFileName: 'JSXRuntime', minifyWithProdErrorCodes: true, wrapWithModuleBoundaries: false, externals: ['react', 'ReactNativeInternalFeatureFlags'], @@ -120,7 +119,6 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROD, NODE_PROFILING], moduleType: ISOMORPHIC, entry: 'react/compiler-runtime', - global: 'CompilerRuntime', minifyWithProdErrorCodes: true, wrapWithModuleBoundaries: false, externals: ['react'], @@ -133,7 +131,6 @@ const bundles = [ entry: 'react/src/jsx/ReactJSXServer.js', name: 'react-jsx-runtime.react-server', condition: 'react-server', - global: 'JSXRuntime', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react', 'ReactNativeInternalFeatureFlags'], @@ -154,7 +151,7 @@ const bundles = [ ], moduleType: ISOMORPHIC, entry: 'react/jsx-dev-runtime', - global: 'JSXDEVRuntime', + hasteFileName: 'JSXDEVRuntime', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react', 'ReactNativeInternalFeatureFlags'], @@ -167,7 +164,6 @@ const bundles = [ entry: 'react/src/jsx/ReactJSXServer.js', name: 'react-jsx-dev-runtime.react-server', condition: 'react-server', - global: 'JSXDEVRuntime', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react', 'ReactNativeInternalFeatureFlags'], @@ -178,7 +174,6 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROD], moduleType: RENDERER, entry: 'react-dom', - global: 'ReactDOM', minifyWithProdErrorCodes: true, wrapWithModuleBoundaries: true, externals: ['react'], @@ -188,7 +183,6 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROD], moduleType: RENDERER, entry: 'react-dom/client', - global: 'ReactDOM', minifyWithProdErrorCodes: true, wrapWithModuleBoundaries: true, externals: ['react', 'react-dom'], @@ -199,7 +193,6 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROFILING], moduleType: RENDERER, entry: 'react-dom/profiling', - global: 'ReactDOM', minifyWithProdErrorCodes: true, wrapWithModuleBoundaries: true, externals: ['react', 'react-dom'], @@ -209,7 +202,7 @@ const bundles = [ bundleTypes: [FB_WWW_DEV, FB_WWW_PROD, FB_WWW_PROFILING], moduleType: RENDERER, entry: 'react-dom/src/ReactDOMFB.js', - global: 'ReactDOM', + hasteFileName: 'ReactDOM', minifyWithProdErrorCodes: true, wrapWithModuleBoundaries: true, externals: ['react'], @@ -222,7 +215,6 @@ const bundles = [ entry: 'react-dom/src/ReactDOMReactServer.js', name: 'react-dom.react-server', condition: 'react-server', - global: 'ReactDOM', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react'], @@ -233,7 +225,7 @@ const bundles = [ moduleType: RENDERER_UTILS, bundleTypes: [FB_WWW_DEV, NODE_DEV, NODE_PROD], entry: 'react-dom/test-utils', - global: 'ReactTestUtils', + hasteFileName: 'ReactTestUtils', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react', 'react-dom'], @@ -244,7 +236,6 @@ const bundles = [ moduleType: RENDERER, bundleTypes: __EXPERIMENTAL__ ? [NODE_DEV, NODE_PROD] : [], entry: 'react-dom/unstable_testing', - global: 'ReactDOMTesting', minifyWithProdErrorCodes: true, wrapWithModuleBoundaries: false, externals: ['react', 'react-dom'], @@ -255,7 +246,7 @@ const bundles = [ moduleType: RENDERER, bundleTypes: [FB_WWW_DEV, FB_WWW_PROD], entry: 'react-dom/src/ReactDOMTestingFB.js', - global: 'ReactDOMTesting', + hasteFileName: 'ReactDOMTesting', minifyWithProdErrorCodes: true, wrapWithModuleBoundaries: false, externals: ['react'], @@ -267,7 +258,7 @@ const bundles = [ moduleType: RENDERER, entry: 'react-dom/src/server/ReactDOMLegacyServerBrowser.js', name: 'react-dom-server-legacy.browser', - global: 'ReactDOMServer', + hasteFileName: 'ReactDOMServer', minifyWithProdErrorCodes: true, wrapWithModuleBoundaries: false, externals: ['react', 'react-dom'], @@ -300,7 +291,6 @@ const bundles = [ moduleType: RENDERER, entry: 'react-dom/src/server/react-dom-server.browser.js', name: 'react-dom-server.browser', - global: 'ReactDOMServer', minifyWithProdErrorCodes: true, wrapWithModuleBoundaries: false, externals: ['react', 'react-dom'], @@ -310,7 +300,6 @@ const bundles = [ moduleType: RENDERER, entry: 'react-dom/src/server/react-dom-server.node.js', name: 'react-dom-server.node', - global: 'ReactDOMServer', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react', 'util', 'crypto', 'async_hooks', 'react-dom'], @@ -319,7 +308,7 @@ const bundles = [ bundleTypes: __EXPERIMENTAL__ ? [FB_WWW_DEV, FB_WWW_PROD] : [], moduleType: RENDERER, entry: 'react-server-dom-fb/src/ReactDOMServerFB.js', - global: 'ReactDOMServerStreaming', + hasteFileName: 'ReactDOMServerStreaming', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react', 'react-dom'], @@ -331,8 +320,6 @@ const bundles = [ moduleType: RENDERER, entry: 'react-dom/src/server/react-dom-server.edge.js', name: 'react-dom-server.edge', // 'node_modules/react/*.js', - - global: 'ReactDOMServer', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react', 'react-dom'], @@ -344,8 +331,6 @@ const bundles = [ moduleType: RENDERER, entry: 'react-dom/src/server/react-dom-server.bun.js', name: 'react-dom-server.bun', // 'node_modules/react/*.js', - - global: 'ReactDOMServer', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react', 'react-dom'], @@ -357,7 +342,6 @@ const bundles = [ moduleType: RENDERER, entry: 'react-dom/unstable_server-external-runtime', outputPath: 'unstable_server-external-runtime.js', - global: 'ReactDOMServerExternalRuntime', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: [], @@ -369,7 +353,6 @@ const bundles = [ moduleType: RENDERER, entry: 'react-server-dom-webpack/server.browser', condition: 'react-server', - global: 'ReactServerDOMServer', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react', 'react-dom'], @@ -379,7 +362,6 @@ const bundles = [ moduleType: RENDERER, entry: 'react-server-dom-webpack/server.node', condition: 'react-server', - global: 'ReactServerDOMServer', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react', 'util', 'crypto', 'async_hooks', 'react-dom'], @@ -389,7 +371,6 @@ const bundles = [ moduleType: RENDERER, entry: 'react-server-dom-webpack/server.node.unbundled', condition: 'react-server', - global: 'ReactServerDOMServer', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react', 'util', 'crypto', 'async_hooks', 'react-dom'], @@ -399,7 +380,6 @@ const bundles = [ moduleType: RENDERER, entry: 'react-server-dom-webpack/server.edge', condition: 'react-server', - global: 'ReactServerDOMServer', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react', 'util', 'crypto', 'async_hooks', 'react-dom'], @@ -410,7 +390,6 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROD], moduleType: RENDERER, entry: 'react-server-dom-webpack/client.browser', - global: 'ReactServerDOMClient', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react', 'react-dom'], @@ -419,7 +398,6 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROD], moduleType: RENDERER, entry: 'react-server-dom-webpack/client.node', - global: 'ReactServerDOMClient', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react', 'react-dom', 'util', 'crypto'], @@ -428,7 +406,6 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROD], moduleType: RENDERER, entry: 'react-server-dom-webpack/client.node.unbundled', - global: 'ReactServerDOMClient', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react', 'react-dom', 'util', 'crypto'], @@ -437,7 +414,6 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROD], moduleType: RENDERER, entry: 'react-server-dom-webpack/client.edge', - global: 'ReactServerDOMClient', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react', 'react-dom'], @@ -448,7 +424,6 @@ const bundles = [ bundleTypes: [NODE_ES2015], moduleType: RENDERER_UTILS, entry: 'react-server-dom-webpack/plugin', - global: 'ReactServerWebpackPlugin', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['fs', 'path', 'url', 'neo-async'], @@ -460,7 +435,6 @@ const bundles = [ moduleType: RENDERER_UTILS, entry: 'react-server-dom-webpack/node-loader', condition: 'react-server', - global: 'ReactServerWebpackNodeLoader', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['acorn'], @@ -473,7 +447,6 @@ const bundles = [ entry: 'react-server-dom-webpack/src/ReactFlightWebpackNodeRegister', name: 'react-server-dom-webpack-node-register', condition: 'react-server', - global: 'ReactFlightWebpackNodeRegister', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['url', 'module', 'react-server-dom-webpack/server'], @@ -485,7 +458,6 @@ const bundles = [ moduleType: RENDERER, entry: 'react-server-dom-turbopack/server.browser', condition: 'react-server', - global: 'ReactServerDOMServer', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react', 'react-dom'], @@ -495,7 +467,6 @@ const bundles = [ moduleType: RENDERER, entry: 'react-server-dom-turbopack/server.node', condition: 'react-server', - global: 'ReactServerDOMServer', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react', 'util', 'async_hooks', 'react-dom'], @@ -505,7 +476,6 @@ const bundles = [ moduleType: RENDERER, entry: 'react-server-dom-turbopack/server.node.unbundled', condition: 'react-server', - global: 'ReactServerDOMServer', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react', 'util', 'async_hooks', 'react-dom'], @@ -515,7 +485,6 @@ const bundles = [ moduleType: RENDERER, entry: 'react-server-dom-turbopack/server.edge', condition: 'react-server', - global: 'ReactServerDOMServer', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react', 'util', 'async_hooks', 'react-dom'], @@ -526,7 +495,6 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROD], moduleType: RENDERER, entry: 'react-server-dom-turbopack/client.browser', - global: 'ReactServerDOMClient', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react', 'react-dom'], @@ -535,7 +503,6 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROD], moduleType: RENDERER, entry: 'react-server-dom-turbopack/client.node', - global: 'ReactServerDOMClient', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react', 'react-dom', 'util'], @@ -544,7 +511,6 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROD], moduleType: RENDERER, entry: 'react-server-dom-turbopack/client.node.unbundled', - global: 'ReactServerDOMClient', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react', 'react-dom', 'util'], @@ -553,7 +519,6 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROD], moduleType: RENDERER, entry: 'react-server-dom-turbopack/client.edge', - global: 'ReactServerDOMClient', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react', 'react-dom'], @@ -569,7 +534,6 @@ const bundles = [ moduleType: RENDERER_UTILS, entry: 'react-server-dom-turbopack/node-loader', condition: 'react-server', - global: 'ReactServerTurbopackNodeLoader', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['acorn'], @@ -582,7 +546,6 @@ const bundles = [ entry: 'react-server-dom-turbopack/src/ReactFlightTurbopackNodeRegister', name: 'react-server-dom-turbopack-node-register', condition: 'react-server', - global: 'ReactFlightWebpackNodeRegister', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['url', 'module', 'react-server-dom-turbopack/server'], @@ -623,7 +586,6 @@ const bundles = [ moduleType: RENDERER_UTILS, entry: 'react-server-dom-esm/node-loader', condition: 'react-server', - global: 'ReactServerESMNodeLoader', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['acorn'], @@ -634,7 +596,6 @@ const bundles = [ bundleTypes: [NODE_ES2015], moduleType: RENDERER_UTILS, entry: 'react-suspense-test-utils', - global: 'ReactSuspenseTestUtils', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react'], @@ -645,7 +606,7 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROD, FB_WWW_DEV, FB_WWW_PROD], moduleType: RENDERER, entry: 'react-art', - global: 'ReactART', + hasteFileName: 'ReactART', externals: ['react'], minifyWithProdErrorCodes: true, wrapWithModuleBoundaries: true, @@ -669,7 +630,7 @@ const bundles = [ : [RN_FB_DEV, RN_FB_PROD, RN_FB_PROFILING], moduleType: RENDERER, entry: 'react-native-renderer', - global: 'ReactNativeRenderer', + hasteFileName: 'ReactNativeRenderer', externals: ['react-native', 'ReactNativeInternalFeatureFlags'], minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: true, @@ -684,7 +645,7 @@ const bundles = [ bundleTypes: [RN_OSS_DEV, RN_OSS_PROD, RN_OSS_PROFILING], moduleType: RENDERER, entry: 'react-native-renderer', - global: 'ReactNativeRenderer', + hasteFileName: 'ReactNativeRenderer', externals: ['react-native'], minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: true, @@ -703,7 +664,7 @@ const bundles = [ : [RN_FB_DEV, RN_FB_PROD, RN_FB_PROFILING], moduleType: RENDERER, entry: 'react-native-renderer/fabric', - global: 'ReactFabric', + hasteFileName: 'ReactFabric', externals: ['react-native', 'ReactNativeInternalFeatureFlags'], minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: true, @@ -717,8 +678,8 @@ const bundles = [ { bundleTypes: [RN_OSS_DEV, RN_OSS_PROD, RN_OSS_PROFILING], moduleType: RENDERER, + hasteFileName: 'ReactFabric', entry: 'react-native-renderer/fabric', - global: 'ReactFabric', externals: ['react-native'], minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: true, @@ -742,7 +703,7 @@ const bundles = [ ], moduleType: RENDERER, entry: 'react-test-renderer', - global: 'ReactTestRenderer', + hasteFileName: 'ReactTestRenderer', externals: [ 'react', 'scheduler', @@ -764,7 +725,6 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROD], moduleType: RENDERER, entry: 'react-noop-renderer', - global: 'ReactNoopRenderer', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react', 'scheduler', 'scheduler/unstable_mock', 'expect'], @@ -775,7 +735,6 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROD], moduleType: RENDERER, entry: 'react-noop-renderer/persistent', - global: 'ReactNoopRendererPersistent', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react', 'scheduler', 'expect'], @@ -786,7 +745,6 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROD], moduleType: RENDERER, entry: 'react-noop-renderer/server', - global: 'ReactNoopRendererServer', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react', 'scheduler', 'expect'], @@ -798,7 +756,6 @@ const bundles = [ moduleType: RENDERER, entry: 'react-noop-renderer/flight-server', condition: 'react-server', - global: 'ReactNoopFlightServer', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: [ @@ -814,7 +771,6 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROD], moduleType: RENDERER, entry: 'react-noop-renderer/flight-client', - global: 'ReactNoopFlightClient', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: [ @@ -830,7 +786,7 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROD, NODE_PROFILING, FB_WWW_DEV, FB_WWW_PROD], moduleType: RECONCILER, entry: 'react-reconciler', - global: 'ReactReconciler', + hasteFileName: 'ReactReconciler', minifyWithProdErrorCodes: true, wrapWithModuleBoundaries: false, externals: ['react'], @@ -841,7 +797,6 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROD], moduleType: RECONCILER, entry: 'react-server', - global: 'ReactServer', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react'], @@ -853,7 +808,6 @@ const bundles = [ moduleType: RECONCILER, entry: 'react-server/flight', condition: 'react-server', - global: 'ReactFlightServer', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react'], @@ -864,7 +818,6 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROD], moduleType: RECONCILER, entry: 'react-client/flight', - global: 'ReactFlightClient', minifyWithProdErrorCodes: true, wrapWithModuleBoundaries: false, externals: ['react'], @@ -875,7 +828,6 @@ const bundles = [ moduleType: RENDERER_UTILS, bundleTypes: [NODE_DEV, NODE_PROD], entry: 'react-reconciler/reflection', - global: 'ReactFiberTreeReflection', minifyWithProdErrorCodes: true, wrapWithModuleBoundaries: false, externals: [], @@ -886,7 +838,6 @@ const bundles = [ moduleType: RENDERER_UTILS, bundleTypes: [NODE_DEV, NODE_PROD], entry: 'react-reconciler/constants', - global: 'ReactReconcilerConstants', minifyWithProdErrorCodes: true, wrapWithModuleBoundaries: false, externals: [], @@ -905,7 +856,7 @@ const bundles = [ ], moduleType: ISOMORPHIC, entry: 'react-is', - global: 'ReactIs', + hasteFileName: 'ReactIs', minifyWithProdErrorCodes: true, wrapWithModuleBoundaries: false, externals: ['ReactNativeInternalFeatureFlags'], @@ -916,7 +867,6 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROD], moduleType: ISOMORPHIC, entry: 'react-debug-tools', - global: 'ReactDebugTools', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: [], @@ -927,7 +877,7 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROD, FB_WWW_DEV, FB_WWW_PROD], moduleType: ISOMORPHIC, entry: 'react-cache', - global: 'ReactCacheOld', + hasteFileName: 'ReactCacheOld', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react', 'scheduler'], @@ -938,7 +888,6 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROD], moduleType: ISOMORPHIC, entry: 'use-subscription', - global: 'useSubscription', minifyWithProdErrorCodes: true, wrapWithModuleBoundaries: true, externals: ['react'], @@ -949,7 +898,6 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROD], moduleType: ISOMORPHIC, entry: 'use-sync-external-store', - global: 'useSyncExternalStore', minifyWithProdErrorCodes: true, wrapWithModuleBoundaries: true, externals: ['react'], @@ -960,7 +908,6 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROD], moduleType: ISOMORPHIC, entry: 'use-sync-external-store/shim', - global: 'useSyncExternalStore', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: true, externals: ['react'], @@ -971,7 +918,6 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROD], moduleType: ISOMORPHIC, entry: 'use-sync-external-store/shim/index.native', - global: 'useSyncExternalStore', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: true, externals: ['react'], @@ -982,7 +928,6 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROD], moduleType: ISOMORPHIC, entry: 'use-sync-external-store/with-selector', - global: 'useSyncExternalStoreWithSelector', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: true, externals: ['react'], @@ -993,7 +938,6 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROD], moduleType: ISOMORPHIC, entry: 'use-sync-external-store/shim/with-selector', - global: 'useSyncExternalStoreWithSelector', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: true, externals: ['react', 'use-sync-external-store/shim'], @@ -1013,7 +957,7 @@ const bundles = [ ], moduleType: ISOMORPHIC, entry: 'scheduler', - global: 'Scheduler', + hasteFileName: 'Scheduler', minifyWithProdErrorCodes: true, wrapWithModuleBoundaries: true, externals: ['ReactNativeInternalFeatureFlags'], @@ -1031,7 +975,7 @@ const bundles = [ ], moduleType: ISOMORPHIC, entry: 'scheduler/unstable_mock', - global: 'SchedulerMock', + hasteFileName: 'SchedulerMock', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['ReactNativeInternalFeatureFlags'], @@ -1042,7 +986,6 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROD], moduleType: ISOMORPHIC, entry: 'scheduler/index.native', - global: 'SchedulerNative', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['ReactNativeInternalFeatureFlags'], @@ -1059,7 +1002,7 @@ const bundles = [ ], moduleType: ISOMORPHIC, entry: 'scheduler/unstable_post_task', - global: 'SchedulerPostTask', + hasteFileName: 'SchedulerPostTask', minifyWithProdErrorCodes: true, wrapWithModuleBoundaries: false, externals: [], @@ -1070,7 +1013,6 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROD], moduleType: ISOMORPHIC, entry: 'jest-react', - global: 'JestReact', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: ['react', 'scheduler', 'scheduler/unstable_mock'], @@ -1085,7 +1027,6 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROD], moduleType: ISOMORPHIC, entry: 'eslint-plugin-react-hooks', - global: 'ESLintPluginReactHooks', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: [], @@ -1096,7 +1037,6 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROD], moduleType: ISOMORPHIC, entry: 'react-refresh/babel', - global: 'ReactFreshBabelPlugin', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: [], @@ -1105,7 +1045,7 @@ const bundles = [ bundleTypes: [NODE_DEV, NODE_PROD, FB_WWW_DEV], moduleType: ISOMORPHIC, entry: 'react-refresh/runtime', - global: 'ReactFreshRuntime', + hasteFileName: 'ReactFreshRuntime', minifyWithProdErrorCodes: false, wrapWithModuleBoundaries: false, externals: [], @@ -1134,7 +1074,6 @@ deepFreeze(moduleTypes); function getFilename(bundle, bundleType) { let name = bundle.name || bundle.entry; - const globalName = bundle.global; // we do this to replace / to -, for react-dom/server name = name.replace('/index.', '.').replace('/', '-'); switch (bundleType) { @@ -1157,15 +1096,15 @@ function getFilename(bundle, bundleType) { case FB_WWW_DEV: case RN_OSS_DEV: case RN_FB_DEV: - return `${globalName}-dev.js`; + return `${bundle.hasteFileName}-dev.js`; case FB_WWW_PROD: case RN_OSS_PROD: case RN_FB_PROD: - return `${globalName}-prod.js`; + return `${bundle.hasteFileName}-prod.js`; case FB_WWW_PROFILING: case RN_FB_PROFILING: case RN_OSS_PROFILING: - return `${globalName}-profiling.js`; + return `${bundle.hasteFileName}-profiling.js`; case BROWSER_SCRIPT: return `${name}.js`; } diff --git a/scripts/rollup/wrappers.js b/scripts/rollup/wrappers.js index e76931bb85b4..2853657a39d3 100644 --- a/scripts/rollup/wrappers.js +++ b/scripts/rollup/wrappers.js @@ -56,34 +56,34 @@ const license = ` * Copyright (c) Meta Platforms, Inc. and affiliates. const topLevelDefinitionWrappers = { /***************** NODE_ES2015 *****************/ - [NODE_ES2015](source, globalName, filename, moduleType) { + [NODE_ES2015](source, filename) { return `'use strict'; ${source}`; }, /***************** ESM_DEV *****************/ - [ESM_DEV](source, globalName, filename, moduleType) { + [ESM_DEV](source, filename) { return source; }, /***************** ESM_PROD *****************/ - [ESM_PROD](source, globalName, filename, moduleType) { + [ESM_PROD](source, filename) { return source; }, /***************** BUN_DEV *****************/ - [BUN_DEV](source, globalName, filename, moduleType) { + [BUN_DEV](source, filename) { return source; }, /***************** BUN_PROD *****************/ - [BUN_PROD](source, globalName, filename, moduleType) { + [BUN_PROD](source, filename) { return source; }, /***************** NODE_DEV *****************/ - [NODE_DEV](source, globalName, filename, moduleType) { + [NODE_DEV](source, filename) { return `'use strict'; if (process.env.NODE_ENV !== "production") { @@ -94,17 +94,17 @@ ${source} }, /***************** NODE_PROD *****************/ - [NODE_PROD](source, globalName, filename, moduleType) { + [NODE_PROD](source, filename) { return source; }, /***************** NODE_PROFILING *****************/ - [NODE_PROFILING](source, globalName, filename, moduleType) { + [NODE_PROFILING](source, filename) { return source; }, /****************** FB_WWW_DEV ******************/ - [FB_WWW_DEV](source, globalName, filename, moduleType) { + [FB_WWW_DEV](source, filename) { return `'use strict'; if (__DEV__) { @@ -115,17 +115,17 @@ ${source} }, /****************** FB_WWW_PROD ******************/ - [FB_WWW_PROD](source, globalName, filename, moduleType) { + [FB_WWW_PROD](source, filename) { return source; }, /****************** FB_WWW_PROFILING ******************/ - [FB_WWW_PROFILING](source, globalName, filename, moduleType) { + [FB_WWW_PROFILING](source, filename) { return source; }, /****************** RN_OSS_DEV ******************/ - [RN_OSS_DEV](source, globalName, filename, moduleType) { + [RN_OSS_DEV](source, filename) { return `'use strict'; if (__DEV__) { @@ -136,17 +136,17 @@ ${source} }, /****************** RN_OSS_PROD ******************/ - [RN_OSS_PROD](source, globalName, filename, moduleType) { + [RN_OSS_PROD](source, filename) { return source; }, /****************** RN_OSS_PROFILING ******************/ - [RN_OSS_PROFILING](source, globalName, filename, moduleType) { + [RN_OSS_PROFILING](source, filename) { return source; }, /****************** RN_FB_DEV ******************/ - [RN_FB_DEV](source, globalName, filename, moduleType) { + [RN_FB_DEV](source, filename) { return `'use strict'; if (__DEV__) { @@ -157,19 +157,19 @@ ${source} }, /****************** RN_FB_PROD ******************/ - [RN_FB_PROD](source, globalName, filename, moduleType) { + [RN_FB_PROD](source, filename) { return source; }, /****************** RN_FB_PROFILING ******************/ - [RN_FB_PROFILING](source, globalName, filename, moduleType) { + [RN_FB_PROFILING](source, filename) { return source; }, }; const reconcilerWrappers = { /***************** NODE_DEV (reconciler only) *****************/ - [NODE_DEV](source, globalName, filename, moduleType) { + [NODE_DEV](source, filename) { return `'use strict'; if (process.env.NODE_ENV !== "production") { @@ -185,7 +185,7 @@ ${source} }, /***************** NODE_PROD (reconciler only) *****************/ - [NODE_PROD](source, globalName, filename, moduleType) { + [NODE_PROD](source, filename) { return `module.exports = function $$$reconciler($$$config) { var exports = {}; @@ -198,7 +198,7 @@ Object.defineProperty(module.exports, "__esModule", { value: true }); }, /***************** NODE_PROFILING (reconciler only) *****************/ - [NODE_PROFILING](source, globalName, filename, moduleType) { + [NODE_PROFILING](source, filename) { return `module.exports = function $$$reconciler($$$config) { var exports = {}; ${source} @@ -210,7 +210,7 @@ Object.defineProperty(module.exports, "__esModule", { value: true }); }, /***************** FB_WWW_DEV (reconciler only) *****************/ - [FB_WWW_DEV](source, globalName, filename, moduleType) { + [FB_WWW_DEV](source, filename) { return `'use strict'; if (__DEV__) { @@ -226,7 +226,7 @@ ${source} }, /***************** FB_WWW_PROD (reconciler only) *****************/ - [FB_WWW_PROD](source, globalName, filename, moduleType) { + [FB_WWW_PROD](source, filename) { return `module.exports = function $$$reconciler($$$config) { var exports = {}; @@ -239,7 +239,7 @@ ${source} }, /***************** FB_WWW_PROFILING (reconciler only) *****************/ - [FB_WWW_PROFILING](source, globalName, filename, moduleType) { + [FB_WWW_PROFILING](source, filename) { return `module.exports = function $$$reconciler($$$config) { var exports = {}; ${source} @@ -253,7 +253,7 @@ ${source} const licenseHeaderWrappers = { /***************** NODE_ES2015 *****************/ - [NODE_ES2015](source, globalName, filename, moduleType) { + [NODE_ES2015](source, filename) { return `/** * @license React * ${filename} @@ -265,9 +265,9 @@ ${source}`; }, /***************** ESM_DEV *****************/ - [ESM_DEV](source, globalName, filename, moduleType) { + [ESM_DEV](source, filename) { return `/** -* @license React + * @license React * ${filename} * ${license} @@ -277,9 +277,9 @@ ${source}`; }, /***************** ESM_PROD *****************/ - [ESM_PROD](source, globalName, filename, moduleType) { + [ESM_PROD](source, filename) { return `/** -* @license React + * @license React * ${filename} * ${license} @@ -289,9 +289,9 @@ ${source}`; }, /***************** BUN_DEV *****************/ - [BUN_DEV](source, globalName, filename, moduleType) { + [BUN_DEV](source, filename) { return `/** -* @license React + * @license React * ${filename} * ${license} @@ -301,7 +301,7 @@ ${source}`; }, /***************** BUN_PROD *****************/ - [BUN_PROD](source, globalName, filename, moduleType) { + [BUN_PROD](source, filename) { return `/** * @license React * ${filename} @@ -313,7 +313,7 @@ ${source}`; }, /***************** NODE_DEV *****************/ - [NODE_DEV](source, globalName, filename, moduleType) { + [NODE_DEV](source, filename) { return `/** * @license React * ${filename} @@ -325,7 +325,7 @@ ${source}`; }, /***************** NODE_PROD *****************/ - [NODE_PROD](source, globalName, filename, moduleType) { + [NODE_PROD](source, filename) { return `/** * @license React * ${filename} @@ -337,7 +337,7 @@ ${source}`; }, /***************** NODE_PROFILING *****************/ - [NODE_PROFILING](source, globalName, filename, moduleType) { + [NODE_PROFILING](source, filename) { return `/** * @license React * ${filename} @@ -349,7 +349,7 @@ ${source}`; }, /****************** FB_WWW_DEV ******************/ - [FB_WWW_DEV](source, globalName, filename, moduleType) { + [FB_WWW_DEV](source, filename) { return `/** ${license} * @@ -363,7 +363,7 @@ ${source}`; }, /****************** FB_WWW_PROD ******************/ - [FB_WWW_PROD](source, globalName, filename, moduleType) { + [FB_WWW_PROD](source, filename) { return `/** ${license} * @@ -377,7 +377,7 @@ ${source}`; }, /****************** FB_WWW_PROFILING ******************/ - [FB_WWW_PROFILING](source, globalName, filename, moduleType) { + [FB_WWW_PROFILING](source, filename) { return `/** ${license} * @@ -391,7 +391,7 @@ ${source}`; }, /****************** RN_OSS_DEV ******************/ - [RN_OSS_DEV](source, globalName, filename, moduleType) { + [RN_OSS_DEV](source, filename) { return signFile(`/** ${license} * @@ -405,7 +405,7 @@ ${source}`); }, /****************** RN_OSS_PROD ******************/ - [RN_OSS_PROD](source, globalName, filename, moduleType) { + [RN_OSS_PROD](source, filename) { return signFile(`/** ${license} * @@ -419,7 +419,7 @@ ${source}`); }, /****************** RN_OSS_PROFILING ******************/ - [RN_OSS_PROFILING](source, globalName, filename, moduleType) { + [RN_OSS_PROFILING](source, filename) { return signFile(`/** ${license} * @@ -433,7 +433,7 @@ ${source}`); }, /****************** RN_FB_DEV ******************/ - [RN_FB_DEV](source, globalName, filename, moduleType) { + [RN_FB_DEV](source, filename) { return signFile(`/** ${license} * @@ -447,7 +447,7 @@ ${source}`); }, /****************** RN_FB_PROD ******************/ - [RN_FB_PROD](source, globalName, filename, moduleType) { + [RN_FB_PROD](source, filename) { return signFile(`/** ${license} * @@ -461,7 +461,7 @@ ${source}`); }, /****************** RN_FB_PROFILING ******************/ - [RN_FB_PROFILING](source, globalName, filename, moduleType) { + [RN_FB_PROFILING](source, filename) { return signFile(`/** ${license} * @@ -478,7 +478,6 @@ ${source}`); function wrapWithTopLevelDefinitions( source, bundleType, - globalName, filename, moduleType, wrapWithModuleBoundaries @@ -521,7 +520,7 @@ function wrapWithTopLevelDefinitions( ); } - return wrapper(source, globalName, filename, moduleType); + return wrapper(source, filename); } // All the other packages. @@ -530,16 +529,10 @@ function wrapWithTopLevelDefinitions( throw new Error(`Unsupported build type: ${bundleType}.`); } - return wrapper(source, globalName, filename, moduleType); + return wrapper(source, filename); } -function wrapWithLicenseHeader( - source, - bundleType, - globalName, - filename, - moduleType -) { +function wrapWithLicenseHeader(source, bundleType, filename) { if (bundleType === BROWSER_SCRIPT) { // Bundles of type BROWSER_SCRIPT get sent straight to the browser without // additional processing. So we should exclude any extra wrapper comments. @@ -552,7 +545,7 @@ function wrapWithLicenseHeader( throw new Error(`Unsupported build type: ${bundleType}.`); } - return wrapper(source, globalName, filename, moduleType); + return wrapper(source, filename); } module.exports = {