Skip to content

v1.0.0

Choose a tag to compare

@wessberg wessberg released this 17 Mar 15:58
· 54 commits to master since this release

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 preserved
  • internal: CommonJS module specifiers identifying anything else than libraries or built-in modules are preserved
  • always: 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.

Full changelog

  • docs(README): update README 02213db
  • feat: add new option, 'preserveModuleSpecifiers' 1bad5b7

v0.1.3...v1.0.0