Comments (6)
Hi @shivghai turns out that @orta has similar experiences with his larger app as well ... and has invested some time in implementing hot module reloading (HMR) on the api/graphql side (still a WIP). He can provide more context, but perhaps we can offer a better experience soon.
from redwood.
@dthyresson Is there a thread I can follow? What do you recommend as next steps?
from redwood.
I'm happy to help with the implementation too, this is painful enough
from redwood.
No issue/thread to follow (#9738 relates because it's been my problem), I've mainly been prototyping outside of Redwood but the current runtime mechanics can be switched to remove the build step by moving to vite via: vite-node
Looking roughly like:
vite-node --watch src/server.ts
const schemas = import.meta.glob("./graphql/**/*.sdl.ts", { eager: true })
const services = import.meta.glob("./services/**/*.ts", { eager: true })
const fastify = Fastify({ logger: true })
const { yoga, logger } = createGraphQLYoga({
allowGraphiQL: true,
loggerConfig: {
logger: createLogger({}),
},
services: services as any,
sdls: schemas as any,
})
// [...]
function killServer() {
if (!_fastify) return
_fastify.close(() => {
console.error("Reset graphql")
})
}
// @ts-ignore
if (import.meta.hot) {
// @ts-ignore
const hot = import.meta.hot
hot.on("vite:beforeFullReload", () => {
console.log("HMR: full reload")
killServer()
})
hot.dispose(() => {
console.log("HMR: dispose")
killServer()
})
}
At a guess, to pull this off in Redwood would require:
- understanding how to safely stop using the current dev server
- figure out a watcher for files which need updating, that are currently in the build process
- make a codemod for changing the users user-land graphql function code to use vite-node compatible import syntax instead of the babel modifications
from redwood.
Thanks @orta !
@Josh-Walker-GM and @Tobbe - any thoughts on how we might get api/gql side hmr in dev server?
from redwood.
I have a more fleshed out working version of HMR in https://github.com/orta/redwood-vite-api
from redwood.
Related Issues (20)
- [RFC]: Remove default UserExample model in newly generated Redwood app
- [Background jobs] Generators
- [Bug?]: Trusted Documents does not work with Realtime. HOT 7
- [Feature]: ESLint flat config support for @redwoodjs/eslint-config HOT 2
- [Bug?]: corepack enable does nothing on fresh clone (yarn stays on v1.x) HOT 1
- [Feature]: ESLint flat config support for @redwoodjs/eslint-plugin HOT 1
- [Bug?]: Deploy to Vercel breaks all server functions (500 errors with cryptic messages) HOT 9
- [Bug?]: yarn rw setup server-file fails with js but works with ts HOT 5
- Multiple RW apps all use the same debug port HOT 2
- Syntax check `package.json` for dual ESM+CJS support in `@redwoodjs/auth`
- [Bug?]: cannot set bodyLimit using server.ts HOT 2
- [Bug?]: Clarify impact on database file location with prisma multi file schema HOT 2
- [Bug]: Flaky dbAuth test in framework tests
- [RWUploads] Spike prisma extensions and if its possible to detect a specific model
- [RWUploads] Spike Prisma single table inheritance
- Background Jobs: Re-work to procedural design
- [Bug?]: Generate page command not working HOT 4
- [Bug?]: Fastify server throws an error when using custom server.ts and enriched graphql yoga server HOT 6
- [Bug]: Server doesn't handle periods in path parameters HOT 1
- [Bug?]: Storybook won't work with Mantine HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from redwood.