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

Add sideEffects: false flag to package.json to allow tree-shaking #2479

Closed
josdejong opened this issue Jul 25, 2024 · 5 comments · Fixed by #2480
Closed

Add sideEffects: false flag to package.json to allow tree-shaking #2479

josdejong opened this issue Jul 25, 2024 · 5 comments · Fixed by #2480

Comments

@josdejong
Copy link
Contributor

I have a library that amongst others exports a utility function createAjvValidator that uses ajv. Now, not all users of my library use this utility function, but I noticed that the Ajv library is always included when creating a js bundle containing my library, also when the ajv utility function is not used at all. It turns out that tree-shaking is not working.

Can the flag "sideEffects": false be added to the package.json file of ajv? That will enable tree shaking by Vite/Rollup/Webpack out of the box.

See:

@jasoniangreen
Copy link
Collaborator

jasoniangreen commented Jul 25, 2024

Sure @josdejong, do you want to make a PR for it and I'll run it by @epoberezkin ?

@josdejong
Copy link
Contributor Author

Definitely! Here you go: #2480

@jasoniangreen
Copy link
Collaborator

Merged. Not sure when it will go out, but I'll keep you posted.

@josdejong
Copy link
Contributor Author

Thanks Jason 👍

@josdejong
Copy link
Contributor Author

Any news on this @jasoniangreen? A bug fix release would be very welcome 😅

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

Successfully merging a pull request may close this issue.

2 participants