Using in the browser
I'm using the minified version of ajv7 in Javascript, and i want to support other formats, which are in the ajv-formats package. I want to import ajv-formats, which is written in typescript, to my Javascript project. Is there a possibility to make it ? Does a minified version of ajv-formats exist ?
No, it is not provided. There is a compiled JS code though that it would be much more efficient to bundle with your code rather than use as a separate bundle as it's really small.
Where can i find the compiled JS code? can you provide me the link please.
@epoberezkin what if I just want to load ajv-formats in the browser, just like ajv-dist, no build/bundle involved?
We could use it directly in the browser without any bundlers with a small ESM wrapper const ajv-formats = await import('https://unpkg.com/[email protected]/dist/index.js', that's a dynamic import, but a static one SHOULD work just as well. It doesn't because the current dist is only compiled to CommonJS.
In the meantime you can use Vite/ESBuild, it compiles just fine without any polyfills https://stackblitz.com/edit/vitejs-vite-pmhsra?file=src/main.ts
Thanks for that, it was exactly what I've started testing after my comment :)