Chevrotain / chevrotain

Parser Building Toolkit for JavaScript
https://chevrotain.io
Apache License 2.0
2.44k stars 200 forks source link

Consider switching to ESM only build/artifacts #1778

Closed bd82 closed 1 year ago

bd82 commented 2 years ago

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.

How

bd82 commented 2 years ago

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

bd82 commented 1 year ago

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

bd82 commented 1 year ago

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.