I'm just quoting's @flybayer's message from the Prisma Slack turning it into a public GitHub issue
We鈥檙e currently having an issue properly keeping the prisma2
@prisma/client
out of the client side bundle in Next.js, (using it fromgetServerSideProps
).The Blitz core and example code on the canary branch works properly in production, but not in development.
- Here鈥檚 the code where
@prisma/client
is required from blitz coreThis blog post shows different ways to do this, but none of them are working when an npm package is requiring @prisma/client.
- This comment describes our current issue.
- This PR shows the hack we have to use right now to get it working in development
Good news: I found a good solution for this!
yarn install null-loader
next.config.js
module.exports = {
webpack(config, { isServer }) {
if (!isServer) {
// Ensure prisma client is not included in the client bundle
config.module.rules.push({
test: /@prisma\/client/,
use: "null-loader",
})
}
return config
},
}
Hey @flybayer,
Now that Next.js 9.3 is out, can you please confirm that you are able to still reproduce this.
If yes, can you share a minimal reproduction in a Git repository? If you can also configure that reproduction with webpack bundle analyzer, that would be super nice.
I'm no longer having this issue! It can be closed
Most helpful comment
Good news: I found a good solution for this!
yarn install null-loader
next.config.js