Skip to content

Commit

Permalink
[Fresh] Add skipEnvCheck option to Babel plugin (#16688)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon authored Sep 6, 2019
1 parent 2f15881 commit b260bef
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions packages/react-refresh/src/ReactFreshBabelPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function transform(input, options = {}) {
plugins: [
'@babel/syntax-jsx',
'@babel/syntax-dynamic-import',
freshPlugin,
[freshPlugin, {skipEnvCheck: true}],
...(options.plugins || []),
],
}).code,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit b260bef

Please sign in to comment.