Quramy / prisma-fabbrica

Prisma generator to define model factory

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature: Generate a package in node_modules rather than creating generated files

youssefm opened this issue · comments

This is a feature request.

The way Prisma works, and the way prisma-factory works, they generate a package in node_modules rather then generating source files.

This makes it easy to import files without having to think about where the files are or whether they need to be committed into the repo.

Ideally, you could run prisma generate and then write:

import { defineUserFactory } from "prisma-fabricca/generated"

and it would just work.

You can do this via output parameter.

generator fabbrica {
  provider    = "prisma-fabbrica"
  output      = "../node_modules/@quramy/prisma-fabbrica/generated"
}

@Quramy I tried it out and I don't think it actually works.

If you try:

import { defineUserFactory } from "@quramy/prisma-fabricca/generated"

you get:

Cannot find module '@quramy/prisma-fabricca/generated' from 'factories.ts'

I think node expects every module to also have a package.json file that defines how you can access the module, and the generated module does not have one. You would have to generate a valid package.json for this to work properly.

It turns out I just had a typo, it works perfectly fine @Quramy, thanks.