-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: separate module graphs per environment #16003
Conversation
Run & review this pull request in StackBlitz Codeflow. |
This comment was marked as outdated.
This comment was marked as outdated.
Nuxt is failing because Vitest and Svelte are failing because of |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Nuxt is now working. It seems there is ton of direct usage for the ModuleGraph maps, so we can't just ask the main frameworks to update. They are also iterating over the maps, so it looks like the maps should be backward compatible too. Here is the commit to add the compat layers for maps |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
📝 Ran ecosystem CI on
|
previewjs was failing because they used the VitePress was failing because they are using the internal Qwik and Rakkas are failing due to a puppeteer issue unrelated to this PR. We aren't that bad now. The CIs that are still failing are: vite-plugin-svelte, SvelteKit, vite-plugin-react, vike, histoire, and astro. |
Regarding VitePress, I am not completely sure, it's Evan's code 😅. But my guess is it's to trigger hmr when any of the files matching the watch pattern is added / removed. Probably we can write our own logic but maybe Evan wanted to reuse stuff (because that code is there since vite 2 and vitepress then was using too many vite internals). |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
…ansformResult and ssrTransformResult
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
/ecosystem-ci run |
📝 Ran ecosystem CI on
✅ histoire, ladle, laravel, marko, previewjs, qwik, rakkas, sveltekit, unocss, vike, vite-plugin-pwa, vite-plugin-react, vite-plugin-react-pages, vite-plugin-react-swc, vite-plugin-svelte, vite-plugin-vue, vite-setup-catalogue, vitepress, vitest |
This PR is a good reference to see that all downstream projects in ecosystem-ci were passing except for Astro and Nuxt with separate module graphs. Let's close this one as there is no much value to have it open, the latest work is at #16471 |
Description
We've been discussing a review of Vite's
server.moduleGraph
API. The idea would be to have separate generic module graphs for each environment instead of a single graph where each module node has mixed properties for the client (browser) and ssr (server) graphs.Instead of
This PR proposes:
Sending this PR as a draft so we can use it as a proof of concept to keep discussing.
Some details:
environment
string toresolveId
,load
, andtransform
and not only assr
boolean because we want to support one graph per environment (even if currently there are only two graphs). We may need to passenvironment
in other places.server.moduleGraph
keeps the same public methods API as before, returning a proxy that tries to be backward compatible with the previous mixed graph. Vitest usesgetModuleById
andgetModulesByFile
so these have been tested by passing Vite's CI. The others are not yet tested, and may need more work. I think we don't need to support the non-function members ofserver.moduleGraph
(all the maps).handle isomorphic module updates
) that I skipped for now to show the CI working for the draft. @sheremet-va maybe you could check it out if you have some time.Some initial open questions:
getModuleGraph(environment: string)
method for now, but it doesn't feel right.ssr
flag? Isenvironment !== 'browser'
equivalent to it? Or should each environment define if it is ssr or not (currently the flag is used for some branches in core plugins.ssr: { ... }
. Should we have arsc: { ... }
oredge: { ... }
? Each with its ownexternal
/noExternal
/conditions
?ssr.target: 'node' | 'webworker'
and make webworker be a environment?What is the purpose of this pull request?