-
-
Notifications
You must be signed in to change notification settings - Fork 451
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
Set modules: false
by default on babel-preset-env
#521
Comments
Another open questions: should we hardcode this for babel-preset-env? What if you use babel-preset-es2015 (or should we ignore it because you should use env)?Or is there another way to automatically set this? |
Cool! Perhaps I can find some time to make a PR in a few days, but if anyone has the time and interest feel free to do it. |
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 It's possible others may disagree. Also I would add the dynamic import syntax on by default too |
I like this propose. I don't want to setup babel configurations respectively due to |
Would setting modules to false by default also make tree shaking work out of the box with webpack -p? I also agree with adding dynamic import. I spent hours trying to get dynamic importing to work, finding out later that I was using the wrong plugin (webpack's dynamic import vs Babel). |
@mikeaustin Indeed it would! |
Thanks for creating this issue. My project also broke due to |
What's the status of this issue? I wasn't afraid of this option too, found this issue looking for a reason why three shaking in my Webpack 4 setup doesn't work when using |
If we wanted, we could just hardcode it in preset-env #529 not that we have deprecated all the other presets (es2015, latest), and then figure out the generic solution later (same with dynamic import). Just need to check the webpack version. |
I think hard coding it sounds great. How great is the desire to support webpack one users though. Ideally that's the only compat challenge and I'd be personally fine with you making a webpack requirement to be v2+ for latest present version. But that would force a semver major? |
@hzoo allright! I've created a new PR, #650 (I messed up #529 completely. git & me are having relationship issues at the moment). It hardcodes preset-env as you said (AFAIK there are three ways of using it,
The code only kicks in on webpack > 1 and doing so is less than a line of code, so I think we can discuss supporting webpack 1 outside of this issue/PR 😄 (good point nonetheless). |
This should be resolved with #660 |
Hi, I'm trying to understand what is happening with modules. Originally this ticket was created to make From the link in open issue I see that https://github.com/babel/babel/pull/8485/files#r236086742 says
but I'm not sure what that means. Can someone please clarify this? So my understanding is that currently default ('auto') option sets modules to false, but it is not too clear in which case it will not do that. Please let me know if I'm missing something. |
@nicolo-ribaudo helped to answer that ❤️:
|
https://babeljs.io/docs/en/babel-preset-env#modules modules: I tried to set the option to
|
Which version are you using? |
Update:
With
In my case I just need Versions: |
Whats your full config? |
modules options is all about using either false or not use modules option even in preset in babel config file because by default |
I'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: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.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
ontrue
in webpack 2?cc'ing @hzoo and @TheLarkInn because I know you talked about this a few minutes ago with eachother 🥇
Related: #519
The text was updated successfully, but these errors were encountered: