mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
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:
committed by
GitHub
parent
400e822277
commit
ff89ba7346
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user