Skip to content

Conversation

@hi-ogawa
Copy link
Contributor

@hi-ogawa hi-ogawa commented Aug 28, 2025

Description

Since Vite 7.1, module runner implements import.meta.resolve via custom node loader vitejs/vite#20260.

TODO

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 Aug 28, 2025

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 259741b
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/68b0031ebb6c1f0008336d85
😎 Deploy Preview https://deploy-preview-8493--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.

public moduleExecutionInfo: ModuleExecutionInfo

constructor(private options: VitestModuleRunnerOptions) {
constructor(private vitestOptions: VitestModuleRunnerOptions) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The base class ModuleRunner also has options property, which later accessed for this.options.createImportMeta
https://github.com/vitejs/vite/blob/84079a84ad94de4c1ef4f1bdb2ab448ff2c01196/packages/vite/src/module-runner/runner.ts#L342-L343. To avoid crashing the properly, I needed to rename this.

@hi-ogawa hi-ogawa force-pushed the fix-vite-7-import-meta-resolve branch from 3a8f6b0 to add181d Compare August 28, 2025 05:09
state,
evaluatedModules: state.evaluatedModules,
spyModule,
createImportMeta: createNodeImportMeta,
Copy link
Contributor Author

@hi-ogawa hi-ogawa Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made it explicitly passed via startVitestModuleRunner since otherwise createNodeImportMeta would break @vitest/web-worker on vm since module.register is not supported there. Such limitation might exist for other custom runner (e.g. cloudflare), so making this as opt-in is probably better.

@hi-ogawa hi-ogawa marked this pull request as ready for review August 28, 2025 07:30
@sheremet-va sheremet-va merged commit 549d321 into vitest-dev:main Aug 28, 2025
10 of 14 checks passed
@hi-ogawa hi-ogawa deleted the fix-vite-7-import-meta-resolve branch August 28, 2025 08:59
@vladfaust
Copy link

vladfaust commented Sep 16, 2025

Hi, I'm using "vitest": "^4.0.0-beta.11", and it says Error: [module runner] "import.meta.resolve" is not supported..

Edit: fixed with explicitly adding "vite": "^7.1.5" to package.json.

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.

import.meta.resolve is broken in vite-node, despite working in node

3 participants