StefanTerdell / json-schema-to-zod

ISC License
336 stars 48 forks source link

vite build issue #81

Closed michaelbuehlmann closed 10 months ago

michaelbuehlmann commented 10 months ago

I'm running into an build issue after the v2 update when doing a production build with vite (in a sveltekit project). I think the problem is that fs is used in client-side code:

[vite-plugin-sveltekit-compile] "readFileSync" is not exported by "__vite-browser-external", imported by "node_modules/json-schema-to-zod/dist/esm/utils/cliTools.js".
file: ./node_modules/json-schema-to-zod/dist/esm/utils/cliTools.js:1:19
1: import { statSync, readFileSync } from "fs";
                      ^
2: export function parseArgs(params, args, help) {
3:     const result = {};

error during build:
RollupError: "readFileSync" is not exported by "__vite-browser-external", imported by "node_modules/json-schema-to-zod/dist/esm/utils/cliTools.js".

Problem is resolved when removing

export * from "./utils/cliTools.js"

from src/index.ts. Is it necessary to export the cliTools to library users?

Thanks for the great library!

StefanTerdell commented 10 months ago

80

StefanTerdell commented 10 months ago

Wait no, you're right. I didn't think I even did this. Will fix

StefanTerdell commented 10 months ago

@michaelbuehlmann Fixed in 2.0.14