-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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 .mjs
support back to webpack (it has native ESM support)
#5258
Conversation
.mjs
support back to webpack, because webpack was not the problem.mjs
support back to webpack (it has native ESM support)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make sure we test this with packages that created problems before? And that they work in Jest due to the fallback?
We can use the existing behavior tests and add a few more, making sure GraphQL & friends work. |
Here's my understanding: The ecosystem is currently embracing experimental
This constraint has been applied to the following systems:
webpack 4's default behavior is to enforce spec for files with the This behavior aligns closely with what we currently see in the ecosystem:
I believe setting Given all the information provided above, I suggest we take the following path:
Potential issues:
|
I'm not following the issue… |
Do you mean the browser entry will start importing from the server files by accident? That shouldn't happen with this structure:
{
"browser": "lib/browser",
"main": "lib/server"
} |
The browser entry may not be pre-bundled into a separate tree or dist file. I'm imagining a {
"main": "index",
"module": "index.mjs",
"browser": "index.js"
} And a result of this: Just a thought. edit: we posted at the same time Yes, that structure fixes it. But graphql is a perfect example of these files being shipped side by side. https://unpkg.com/graphql@14.0.2/language/ I mentioned (maybe not clearly) that I don't think this would happen often, so it's probably nothing we need to be worried about. It's just a possible (not probable) concern. |
Not following what you mean with |
I used graphql just as an example, pretend it had a
The reason I say this is a concern is because (AFAIK) Node will resolve |
Just a side note, but I think with an extensionless |
Also, this example was incorrect: {
"main": "index.js",
"module": "index.mjs",
"browser": "index.js"
} Node.js only looks at the {
"main": "index",
"module": "index.mjs"
} ^ in that example you might have even gotten away with no |
I'm definitely a proponent of dropping |
I'm going to land this because it aligns with my latest understanding of this. For now, we'll classify this as a bug fix. Cases where this would be considered breaking probably aren't working right now anyway. We still need to come up with a good testing story for this (e2e). |
Tested via #5263. |
That mode aligns TS more with traditional Babel in terms of the
It would be wonderful if there was a way to give a heads up to folks that using
👏
I've done something similar, but less explicit, with the |
* Add `.mjs` support back to webpack, because webpack was not the problem * Continue toggling `.mjs` to `javascript/auto` mode * Be more inline with the specification * Bump old Node to 6
Fixes #5234.
Closes #5257.
Closes #5235.
Webpack was never the problem with
.mjs
support, so we probably shouldn't of removed it.We still want to figure out a story for Jest, we're just not sure what that is yet.
I opted to resolve
.mjs
before.web.js
this time, does this seem OK?