question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide client generator configuration to avoid creation of `package.json`

See original GitHub issue

Note - I posted this in the Prisma slack channel but figure it might make sense to x-post here.

Problem

After upgrading from prisma@3.14.0 => prisma@3.15.2 we noticed that the prisma client generation has started to produce a package.json file which seems to breaks various assumptions of package managers (e.g. https://github.com/prisma/prisma/issues/13893, https://github.com/yarnpkg/berry/issues/4572). The latter is an issue I just filed on yarn but it is worth highlighting how it relates to the prisma change.

For us, we have a polyglot monorepo that utilizes yarn workspaces. We also have 3 databases, all of which we configure and access with Prisma. Accordingly, we generate multiple prisma clients in one monorepo (with more to come as we add additional services/apps). We utilize the client generation output configuration to plop the generated client into the ./dist of appropriately named and located package e.g. @{company-name}/users-service-orm (effectively wrapping it in our own package and tracking it as part of our package dependency graph).

As a rule, all of our package build artifacts (./dist dirs for TS packages in our monorepo) are gitignored in our top-level .gitignore as well as package-specific .gitignores. We agree with y’all that build artifacts shouldn’t end up in version control. The package.json that ends up in client package’s ./dist dir are getting picked up by yarn workspaces 😞 e.g. yarn workspace globbing doesn’t respect gitignored files/dirs.

That is very much a yarn problem but it does feel like the change to produce package.json files as part of client generation relies heavily on the assumption that you will put the generated SDK into node modules. I’ve read your docs on this matter and understand the reasoning but would also argue that it is not necessarily the most natural solution in all cases (e.g. a large polyglot monorepo).

Suggested solution

One idea/proposal - would you consider configuration for the client generation that would allow us to avoid creating a package.json, equivalent to saying that we will manage these build artifacts ourselves? Open to other ideas as well

generator client {
  provider       = "prisma-client-js"
  output         = "../orm/dist/"
  packaged       = false 
}

Alternatives

Stop producing a package.json

Additional context

I’m willing to implement a fix. Happy to contribute to one of our favorite libs.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:3
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
aqrlncommented, Jun 26, 2022
1reaction
joemckenneycommented, Jun 24, 2022

@janpio I’ve created minimal reproductions. See below / let me know if you have any questions.

Working Branch w/ prisma@3.14.0 && @prisma/client@3.14.0 https://github.com/joemckenney/prisma-13999/tree/prisma-3.14.0

Broken Branch w/ prisma@3.15.2 && @prisma/client@3.15.2 https://github.com/joemckenney/prisma-13999

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does openapi-generator not create a package.json with ...
Looks like the description of the plugin is not very clear (at least to me), because it seems that: <configuration> ...
Read more >
package.json - npm Docs
This is a set of config values that will be used at publish-time. It's especially handy if you want to set the tag,...
Read more >
Customization - OpenAPI Generator
#User-defined Templates. The most common scenario for user customization is to override the built-in templates with small modifications.
Read more >
Avoid regression by keeping your server and client code in sync
“generate”: “openapi-generator-cli generate -g typescript-axios -i openapi/backend-api.yml -c config.json -o lib/ui-dto ...
Read more >
AWS SDK for JavaScript v3
Inside of the project, run: yarn add @aws-sdk/client-dynamodb . Adding packages results in update in lock file, yarn.lock or package-lock.json.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found