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
Native ESM module support #3385
Comments
Approach 2 https://github.com/nodejs/node/blob/master/doc/api/esm.md#approach-2-isolate-state actually sounds like a reasonable way forward. I would like to avoid importing CJS parts in the ESM parts of Rollup to provide an optimized build for JS API consumers and re-bundlers of Rollup, and I think it is reasonable to consider Rollup to be stateless enough. We could do this for Rollup 2. If it works correctly on Node 10, we are good to go. |
Ok, I really would love to support this but at the moment, acorn is being a huge pain here: acornjs/acorn#824 (comment) Basically I need to rewrite my code several times to use named imports for the browser build but default imports for the Node builds to make sure even the ESM version of Rollup pulls in the CJS version of acorn. |
Solved in rollup@2.0.0 |
Module support in node is still in early stages (and maybe not ready for runtime), but there are benefits to use it in a tool chain, and to begin creating packages with native support:
esm
transpilationNumerous options are possible as documented here:
https://github.com/nodejs/node/blob/master/doc/api/esm.md#approach-1-use-an-es-module-wrapper
Expected Behavior
This form should be usable from a package with native ESM support:
As verifiable via a simple command-line test:
Or as verifiable in context of the test package provided:
Actual Behavior
Error, as verifiable via a simple command-line test:
Or as verifiable in the context of the test package provided:
Workaround
The workaround is to use a wrapper or an alternate syntax to resolve the exports:
As verifiable via a simple command-line test:
Or as verifiable the in context of the test package provided, by commenting and uncommenting a few lines in
test.js
.The text was updated successfully, but these errors were encountered: