Repository navigation
feat(experimental): implement sync module runner with lazy evaluation - #12149
Draft
sheremet-va wants to merge 52 commits into
Draft
sheremet-va wants to merge 52 commits into
sheremet-va wants to merge 52 commits into
Conversation
✅ Deploy Preview for vitest-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Member
Author
Sync module linker that loads the static import graph in one request and evaluates modules without side effects on first access, with mock support, the link transform, and test call collection for preParse.
Global setup, the server runner, custom environments, web workers and vm pools run linked environments through ModuleLinker.
A static vi.mock in an imported module applies to the modules that run after it, and prepare() keeps the walk promise.
linkTransform hoists vi.mock calls itself, and mock factories run before the code of the module that reads them.
LinkRecords are shared per worker and Vite environment, each vm context keeps its own linker state. Also renames LinkedEnvironmentLoader to LinkedEnvironmentModuleRunner and restores GET_BUILTIN_MODULE from main in moduleEvaluator.ts.
ModuleLinker becomes ModuleLoader in runtime/moduleRunner/moduleLoader/ (loader, records, types, utils).
createNodeImportMeta uses pathToFileURL from node:url, so a lazy module that runs after vi.stubGlobal('URL', ...) still gets import.meta.
A module linked before vi.resetModules gets the instances of its own graph, import() after the reset gets new ones.
The server resolves literal `vi.requireActual` and `vi.requireMock` paths and adds the modules to the graph of the file, they run at the call. The errors of the sync APIs keep their message in a `vi.mock` factory.
…import, not on access to simplify tree shaking
`require()` of an ES module graph with top-level await throws before a module of the graph runs. The loader marks the external and requests the modules that wait for it again, so `import()` loads it at its import. The selection has the names that the code reads from a package without side effects. Their files run with the importer.
The export entries of es-module-lexer 3 have the source and the name of each re-export, so the files of a package without side effects are not parsed with oxc.
This was referenced Dec 1, 2026
One session class for the module graph of a loader, one environment check, and the options of the flag in the resolved config.
The response has the number of a module in place of its id in each import, no keys without a value, and the names of the code files. The worker keeps a record class with the resolved target of each import, so the loader does no lookup by a string for an import.
The module instance is a class that owns its namespace object, and the modules that Node loads have their own class. The loader keeps the load, the link check and the order of evaluation.
sheremet-va
force-pushed
the
feat/lazy-imports
branch
from
December 1, 2026 15:43
29eafa6 to
4e8041b
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

work in progress