Vite "project references" for running the dev server with on-demand build & HMR for dependency Vite library projects #10041
segevfiner
started this conversation in
Ideas
Replies: 2 comments 5 replies
-
Related to evanw/esbuild#1250 bundler(like esbuild) not full implement |
Beta Was this translation helpful? Give feedback.
0 replies
-
Did anyone ever figure out how to fix this? At the moment what I'm doing is to prebuild once and then run a watch with normal build, so it's building twice and the startup is slower but at least I'm able to work. I hope that eventually I could find a way to avoid doing this prebuild if someone has a better setup, please share. |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
To each development in a monorepo. TypeScript has a project references feature that allows it to automatically orchestrate the watching and cross project type checking inside a monorepo.
When using Vite in a monorepo with both library and an app project, you will lose the on-demand compilation & HMR that makes Vite so fast for the library code by default as you will need to use
vite build
to build the library for the app dev server to pick it up. You can use an alias, but you are then building the library code like it was part of the app code and no longer in isolation, this means it won't use it's project configuration appropriately and you must carefully tailor the app build configuration to make it compatible for it to build correctly.It would be cool if Vite had a dedicated feature for this in a similar style to TypeScript's project references that allows for
vite dev
to handle both the app and library projects with full on-demand compilation & HMR, proper handling of the configuration of the libraries vs app configuration and so on.e.g.
vite.config.ts
:And Vite will take care of the rest.
The Vite scenario for such a feature is a both more unique and needed than TypeScript project references which can also be resolved by an external orchestration solution, as Vite does on-demand compilation in dev mode which is not something that can be handled in an external tool when there is more than one project for Vite to handle.
Beta Was this translation helpful? Give feedback.
All reactions