Disable consoleWithStackDev Transform except in RN/WWW (#30313)

Stacked on #30308.

This is now a noop module so we can stop applying the transform of
console.error using the Babel plugin in the mainline builds. I'm keeping
the transform for RN/WWW for now although it might be nice if the
transform moved into those systems as it gets synced instead of keeping
it upstream.

In jest tests we're already not running the forks for RN/WWW so we don't
need it at all there.
This commit is contained in:
Sebastian Markbåge authored and GitHub committed 2024-07-12 14:39:38 -04:00
1 parent 400e822277
commit ff89ba7346
10 files changed
+50 -95

No files matched your search

+1 -11
View File
@@ -16,9 +16,6 @@ const pathToBabel = path.join(
'../..',
'package.json'
);
const pathToBabelPluginReplaceConsoleCalls = require.resolve(
'../babel/transform-replace-console-calls'
);
const pathToTransformInfiniteLoops = require.resolve(
'../babel/transform-prevent-infinite-loops'
);
@@ -73,14 +70,7 @@ module.exports = {
const isInDevToolsPackages = !!filePath.match(
/\/packages\/react-devtools.*\//
);
const testOnlyPlugins = [];
const sourceOnlyPlugins = [];
if (process.env.NODE_ENV === 'development' && !isInDevToolsPackages) {
sourceOnlyPlugins.push(pathToBabelPluginReplaceConsoleCalls);
}
const plugins = (isTestFile ? testOnlyPlugins : sourceOnlyPlugins).concat(
babelOptions.plugins
);
const plugins = [].concat(babelOptions.plugins);
if (isTestFile && isInDevToolsPackages) {
plugins.push(pathToTransformReactVersionPragma);
}
-1
View File
@@ -68,7 +68,6 @@ function transform(file, enc, cb) {
gs([
'packages/**/*.js',
'!packages/*/npm/**/*.js',
'!packages/shared/consoleWithStackDev.js',
'!packages/react-devtools*/**/*.js',
'!**/__tests__/**/*.js',
'!**/__mocks__/**/*.js',
+16 -10
View File
@@ -149,16 +149,22 @@ function getBabelConfig(
sourcemap: false,
};
if (isDevelopment) {
options.plugins.push(
...babelToES5Plugins,
// Turn console.error/warn() into a custom wrapper
[
require('../babel/transform-replace-console-calls'),
{
shouldError: !canAccessReactObject,
},
]
);
options.plugins.push(...babelToES5Plugins);
if (
bundleType === FB_WWW_DEV ||
bundleType === RN_OSS_DEV ||
bundleType === RN_FB_DEV
) {
options.plugins.push(
// Turn console.error/warn() into a custom wrapper
[
require('../babel/transform-replace-console-calls'),
{
shouldError: !canAccessReactObject,
},
]
);
}
}
if (updateBabelOptions) {
options = updateBabelOptions(options);
+16 -10
View File
@@ -149,16 +149,22 @@ function getBabelConfig(
sourcemap: false,
};
if (isDevelopment) {
options.plugins.push(
...babelToES5Plugins,
// Turn console.error/warn() into a custom wrapper
[
require('../babel/transform-replace-console-calls'),
{
shouldError: !canAccessReactObject,
},
]
);
options.plugins.push(...babelToES5Plugins);
if (
bundleType === FB_WWW_DEV ||
bundleType === RN_OSS_DEV ||
bundleType === RN_FB_DEV
) {
options.plugins.push(
// Turn console.error/warn() into a custom wrapper
[
require('../babel/transform-replace-console-calls'),
{
shouldError: !canAccessReactObject,
},
]
);
}
}
if (updateBabelOptions) {
options = updateBabelOptions(options);