Closed coreyfarrell closed 5 years ago
Hi @coreyfarrell!
It's on my TODO to limit .mjs
in this way. However, since esm
is all about ecosystem interop by default we won't be doing this for the non-mjs
case unless folks configure it.
When you say configuring it do you mean an esm
module option or do you mean using package.json type="module"?
I mean esm
option. I'm still working out what type="module"
means for esm
configuration.
Is it planned to impose mandatory file extensions on imports the way native node.js ESM does/will? I'm posing this question as a maintainer of nyc, so far it is not possible for nyc to support running under native ESM (lack of transpile hooks). This means ESM packages can only be tested under nyc if babel or esm is used. It would be nice if
nyc -r esm npm t
would throw errors if an import specifier uses extension resolution or folder to index.js resolution. Some examples that should throw:I realize this would probably be a breaking change for this module and native ESM is still flagged experimental so I understand if you do not want to make this change yet.
Ref https://nodejs.org/dist/latest-v12.x/docs/api/esm.html#esm_mandatory_file_extensions