Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prisma seed incompatible with Nextjs et al. projects #5622

Closed
jasonkuhrt opened this issue Feb 12, 2021 · 1 comment · Fixed by #5820
Closed

Prisma seed incompatible with Nextjs et al. projects #5622

jasonkuhrt opened this issue Feb 12, 2021 · 1 comment · Fixed by #5820
Assignees
Labels
kind/improvement An improvement to existing feature and code. team/schema Issue for team Schema. topic: migrate
Milestone

Comments

@jasonkuhrt
Copy link
Member

Problem

TS projects that use an ESM value for compiler option "module" (such as any Nextjs project) will result in Prisma seed failing because the ts-node invocation will pass off ESM modules to Node:

Screen Shot 2021-02-11 at 5 27 50 PM

Suggested solution

The user should be able to customize how Prisma invokes ts-node.

For example in Nextjs projects I have have this npm script to make for a functioning ts-node in the project:

"ts-node": "ts-node --compiler-options '{\"module\":\"CommonJS\"}'",

I suggest prisma look for a ts-node script in the package and if found use that instead of calling ts-node directly.

Alternatives

  1. There could be a prisma config block in the package json like this:
  "prisma": {  "ts-node": "teach prisma how to invoke ts-node" }

I don't think we could support prisma.config.ts because chicken-egg problem here about how to invoke ts-node. And it it would be weird if users were forced to use a JS file to configure Prisma.

  1. Prisma could be smart enough to recognize that ts-node will never succeed with certain kinds of tsconfig settings, such as ESM module. Internally just always force CJS modules via --compiler-option flag.

Additional context

I think the solutions should not try to be 100%, include opt-out flags etc. The easiest way to opt-out is for user to --skip-seed and then run seed manually.

@Jolg42 Jolg42 added kind/improvement An improvement to existing feature and code. team/schema Issue for team Schema. topic: cli-migrate labels Feb 12, 2021
@Jolg42
Copy link
Member

Jolg42 commented Feb 12, 2021

Related #5161

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/improvement An improvement to existing feature and code. team/schema Issue for team Schema. topic: migrate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants