Skip to content

[Bug] __export function breaking ES module imports #7634

@edison1105

Description

@edison1105

minimal reproduction

steps to reproduce

  • cd pkgs
  • npm install
  • npm run build
  • cd ..
  • node test.js

expected behavior

  • should log [Function: bar]

actual behavior

  • throws SyntaxError: Named export 'bar' not found.

how to fix

  • open pkgs/packages/foo/dist/foo.js
  • change __export to __export1 or any other name
  • run node test.js again
  • should log [Function: bar]

env

  • node version v22.14.0

additional info

__export has special handling in cjs-module-lexer:
https://github.com/nodejs/cjs-module-lexer/blob/1910c8a095b741be468e4098b1490c906e6412cf/lexer.js#L122
https://github.com/nodejs/cjs-module-lexer/blob/1910c8a095b741be468e4098b1490c906e6412cf/lexer.js#L134

  • run node scripts/lexer-repro.cjs
  • should log OK but actually throws

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions