Skip to content

Commit 1899f52

Browse files
authored
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.
1 parent 3efcdbf commit 1899f52

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/babel-preset-react-app/create.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ module.exports = function(api, opts, env) {
9191
// bundle size. We shouldn't rely on magic to try and shrink it.
9292
useBuiltIns: false,
9393
// Do not transform modules to CJS
94-
modules: false,
94+
// unless useESModules is false
95+
modules: useESModules ? false : 'cjs',
9596
// Exclude transforms that make all code slower
9697
exclude: ['transform-typeof-symbol'],
9798
},

0 commit comments

Comments
 (0)