Skip to content

v7 and v8 are not tree-shakable #347

Open
@samuelstroschein

Description

@samuelstroschein

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

  1. Open https://bundlejs.com/?q=path-to-regexp%407&treeshake=%5B%7B+compile+%6D%5D
  2. Press build
  3. 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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions