Skip to content

fix: resolve relative imports for optimized source files (fix #23430) - #23432

Open
DaZuiZui wants to merge 1 commit into
vitejs:mainfrom
DaZuiZui:codex/fix-optimizedeps-relative-source
Open

fix: resolve relative imports for optimized source files (fix #23430)#23432
DaZuiZui wants to merge 1 commit into
vitejs:mainfrom
DaZuiZui:codex/fix-optimizedeps-relative-source

Conversation

@DaZuiZui

@DaZuiZui DaZuiZui commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • resolve relative imports to source files listed in optimizeDeps.include to their optimized dep entry
  • match optimized metadata by the final resolved source path, including extensionless relative imports
  • preserve special query handling for ?raw, workers, and URLs
  • add a regression test covering a project source file imported relatively

Cause

optimizeDeps.include already resolved and pre-bundled the source file, but the dev optimizer resolver only checked optimized metadata for bare specifiers. Relative imports went through the normal filesystem path and continued to serve source modules, leaving the generated pre-bundle unused.

Fixes #23430

Tests

  • pnpm --filter vite build-bundle
  • pnpm test-serve playground/optimize-deps/__tests__/optimize-deps.spec.ts
  • pnpm test-build playground/optimize-deps/__tests__/optimize-deps.spec.ts
  • pnpm --filter vite typecheck
  • pnpm exec eslint packages/vite/src/node/plugins/resolve.ts playground/optimize-deps/__tests__/optimize-deps.spec.ts

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.

optimizeDeps.include accepts a project source file and pre-bundles it, but nothing ever resolves to it

1 participant