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

ESM build is broken (for NodeJS) #2

Open
Venryx opened this issue Mar 10, 2022 · 1 comment
Open

ESM build is broken (for NodeJS) #2

Venryx opened this issue Mar 10, 2022 · 1 comment

Comments

@Venryx
Copy link

Venryx commented Mar 10, 2022

The ESM build/output is broken, as interpreted by NodeJS: nodejs/node#34515

Basically, NodeJS is not able to recognize the files in ./dist/esm/ as being ESM modules, because the files do not end in .mjs, and the closest package.json file to them does not contain type: module.

My opinion is that NodeJS should infer the files as ESM modules automatically (in this case, based on the module field pointing into the ./dist/esm folder), but the NodeJS devs seem opposed to that idea.

In the meantime, I must keep pestering library developers in the hopes they will appease NodeJS's ESM-import mode rules. 😭

@Venryx
Copy link
Author

Venryx commented Mar 10, 2022

When loading in webpack, another error is hit:

BREAKING CHANGE: The request './config' failed to resolve only because it was resolved as fully specified

The issue here seems to be that the command used to output the ESM build...

cross-env BABEL_ENV=esm babel src --root-mode upward --extensions .ts -d dist/esm --source-maps

...is not adding ".js" extensions to the paths to its file-imports, which it apparently "should" be doing to be proper ESM.

More info here: webpack/webpack#11467

Perhaps there is a flag that can be added to babel to have it produce "fully valid" es-modules output?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant