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

Align named imports behavior in .mjs and .js files #14366

Merged
merged 2 commits into from Mar 22, 2022

Conversation

nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Mar 17, 2022

Q                       A
Fixed Issues? Fixes #14365
Patch: Bug Fix? Yes
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

The new behavior of defaulting to false is compatible with the old one, because it's strictly additive. When importing with import * as ns a file that exports module.exports = { foo: 1 } from an mjs file, the previous value of ns was { default: { foo: 1 } } and now it will be { default: { foo: 1 }, foo: 1 }.

This aligns the .mjs behavior with what we do in .js files, and with what Node.js does.

In Babel 8 we will remove mjsStrictNamespace option. We should probably also remove strictNamespace, now that Node.js doesn't have that behavior anymore.

@nicolo-ribaudo nicolo-ribaudo added PR: Bug Fix 🐛 A type of pull request used for our changelog categories area: modules labels Mar 17, 2022
@@ -1,5 +1,5 @@
// No exception should be thrown
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File renamed because our runner doesn't actually run exec.mjs files.

@babel-bot
Copy link
Collaborator

babel-bot commented Mar 17, 2022

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/51496/

@nicolo-ribaudo nicolo-ribaudo merged commit 71a003a into babel:main Mar 22, 2022
@nicolo-ribaudo nicolo-ribaudo deleted the fix-named-import-in-mjs branch March 22, 2022 18:51
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jun 22, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: modules outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: _interopRequireWildcard is not generated for .mjs files
4 participants