chevrotain
chevrotain copied to clipboard
Consider switching to ESM only build/artifacts
Why
Reduce maintenance overhead of supporting multiple consumption options, currently:
- commonjs
- UMD bundle
- UMD minified bundle
- ESM wrapper
- ESM bundle
- 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 only
esbuild
- Remove minified UMD packages
- Update playground / benchmarks to use ESM resources.
- Update docs to clearly indicate the package is ESM only.
I think this should be evaluated at April 2023 once nodejs 16 is deprecated and all LTS nodejs versions will support ESM.
Switching to lodash-es and compiling typescript to ESM instead of commonjs seems to reduce the minified bundle size by ~20% (40Kb).
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.