chevrotain icon indicating copy to clipboard operation
chevrotain copied to clipboard

Consider switching to ESM only build/artifacts

Open bd82 opened this issue 2 years ago • 1 comments

Why

Reduce maintenance overhead of supporting multiple consumption options, currently:

  1. commonjs
  2. UMD bundle
  3. UMD minified bundle
  4. ESM wrapper
  5. ESM bundle
  6. ESM minified bundle

For example Chevrotain currently uses two bundling tools, both esbuild and webpack

When

Likely still too early to do so, need to give the JS / Node community time to adjust. Some popular packages have started doing so already, we should keep track of their progress and/or success in doing so.

  • https://github.com/sindresorhus/meta/discussions/15
  • https://github.com/node-fetch/node-fetch/releases/tag/v3.0.0

How

  • Compile to ESM with TypeScript
  • Major version with breaking changes
  • Remove webpack, and attempt to use onlyesbuild
  • Remove minified UMD packages
  • Update playground / benchmarks to use ESM resources.
  • Update docs to clearly indicate the package is ESM only.

bd82 avatar Mar 06 '22 14:03 bd82

I think this should be evaluated at April 2023 once nodejs 16 is deprecated and all LTS nodejs versions will support ESM.

bd82 avatar Jun 20 '22 22:06 bd82

Switching to lodash-es and compiling typescript to ESM instead of commonjs seems to reduce the minified bundle size by ~20% (40Kb).

bd82 avatar Jul 05 '23 01:07 bd82

Done in: https://github.com/Chevrotain/chevrotain/pull/1953

I'm still keeping the UMD artifacts (chevrotain.js / chevrotain.min.js) for browser usage. But from nodejs only ESM is supported.

bd82 avatar Jul 08 '23 19:07 bd82