-
Notifications
You must be signed in to change notification settings - Fork 26
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
reexports detection incompatible with output from Rollup@^2.39.0 #38
Comments
/cc @lukastaegert |
Note that it's probably too late to make it work again in Node.js 12 so probably many users will be stuck with getting "named" import from the default import. |
PR that introduced the change in rollup: rollup/rollup#3959 |
cc @guybedford |
Seems weird to me why this change would break the lexer, but I am no expert on this matter. For Rollup, it fixes a serious bug and improves spec compliance. |
@lukastaegert It's because the new Rollup output has changed, and it doesn't match anymore the patterns recognized by this package (specifically, Fwiw, as a Babel maintainer I will never consider the generated output that
I'll still try to notify @guybedford (or even open a PR) whenever Babel's exports output changes. |
It is an unfortunate combination and I too feel that tools should not have to cater to what There are several aspects at play here:
I understand why Node provides named imports interop for cjs modules, but it feels a bit flaky for it to be based on code-generation-pattern specific static analysis (which leads to this problem here). |
I've put together a PR in #41. There have been a few changes coming together here, so when the release is made I can work on getting this backported as far as possible on the Node.js release lines. Support on Node.js 12 may not be possible though unfortunately. This project is very much a bandaid and a hack, bridging a divide that was never quite bridgeable. Hopefully we can avoid too much churn during this transition period. @lukastaegert I've also added detection for The Node.js release cutoffs will start to become a problem with this project where we risk things working in modern Node.js then failing in older versions. For that reason we should try to avoid changes to this project as much as possible, or where needed to make them sooner rather than later while the backports are still possible. |
Hi @guybedford, please reopen this issue, because it's not fixed due to the typo here: https://github.com/guybedford/cjs-module-lexer/pull/41/files#r667619960 |
Since Rollup@^2.39.0, the cjs output for re-exports has changed a bit:
The extra
hasOwnProperty
check breaks re-exports detection ofcjs-module-lexer
.The implication of this:
cjs-module-lexer
is used in Node.js' ESM mode to detect named exports compatibility for CJS modulescjs-module-lexer
was able to detect the re-exportsReproduction
https://github.com/yyx990803/cjs-module-lexer-rollup-reexports
npm run build
(which buildssrc/index.js
with Rollup toout.js
)node lex.js
(which runscjs-module-lexer
onout.js
)The text was updated successfully, but these errors were encountered: