-
-
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
fix(vite)!: refactor "module cache" to "evaluated modules", pass down module to "runInlinedModule" #18092
fix(vite)!: refactor "module cache" to "evaluated modules", pass down module to "runInlinedModule" #18092
Conversation
Run & review this pull request in StackBlitz Codeflow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few minor observations/questions but looks good. Thanks.
/** | ||
* Invalidate modules that dependent on the given modules, up to the main entry | ||
*/ | ||
invalidateDepTree( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was using invalidateDepTree
in my example for rsc environment's node runner https://github.com/hi-ogawa/vite-environment-examples/blob/edf04cf23fb472a9d085e1a424ae7543164b98f8/examples/react-server/vite.config.ts#L173 but it doesn't look necessary since it's same as default non-hmr invalidation, so I just removed it hi-ogawa/vite-environment-examples#109
/ecosystem-ci run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discussed that we may want to rename runner.moduleGraph
to runner.evaluatedModules
to avoid confusions between two module graphs being different. Good to do this later though.
📝 Ran ecosystem CI on
✅ analogjs, astro, ladle, laravel, marko, previewjs, quasar, qwik, rakkas, redwoodjs, storybook, sveltekit, unocss, vite-plugin-pwa, vite-plugin-react, vite-plugin-react-swc, vite-plugin-svelte, vite-plugin-vue, vite-setup-catalogue, vitepress, vitest, vuepress |
/ecosystem-ci run nuxt |
📝 Ran ecosystem CI on
✅ |
My example's |
Previously, |
|
JSDoc says that "id" is "ID that was used to fetch the module", not the module ID. Technically, it's a "url". Why don't you use I guess we can just pass down the |
Good point, using |
/ecosystem-ci run |
📝 Ran ecosystem CI on
✅ astro, ladle, laravel, marko, previewjs, quasar, qwik, rakkas, redwoodjs, storybook, sveltekit, unocss, vite-environment-examples, vite-plugin-pwa, vite-plugin-react, vite-plugin-react-swc, vite-plugin-svelte, vite-plugin-vue, vite-setup-catalogue, vitepress, vitest, vuepress |
Seems like the errors are the same as before the PR |
Nuxt seems to be passing in main: https://github.com/vitejs/vite-ecosystem-ci/actions/runs/11031700332/job/30639019630 🤔 |
Seems like it's just flaky because it worked yesterday after a rerun: #18092 (comment) The changes after that can't affect Nuxt since it doesn't use these APIs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok to merge this now and deal with the Nuxt issue later if it is unrelated. The linked comment shows that it was failing though (and I tried twice in main and it worked both times 🤔)
(removed the |
Description
This PR refactors vite-node's
moduleCache
intoEvaluatedModules
that resembles what Vite already has on the server.This is not part of the PR as of September 23, it will be a separate discussion.
This PR also add a new proposal to extend
import.meta
with.environment
property:The goal here is to have easy access to the module graph.
I am personally not sold on the "environment" name - we already have
import.meta.env
for environment variables. And it doesn't reference the actual serverenvironment
which makes it a bit confusing. This is more of a "module context" - or maybe we don't even need a single property to hold this, and we can just put in onimport.meta
, but I am not sure how future-proof it is (module
seems like a generic name that might be available there in some EcmaScript proposal)