Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change @babel/preset-env modules to 'auto' #2709

Merged

Conversation

rossta
Copy link
Member

@rossta rossta commented Aug 24, 2020

@babel/preset-env already defaults to 'auto' and encourages its use when using babel with a bundler such as webpack.

According to babel docs (source: https://babeljs.io/docs/en/babel-preset-env#modules)

Setting this to false will preserve ES modules. Use this only if you intend to ship native ES Modules to browsers. If you are using a bundler with Babel, the default modules: "auto" is always preferred.

I believe this would also be consistent with create-react-app which appears to use the default.

Given this info, I believe Webpacker should follow suit.

@babel/preset-env already defaults to `'auto'` and encourages its use
when using babel with a bundler such as webpack.

According to babel docs
https://babeljs.io/docs/en/babel-preset-env#modules

> Setting this to false will preserve ES modules. Use this only if you intend to ship native ES Modules to browsers. If you are using a bundler with Babel, the default modules: "auto" is always preferred.

Given this info, I believe Webpacker should follow suit.
@gauravtiwari gauravtiwari merged commit 3be7381 into rails:master Aug 24, 2020
@justin808
Copy link
Contributor

@gauravtiwari @rossta If the default is 'auto', why specify it?

create-react-app specifies less:

https://github.com/facebook/create-react-app/blob/42dcf79b43171449a116ddcb51dce7b043cdb1d2/packages/babel-preset-react-app/create.js#L80-L88

        require('@babel/preset-env').default,
        {
          // Allow importing core-js in entrypoint and use browserlist to select polyfills
          useBuiltIns: 'entry',
          // Set the corejs version we are using to avoid warnings in console
          corejs: 3,
          // Exclude transforms that make all code slower
          exclude: ['transform-typeof-symbol'],
        },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants