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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: @babel/parser: __esModule property is not defined in lib/index.js since version 7.22.11 #15934

Closed
1 task
tkallage opened this issue Sep 6, 2023 · 6 comments 路 Fixed by #15935
Closed
1 task
Labels
i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@tkallage
Copy link

tkallage commented Sep 6, 2023

馃捇

  • Would you like to work on a fix?

How are you using Babel?

Other (Next.js, Gatsby, vue-cli, ...)

Input code

working in 7.22.10:
npm i @babel/parser@7.22.10 local-pkg@0.4.3
run in node REPL:

require('local-pkg').importModule('@babel/parser').then(({parse}) => console.log(parse))

Result: [Function: parse]

not working in 7.22.11:
npm i @babel/parser@7.22.11 local-pkg@0.4.3
run in node REPL:

require('local-pkg').importModule('@babel/parser').then(({parse}) => console.log(parse))

Result: undefined

And

require('local-pkg').importModule('@babel/parser').then(({default: {parse}}) => console.log(parse))

Result: [Function: parse]

Configuration file name

No response

Configuration

No response

Current and expected behavior

unplugin-vue-components uses importModule() from the package local-pkg to import @babel/parser.
It recognizes the property __esModule to import the default export of @babel/parser.

With @babel/parser 7.22.10 this works fine, but since 7.22.11 the esModule-marker is missing in the resulting lib/index.js file, resulting in the imported object { default: { parser(), ... } } instead of { parser(), ... }.

Environment

System:
OS: Windows 10 10.0.22621
Binaries:
Node: 18.12.0 - C:\Program Files\nodejs\node.EXE
npm: 9.8.1 - <project_path>\node_modules.bin\npm.CMD
pnpm: 8.5.0 - C:\Program Files\nodejs\pnpm.CMD
npmPackages:
@babel/parser: ^7.22.11 => 7.22.11
@babel/runtime: ^7.22.11 => 7.22.11
eslint: ^8.48.0 => 8.48.0

Possible solution

Add

Object.defineProperty(exports, '__esModule', {
  value: true
});

at the top of the resulting file /lib/index.js in @babel/parser

Additional context

grafik
grafik

@tkallage tkallage changed the title [Bug]: __esModule property is not defined in lib/index.js since version 7.22.11 [Bug]: @babel/parser: __esModule property is not defined in lib/index.js since version 7.22.11 Sep 6, 2023
@babel-bot
Copy link
Collaborator

Hey @tkallage! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.

@nicolo-ribaudo
Copy link
Member

I'm incredibly confused by how this could have happened

@liuxingbaoyu
Copy link
Member

@nicolo-ribaudo #15038 I guess it is.

@nicolo-ribaudo
Copy link
Member

As a quick fix, we could just concatenate Object.defineProperty(exports, "__esModule", { value: true }) to the file generated by rollup.

@liuxingbaoyu
Copy link
Member

I found a workaround and will open a PR later. :)

@tkallage
Copy link
Author

tkallage commented Sep 7, 2023

Thanks for the fast fix! 鈾ワ笍

@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 Dec 8, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants