Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
andersekdahl opened this issue Nov 7, 2023 · 0 comments
Open

Comments

@andersekdahl
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant