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

Add modules: false by default for es2015/env/latest presets #650

Closed
wants to merge 2 commits into from
Closed

Add modules: false by default for es2015/env/latest presets #650

wants to merge 2 commits into from

Conversation

SpaceK33z
Copy link

Note this is an update version of PR #529.

Please check if the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior? (You can also link to an open issue here)

See #521.

What is the new behavior?

The Babel presets env, latest and es2015 will be mutated to add modules: false as an option. This also works when you use e.g. @babel/preset-env or @babel/env.

Does this PR introduce a breaking change?

  • Yes
  • No

For people who use babel-loader without setting the modules option, there might be small differences in the way webpack handles ES modules.

For people who still want to keep the old behavior, they can explicitly add modules: true or e.g. modules: "amd".

Other information:

I am not happy at all with the implementation, but it works. Let me know if there is a better way I missed.

I used parts of the code in #485, so credits to @wardpeet!

Fixes #521, fixes #477, fixes #485

See #521 for the reasoning.
I am not happy at all with the implementation, but it works. Let me know if there is a better way I missed.

Fixes #521, #477, #485
@Andarist
Copy link
Member

Andarist commented Aug 7, 2018

I think there should be something done, because current situation is way from ideal and people shouldn't worry about it (unless they want to). But change such as this doesnt account for .babelrc/.babelrc.js/package.json#babel/babel.config.js lookup.

@SpaceK33z
Copy link
Author

SpaceK33z commented Aug 8, 2018

@Andarist, you're right, it doesn't work for .babelrc etc right now so this is kinda useless. Didn't notice that (when this PR was initially made in 2017 this did work btw).

Spent some time trying to fix this, but got stuck at not being able to mutate the options from a ConfigItem. I'm completely new to the Babel codebase, so would you have any pointers on how to easily do that?

@Andarist
Copy link
Member

Andarist commented Aug 8, 2018

I'm completely new to the Babel codebase, so would you have any pointers on how to easily do that?

I'm not familiar with config loading myself. In general I think it would be better to validate the config rather than mutate it, but also ain't sure how to do it right now. @loganfsmyth should know if it's even possible right now, or if there is anything that can be done in babel itself to make this use case easier.

@Andarist
Copy link
Member

Seems like this should be closed in favour of #660 . Thanks for making this PR - it certainly pushed the needed changes forward so that this can get resolved once and for all now :)

@Andarist Andarist closed this Aug 21, 2018
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.

Set modules: false by default on babel-preset-env Warning if transpiling ES modules to commonjs
2 participants