From 1899f52838d21bb5b47d2c099c8b148256c48f50 Mon Sep 17 00:00:00 2001 From: Dallon Feldner Date: Tue, 22 Jan 2019 11:23:03 -0600 Subject: [PATCH] Fix babel preset useESModules option Currently, `useESModules` only affects `@babel/plugin-transform-runtime` (so the compiled code not reference ESM versions of `@babel/runtime`). This is somewhat misleading, since the resulting code will still contain ES Module syntax if the source uses it. With this update, `useESModule: false` really means that the resulting code will not contain ES Module syntax. --- packages/babel-preset-react-app/create.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/babel-preset-react-app/create.js b/packages/babel-preset-react-app/create.js index a0423f2551c..751d9c5249d 100644 --- a/packages/babel-preset-react-app/create.js +++ b/packages/babel-preset-react-app/create.js @@ -91,7 +91,8 @@ module.exports = function(api, opts, env) { // bundle size. We shouldn't rely on magic to try and shrink it. useBuiltIns: false, // Do not transform modules to CJS - modules: false, + // unless useESModules is false + modules: useESModules ? false : 'cjs', // Exclude transforms that make all code slower exclude: ['transform-typeof-symbol'], },