Skip to content

fix(build): improve root URL import error#22498

Draft
Caltsic wants to merge 1 commit into
vitejs:mainfrom
Caltsic:fix/root-asset-url-error
Draft

fix(build): improve root URL import error#22498
Caltsic wants to merge 1 commit into
vitejs:mainfrom
Caltsic:fix/root-asset-url-error

Conversation

@Caltsic
Copy link
Copy Markdown
Contributor

@Caltsic Caltsic commented May 22, 2026

Fixes #10871.

Summary

  • Add a targeted hint when build fails on a root URL import (/).
  • Cover the case with a focused build unit test.

Details

Vue template asset references such as <img src=/> are transformed into an import of /. The resolver now reports this as an unresolved import with a code frame, but the message does not explain the asset reference problem. This keeps resolution behavior unchanged and augments the build error only for root URL imports.

Tests

  • pnpm vitest run packages/vite/src/node/__tests__/build.spec.ts
  • pnpm exec oxfmt --check packages/vite/src/node/build.ts packages/vite/src/node/__tests__/build.spec.ts
  • pnpm exec eslint --cache --max-warnings 0 packages/vite/src/node/build.ts packages/vite/src/node/__tests__/build.spec.ts
  • pnpm --filter vite typecheck
  • pnpm --filter vite build-bundle

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

Labels

None yet

Projects

None yet

1 participant