Skip to content

[FEATURE] Separate functions into isolated imports for tree shaking #291

@Aghassi

Description

@Aghassi

What / Why

We rely on two or three functions out of this package, and it costs us 5kbs minified at runtime in the browser. We would like the ability to treeshake modules such that we can continue to rely on the package.

Here is the bundlephobia for the package currently. https://bundlephobia.com/[email protected]

Where

Enterprise products owned by Intuit

How

Instead of doing

import semver from "semver"

// ...

semver.valid(/* ... */);

Have the ability to do

import valid from "semver/valid"

valid();

Current Behavior

I must import the entire default module to ensure that I can get a single function off of the module.

Expected Behavior

I should be able to import only the functionality that I care about when targeting the web.

Who

@Aghassi

References

  • n/a

Although there are similar alternatives for specific use cases such as https://www.npmjs.com/package/semver-compare

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