Giter Club home page Giter Club logo

Comments (10)

ryardley avatar ryardley commented on May 20, 2024 1

If we can get away with only modifying watched files in webpack then that would be simpler as to be reactive we would want to setup something that looks like a "next manager" to listen for a specific event and restart the server.

from blitz.

flybayer avatar flybayer commented on May 20, 2024 1

Hey @tconroy, I haven't added next-prisma-plugin yet because it's still experimental from prisma and I don't know if it works with webpack 5. Also it doesn't it with our globalThis caching which we still do inside enhancePrisma.

So need to test that prisma plugin with webpack 5 plus change it to work with globalThis.

from blitz.

aem avatar aem commented on May 20, 2024

if we can either find a JS tool similar to entr or leverage nodemon somehow it should be pretty easy to restart the sevrer there. Or maybe even reuse some logic from the synchronizer to detect changes? @ryardley thoughts?

from blitz.

ryardley avatar ryardley commented on May 20, 2024

So just reading this I would say the issue is that because prisma generates new types etc. and they aren't loaded into next. Perhaps we can flag certain file changes (prisma.schema perhaps?) as tabling a restart of next?

from blitz.

flybayer avatar flybayer commented on May 20, 2024

I suspect this is because prisma client is inside node_modules and Next doesn't expect files in there to change.

Maybe we only need to modify the webpack config?

from blitz.

flybayer avatar flybayer commented on May 20, 2024

Related blitz-js/legacy-framework#466

from blitz.

clearink avatar clearink commented on May 20, 2024

Is there a solution?

from blitz.

flybayer avatar flybayer commented on May 20, 2024

@clearink I think the original issue might be fixed. But regardless, I'm sure there's a way to fix it. No-one has had time to dig into it yet, but anyone is welcome to do so!

Our current new app template has this in db/index.ts

let prisma: PrismaClient

if (process.env.NODE_ENV === "production") {
  prisma = new PrismaClient()
} else {
  // Ensure the prisma instance is re-used during hot-reloading
  // Otherwise, a new client will be created on every reload
  global["prisma"] = global["prisma"] || new PrismaClient()
  prisma = global["prisma"]
}

export default prisma

That is so that we don't run out of too many db connections during hot code reloading in dev. But I think that also may prevent reloading the schema without a restart.

Could you try removing that and see if a restart if still needed for schema changes?

from blitz.

flybayer avatar flybayer commented on May 20, 2024

Solution is to add https://github.com/williamluke4/next-prisma-plugin to our withBlitz webpack wrapper and to remove the globalThis stuff from the new app template.

from blitz.

tconroy avatar tconroy commented on May 20, 2024

Hey @flybayer 👋 it seems the globalThis stuff has been removed from the app template since this ticket was originally opened. Does that mean the only remaining step is to add the next-prisma-plugin to withBlitz? Have a branch locally with that change, happy to push it up. :-)

from blitz.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.