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

Fix import { types } from "@babel/core" with native ESM #14663

Merged
merged 2 commits into from Jun 18, 2022

Conversation

nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Jun 12, 2022

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

This is another step in the direction of #13414. It makes it possible to use named imports for types, tokTypes, traverse and template from @babel/core, which were not available because the Node.js CJS-ESM interop doesn't recognize our lazy reexports.

Basically this code:

Object.defineProperty(exports, "types", {
  enumerable: true,
  get: function () {
    return _types();
  }
});

Is replaced by this (which is detected by the Node.js interpo) by a custom plugin:

Object.defineProperty((0, exports), "types", {
  enumerable: true,
  get: function () {
    return _types();
  }
});
0 && (exports.types = 0);

The second commit removes the usage of @babel/core's default export in our tests, which in theory shouldn't exist.

@nicolo-ribaudo nicolo-ribaudo added the PR: Bug Fix 🐛 A type of pull request used for our changelog categories label Jun 12, 2022
@nicolo-ribaudo nicolo-ribaudo added this to In progress in Move to native ES modules via automation Jun 12, 2022
@babel-bot
Copy link
Collaborator

babel-bot commented Jun 12, 2022

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

@nicolo-ribaudo nicolo-ribaudo merged commit a32306d into babel:main Jun 18, 2022
@nicolo-ribaudo nicolo-ribaudo deleted the import-types-from-core branch June 18, 2022 22:39
Move to native ES modules automation moved this from In progress to Done Jun 18, 2022
@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 Sep 18, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
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
Development

Successfully merging this pull request may close these issues.

None yet

4 participants