ajv-validator / ajv

The fastest JSON schema Validator. Supports JSON Schema draft-04/06/07/2019-09/2020-12 and JSON Type Definition (RFC8927)
https://ajv.js.org
MIT License
13.81k stars 875 forks source link

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

Closed josdejong closed 2 months ago

josdejong commented 2 months ago

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 commented 2 months ago

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

josdejong commented 2 months ago

Definitely! Here you go: #2480

jasoniangreen commented 2 months ago

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

josdejong commented 2 months ago

Thanks Jason 👍

josdejong commented 1 month ago

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