GeezerVison is showing github.com — [Fresh] Add skipEnvCheck option to Babel plugin (#16688) · react/react@b260bef
File treeExpand file treeCollapse file tree Open diff view settings packages/react-refresh/src
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/react-refresh/src/ReactFreshBabelPlugin.js +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 7 | 7 |
| 8 | 8 | 'use strict'; | 9 | 9 |
| 10 | | -export default function(babel) { | | 10 | +export default function(babel, opts) { | 11 | 11 | if (typeof babel.getEnv === 'function') { | 12 | 12 | // Only available in Babel 7. | 13 | 13 | const env = babel.getEnv(); | 14 | | - if (env !== 'development' && typeof expect !== 'function') { | | 14 | + if (env !== 'development' && !opts.skipEnvCheck) { | 15 | 15 | throw new Error( | 16 | 16 | 'React Refresh Babel transform should only be enabled in development environment. ' + | 17 | 17 | 'Instead, the environment is: "' + | 18 | 18 | env + | 19 | | - '".', | | 19 | + '". If you want to override this check, pass {skipEnvCheck: true} as plugin options.', | 20 | 20 | ); | 21 | 21 | } | 22 | 22 | } | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-refresh/src/__tests__/ReactFreshBabelPlugin-test.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -19,7 +19,7 @@ function transform(input, options = {}) { | 19 | 19 | plugins: [ | 20 | 20 | '@babel/syntax-jsx', | 21 | 21 | '@babel/syntax-dynamic-import', | 22 | | - freshPlugin, | | 22 | + [freshPlugin, {skipEnvCheck: true}], | 23 | 23 | ...(options.plugins || []), | 24 | 24 | ], | 25 | 25 | }).code, | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-refresh/src/__tests__/ReactFreshIntegration-test.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -60,7 +60,7 @@ describe('ReactFreshIntegration', () => { | 60 | 60 | babelrc: false, | 61 | 61 | presets: ['@babel/react'], | 62 | 62 | plugins: [ | 63 | | - freshPlugin, | | 63 | + [freshPlugin, {skipEnvCheck: true}], | 64 | 64 | '@babel/plugin-transform-modules-commonjs', | 65 | 65 | compileDestructuring && '@babel/plugin-transform-destructuring', | 66 | 66 | ].filter(Boolean), | |
|