-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat(experimental): allow disabling the module runner #9210
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
base: main
Are you sure you want to change the base?
feat(experimental): allow disabling the module runner #9210
Conversation
✅ Deploy Preview for vitest-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
hi-ogawa
left a comment
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.
Can you add some mock tests to show what working and not working? Also it's nice to have a failing test case (like relative ./basic import instead ./basic.js), which would pass if it were module runner.
I didn't implement mocking yet, there will be a separate project in examples when this is ready |
…xperimental_allow_disabling_the_module_runner
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.
Pull request overview
This PR introduces experimental support for disabling Vite's module runner and falling back to native Node.js import. This allows tests to run in their actual environment without Vite's transformation layer, which is beneficial for backend Node.js code that doesn't require transformations.
Key changes:
- Added
experimental.viteModuleRunner(default: true) andexperimental.nodeLoader(default: true) configuration options - Implemented native module runner using Node.js Loaders API (requires Node 22.15+)
- Refactored mocking system to support both Vite module runner and native imports
- Updated error messages to remove quotes around file paths for consistency
Reviewed changes
Copilot reviewed 99 out of 101 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
packages/vitest/src/utils/nativeModuleRunner.ts |
New native module runner implementation that uses native imports |
packages/vitest/src/runtime/workers/native.ts |
Node.js loader hooks implementation for transforms when module runner is disabled |
packages/vitest/src/runtime/moduleRunner/nativeModuleMocker.ts |
Native mocker implementation using Node.js module hooks |
packages/vitest/src/runtime/moduleRunner/bareModuleMocker.ts |
Base mocker class extracted from VitestMocker |
packages/mocker/src/node/parsers.ts |
New module export parser using es-module-lexer and cjs-module-lexer |
packages/mocker/src/node/hoistMocks.ts |
Extracted hoisting logic from plugin |
test/cli/test/no-module-runner.test.ts |
Comprehensive test suite for native module runner |
examples/native/ |
Complete example project demonstrating native module runner usage |
docs/config/experimental.md |
Documentation for new experimental features |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
…xperimental_allow_disabling_the_module_runner
Description
Resolves #7234
Resolves #9181
TODO
corehang even when this flag is not used 🤔Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Documentation
pnpm run docscommand.Changesets
feat:,fix:,perf:,docs:, orchore:.