Skip to content

Missing browser entry and/or sideEffects:false in package.json #89

@andersekdahl

Description

@andersekdahl

Hi!
We're using node-localstorage in Next.js apps and noticed that node-localstorage ends up in our browser bundle. We've been able to remove it by doing some webpack tomfoolery and wanted to check if this instead can be fixed in the package?

One thing is having "sideEffects": false in package.json:
https://webpack.js.org/guides/tree-shaking/#mark-the-file-as-side-effect-free

Another thing would be to have a browser field in package.json that points to a file that basically just does this:

module.exports = window.localStorage;

webpack and other bundlers would then prefer that file when the build target is for the browser, and you wouldn't end up with the real node-localstorage in the browser bundles.

I would have contributed with a PR but my coffeescript skills are less than ideal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions