From 446aa9a632670eb9a373d897309452e24c10c55e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Markb=C3=A5ge?= Date: Fri, 19 Apr 2024 18:06:01 -0400 Subject: [PATCH] Build react-reconciler for FB builds (#28880) Meta uses various tools built on top of the "react-reconciler" package but that package needs to match the version of the "react" package. This means that it should be synced at the same time. However, more than that the feature flags between the "react" package and the "react-reconciler" package needs to line up. Since FB has custom feature flags, it can't use the OSS version of react-reconciler. --- scripts/rollup/bundles.js | 2 +- scripts/rollup/wrappers.js | 41 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/scripts/rollup/bundles.js b/scripts/rollup/bundles.js index 02cb0a84f07bb..08a47c6767aa9 100644 --- a/scripts/rollup/bundles.js +++ b/scripts/rollup/bundles.js @@ -782,7 +782,7 @@ const bundles = [ /******* React Reconciler *******/ { - bundleTypes: [NODE_DEV, NODE_PROD, NODE_PROFILING], + bundleTypes: [NODE_DEV, NODE_PROD, NODE_PROFILING, FB_WWW_DEV, FB_WWW_PROD], moduleType: RECONCILER, entry: 'react-reconciler', global: 'ReactReconciler', diff --git a/scripts/rollup/wrappers.js b/scripts/rollup/wrappers.js index 330ac071eec98..fb3ea66783bbb 100644 --- a/scripts/rollup/wrappers.js +++ b/scripts/rollup/wrappers.js @@ -204,6 +204,47 @@ module.exports.default = module.exports; Object.defineProperty(module.exports, "__esModule", { value: true }); `; }, + + /***************** FB_WWW_DEV (reconciler only) *****************/ + [FB_WWW_DEV](source, globalName, filename, moduleType) { + return `'use strict'; + +if (__DEV__) { + module.exports = function $$$reconciler($$$config) { + var exports = {}; +${source} + return exports; + }; + module.exports.default = module.exports; + Object.defineProperty(module.exports, "__esModule", { value: true }); +} +`; + }, + + /***************** FB_WWW_PROD (reconciler only) *****************/ + [FB_WWW_PROD](source, globalName, filename, moduleType) { + return `module.exports = function $$$reconciler($$$config) { + + var exports = {}; + ${source} + return exports; + }; + module.exports.default = module.exports; + Object.defineProperty(module.exports, "__esModule", { value: true }); + `; + }, + + /***************** FB_WWW_PROFILING (reconciler only) *****************/ + [FB_WWW_PROFILING](source, globalName, filename, moduleType) { + return `module.exports = function $$$reconciler($$$config) { + var exports = {}; + ${source} + return exports; + }; + module.exports.default = module.exports; + Object.defineProperty(module.exports, "__esModule", { value: true }); + `; + }, }; const licenseHeaderWrappers = {