Releases: wessberg/cjstoesm
v1.1.0
v1.0.1
v1.0.0
New Features
Automatic and configurable addition of file extensions to module specifiers
Support for EcmaScript modules is now stable in both node.js and supported browsers. In both of these environments, file extensions must be provided to module specifiers when using ES modules. Additionally, directory indexes must also be fully specified.
Until now, cjstoesm
always preserved module specifiers as they were. While this might work fine for a lot of use cases, ideally cjstoesm
generates standards compliant modules.
Going forward, this behavior is now configurable and defaults to adding file extensions to relative module specifiers, while leaving alone module specifiers for built-in modules and external libraries. The preserveModuleSpecifiers
option (or --preserve-module-specifiers
via the CLI).
Here's all the supported options:
external
(default): CommonJS module specifiers identifying libraries or built-in modules are preservedinternal
: CommonJS module specifiers identifying anything else than libraries or built-in modules are preservedalways
: CommonJS module specifiers are never transformed.never
: CommonJS module specifiers are always transformed
It can also take a function that is invoked with a module specifier and returns a boolean determining whether or not it should be preserved.