Description
Problem
Tree-shaking is not working with v7 and above because the ESM build has been removed.
I am the author of Paraglide JS. Tree-shaking is a key differentiator. For locale detection reasons, I'd like to use path-to-regexp on the client. The lack of tree-shaking (which would increase the runtime size from <1kb to >4kb) and ESM problems like #346 prevent me from adopting path-to-regexp.
Using URLPattern
instead of path-to-regexp is not possible because a reverse compile function is missing whatwg/urlpattern#73.
Reproduction
- Open https://bundlejs.com/?q=path-to-regexp%407&treeshake=%5B%7B+compile+%6D%5D
- Press
build
- Repeat with v7 and v8
To inspect the bundle, disable minify: true
in the settings. V6 only contains functions used in compile,
while >V7 bundles everything.
Proposal
Re-introduce dual CJS + ESM build, or say goodbye to CJS altogether, now that Node supports native require(esm)
.