mirror of
https://github.com/facebook/react.git
synced 2026-02-24 12:43:00 +00:00
[Fresh] Add skipEnvCheck option to Babel plugin (#16688)
This commit is contained in:
@@ -7,16 +7,16 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
export default function(babel) {
|
||||
export default function(babel, opts) {
|
||||
if (typeof babel.getEnv === 'function') {
|
||||
// Only available in Babel 7.
|
||||
const env = babel.getEnv();
|
||||
if (env !== 'development' && typeof expect !== 'function') {
|
||||
if (env !== 'development' && !opts.skipEnvCheck) {
|
||||
throw new Error(
|
||||
'React Refresh Babel transform should only be enabled in development environment. ' +
|
||||
'Instead, the environment is: "' +
|
||||
env +
|
||||
'".',
|
||||
'". If you want to override this check, pass {skipEnvCheck: true} as plugin options.',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ function transform(input, options = {}) {
|
||||
plugins: [
|
||||
'@babel/syntax-jsx',
|
||||
'@babel/syntax-dynamic-import',
|
||||
freshPlugin,
|
||||
[freshPlugin, {skipEnvCheck: true}],
|
||||
...(options.plugins || []),
|
||||
],
|
||||
}).code,
|
||||
|
||||
@@ -60,7 +60,7 @@ describe('ReactFreshIntegration', () => {
|
||||
babelrc: false,
|
||||
presets: ['@babel/react'],
|
||||
plugins: [
|
||||
freshPlugin,
|
||||
[freshPlugin, {skipEnvCheck: true}],
|
||||
'@babel/plugin-transform-modules-commonjs',
|
||||
compileDestructuring && '@babel/plugin-transform-destructuring',
|
||||
].filter(Boolean),
|
||||
|
||||
Reference in New Issue
Block a user