-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Barrel files (containing only exports) are considered CommonJS #2164
Comments
I believe the interpretation as CommonJS may be due to the use of |
Thanks for the answer!
Using CommonJS version doesn't throw any errors. But if we enforce using esm version then we end up with the error I posted originally ( Do you know a way of making |
@evanw how does is there any temporary workaround for this? |
Background
There's a common pattern to point
main
ormodule
to a barrel file, which contains exports from other files.An example dependency
@aws-sdk/client-s3
has amodule
entry which points to es module version of their code. This file contains onlyexport *
entries. Even though it's an es modules version, Node still treats it as a CommonJS and throws an error.Reproduction repository
https://github.com/zofiag/esm
node version: 16.14.2
Expected result:
No errors, node can run built files (
dist/index.js
).Actual result:
node_modules/@aws-sdk/client-s3/dist-es/index.js
is considered CommonJS even though it is not. That file containsexport *
entries that point to other es modules files.Notes
It seems to be more of a Node issue, but I couldn't find any useful info about it. Hope someone can help!
The text was updated successfully, but these errors were encountered: