zenstack
zenstack copied to clipboard
Zenstack VSCode plugin import from a NPM package leads to `Cannot find model file` error
Zenstack plugin import from a npm package leads to Cannot find model file (although it does work when trying to do npx zenstack generate)
Plugin version: v2.3.0
An easy way to reproduce in case you need a npm package:
npm install @dptickets2/common
then in schema.zmodel file:
import '@dptickets2/common/models/outbox'
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")}
The issue is quite annoying because right now in vscode, i have an error indication that reflects on my whole repository.
Another issue - from some reason the assumption is that i must have in my npm module a schema.zmodel, specifically with schema name, even if it's not being used and u make also other zmodel fiels and include only them.
Hi @Tsimopak , a late follow up here 😄. ZenStack uses standard node.js module resolution to resolve imported zmodel files (by calling require.resolve) , so the imported package need to have proper exports in package.json file.
Adding the following should resolve the error:
{
"exports": {
...
"./models/outbox.zmodel": "./models/outbox.zmodel"
}
}
Resolving the issue fornow.