Skip to content

Conversation

@sheremet-va
Copy link
Member

@sheremet-va sheremet-va commented Dec 8, 2025

Description

Resolves #7234
Resolves #9181

TODO

  • Fix issues on Windows
  • Seems like tests in core hang even when this flag is not used 🤔

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.
  • Please check Allow edits by maintainers to make review process faster. Note that this option is not available for repositories that are owned by Github organizations.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

@netlify
Copy link

netlify bot commented Dec 8, 2025

Deploy Preview for vitest-dev ready!

Name Link
🔨 Latest commit f7def15
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/6942bbb7181ef900088a3d6d
😎 Deploy Preview https://deploy-preview-9210--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

@hi-ogawa hi-ogawa left a 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.

@sheremet-va
Copy link
Member Author

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

Copy link

Copilot AI left a 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) and experimental.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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow running Vitest without any transforms

2 participants