Add modules: false by default for es2015/env/latest presets#529
Add modules: false by default for es2015/env/latest presets#529SpaceK33z wants to merge 0 commit intobabel:masterfrom SpaceK33z:disable-modules-default
modules: false by default for es2015/env/latest presets#529Conversation
|
Override shouldnt be done with true but with a module type to match the mentioned presets options |
|
@SpaceK33z should I abandon my PR? |
|
@wardpeet, yeah this would make your PR redundant. Sorry about that, but I did end up using much of your code! |
|
@SpaceK33z no worries, thought it did the same as my PR 👍 |
|
I would be still in favor of showing a warning similar to |
src/index.js
Outdated
| } | ||
|
|
||
| if (this.version > 1 && options.presets) { | ||
| const presetsWithModulesOption = ["es2015", "env", "latest"]; |
There was a problem hiding this comment.
const presets = [ "es2015", "env", "latest" ]
// not sure if really needed (?)
const name = (name) => name
.replace(/^@babel\//, "")
.replace(/^preset-/, "")
options.presets.forEach((preset) => presets.indexOf(name(preset[0])) > -1
? preset[1] !== undefined
? preset[1].modules = false
: preset[1] = { modules: false }
: preset
)|
Guys, what is the status of this PR? |
|
I messed up this PR by using force push, so I made a new PR #650. |
Please check if the PR fulfills these requirements
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
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,latestandes2015will be mutated to addmodules: falseas an option. This also works when you use e.g.@babel/preset-envor@babel/env.Does this PR introduce a breaking change?
For people who use babel-loader without setting the
modulesoption, 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: trueor 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