zaggino / z-schema

JSON Schema validator written in JavaScript for NodeJS and Browsers
Other
340 stars 91 forks source link

feat: publish ESM bundle #302

Open jorenbroekema opened 2 months ago

jorenbroekema commented 2 months ago

Disclaimer: some of the files changes are related to me publishing a fork of this project on NPM because of some time constraints/urgency, let me know if you are open to this PR and I'll revert those changes related to the published fork. The idea of this contribution is just the ESM prebundled publish

Adds a bundle step to add mjs files to the dist folder, so that this project can be used natively as ESM without requiring a bundle-step on the consumer's end.

This isn't the same as the browser output since that just makes the default export available as a global variable on window. The reason why publishing as ESM (as opposed to browser global var) is preferred is because then it can be used in an isomorphic way in both Node and the Browser.

Even better would be for this package to be written in native ESM but maybe that's a contribution for another day, also let me know if you'd be open to it.