Open fortezhuo opened 6 months ago
It would be amazing if you avoided using 'prisma/client' entirely in the schema files to enable their usage on the client side (browser).
@michiim Yeah.. And for temp solution, since the files generated by zod-prisma-types automatically. I only can run simple patch to remove all of "z.instance(Prisma.Decimal)" after.
async function clean(path: string, files: string[]) {
for await (const file of files) {
let content = fs.readFileSync(resolve(path, `./${file}`), "utf8")
if (content.indexOf("z.instanceof(Prisma.Decimal)") >= 0) {
content = content.replaceAll("z.instanceof(Prisma.Decimal).array(),", "")
content = content.replaceAll("z.instanceof(Prisma.Decimal),", "")
fs.writeFile(resolve(path, `./${file}`), content, "utf8", (err) => {
if (!err) {
console.log(`File ${path}/${file} patched`)
}
})
}
}
}
@fortezhuo I don't think you should do that. It would be better if zod-prisma-types avoided using Prisma in the schema files, so that these files can also be used in browsers.
@chrishoermann what do you think if zod-prisma-types avoided using Prisma in the schema files ?
This is also an issue for me too. I am trying to import generated schemas into React Native but now I get complaints that Unable to resolve module os
.
Describe the bug z.instanceof(Prisma.Decimal) is not playing well with vite build while consume schema for client side
Screenshots
Package versions (please complete the following information):
Temp Workaround I remove all z.instanceof(Prisma.Decimal), and z.instance(Prisma.Decimal).array() using vscode