Set `modules: false` by default on babel-preset-env
See original GitHub issueI’m submitting a feature request
Webpack Version: >= 2.x
Babel Loader Version: 7.1.2
Current behavior:
I need to manually disable the modules
feature of Babel like this:
test: /\.js$/,
use: {
loader: 'babel-loader',
options: {
presets: ['env', { modules: false }]
}
}
To let webpack use its own ESM system.
Expected/desired behavior:
For webpack 2.x and higher, babel-loader can detect automatically that we don’t want to use modules
.
Sean said I had to mention loaderContext.version = 2
as a way to detect the new webpack version.
- What is the motivation / use case for changing the behavior?
Many people don’t know this, and especially people who upgraded from webpack 1.x to >2.x often don’t have this enabled (seen this a lot personally).
One problem with this is that it is a breaking change (or at least potentially), but at the long term I think it’s worth it. One less configuration option for most people.
Open question: is there a valid use-case where you want to have modules
on true
in webpack 2?
cc’ing @hzoo and @TheLarkInn because I know you talked about this a few minutes ago with eachother 🥇
Related: #519
Issue Analytics
- State:
- Created 6 years ago
- Reactions:15
- Comments:20 (6 by maintainers)
https://github.com/babel/babel-loader/pull/485/files does a lot of it already although it’s hardcoded (and we are going to move to scoped packages so it should support
@babel/preset-env
too)It’s possible others may disagree. Also I would add the dynamic import syntax on by default too
Also related is https://github.com/babel/babel-loader/pull/485 and #477 (issue)
Personally I’d rather just make it default, and even warn if they are using with webpack v1 to upgrade. No reason to not do it as long as there’s a way out if you need to
Totally fine with making a major version bump