[Pkg-javascript-devel] Bug#932965: Fix ES module exports in node-magic-string : what is left?

Pirate Praveen praveen at onenetbeyond.org
Tue Jul 30 20:12:59 BST 2019


On 2019-07-31 00:33, Julien Puydt wrote:
> Hi,
> 
> the original report was about shipping the files correctly and fixing
> the ES module exports.
> 
> For the first part you already committed a fix, and for the later, I 
> had
> a look and the end of dist/magic-string.es.js is:
> 
> export { Bundle, SourceMap };
> export default MagicString$1;
> //# sourceMappingURL=magic-string.es.js.map
> 
> 
> which looks quite correct as far as I understand things.

It is correct for rollup's implementation of ES modules, but node esm 
loader (node --experimental-modules command) does not support it. See 
https://github.com/nodejs/help/issues/2081

node currently considers a file as ES module only if package.json has a 
"type": "module" field or the file extension is .mjs.

So upstream has to decide, but we will have to wait till esm loader 
becomes stable in node core first before we request upstream to change 
it.

For now, we can use module.createRequire() option to load commonjs. See 
esm branch of node-rollup.

> Can I upload?

Yes.

> JP



More information about the Pkg-javascript-devel mailing list