From a5ea56abbf43efc98d590f8718d1bc21877d2f3d Mon Sep 17 00:00:00 2001 From: Rasmus Eneman Date: Wed, 21 Nov 2018 20:39:33 +0100 Subject: [PATCH] Add allowESModules option to babel-preset-react-app (#5487) * Add allowESModules option to babel-preset-react-app * changes after feedback * Apply suggestions from code review Co-Authored-By: Pajn --- packages/babel-preset-react-app/create.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/babel-preset-react-app/create.js b/packages/babel-preset-react-app/create.js index 04b2b32a5c7..0f972477c23 100644 --- a/packages/babel-preset-react-app/create.js +++ b/packages/babel-preset-react-app/create.js @@ -29,6 +29,11 @@ module.exports = function(api, opts, env) { var isEnvProduction = env === 'production'; var isEnvTest = env === 'test'; + var useESModules = validateBoolOption( + 'useESModules', + opts.useESModules, + isEnvDevelopment || isEnvProduction + ); var isFlowEnabled = validateBoolOption('flow', opts.flow, true); var isTypeScriptEnabled = validateBoolOption( 'typescript', @@ -151,7 +156,7 @@ module.exports = function(api, opts, env) { // https://babeljs.io/docs/en/babel-plugin-transform-runtime#useesmodules // We should turn this on once the lowest version of Node LTS // supports ES Modules. - useESModules: isEnvDevelopment || isEnvProduction, + useESModules, // Undocumented option that lets us encapsulate our runtime, ensuring // the correct version is used // https://github.com/babel/babel/blob/090c364a90fe73d36a30707fc612ce037bdbbb24/packages/babel-plugin-transform-runtime/src/index.js#L35-L42