Repository navigation
fix(vite-plugin-vue,vite-plugin-solid): resolve relative .tsrx imports from a module Vitest loads by URL - #1250
Merged
jonkwheeler merged 2 commits intoNov 12, 2026
Conversation
…l id Vitest asks for a test module by its root-relative URL, such as `/packages/vite-plugin-vue/tests/App.test.tsrx.tsx`. resolveId kept a virtual id as written whenever it looked absolute, so that URL became the module's id. `load` re-anchored it to find the file, but imports from the module resolved against a path that doesn't exist, and a relative `.tsrx` import ended up at the project root (ENOENT). resolveId now anchors a virtual id the way `load` already does. An id that is already the real file's path, and one that can't be found under the root, stay as they were. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…does The previous commit anchored a root-relative virtual id to the file under the root as written. Through a symlinked root (`/tmp` on macOS, say) that kept the symlink spelling, while an import of the same file resolves to its real path, so one file could get two module ids. Resolve the anchored path through Vite's resolver instead, which applies its own symlink rules, and run the id through `normalizePath` for `/` separators on Windows. An id that needs no anchoring stays as it was. Co-Authored-By: Claude Opus 5.5 <[email protected]>
jonkwheeler
marked this pull request as ready for review
October 29, 2026 13:08
jonkwheeler
added a commit
to jonkwheeler/tsrx
that referenced
this pull request
Nov 12, 2026
Main's tsrx-org#1091 added resolveTsconfigJsx (source, types and tests) where this branch adds getBuildPlatformConfigFiles, and tsrx-org#1250 added a normalizePath import from vite in the Solid and Vue plugins where this branch imports parseSync; both sides are kept in each file. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
jonkwheeler
added a commit
that referenced
this pull request
Nov 12, 2026
The Solid and Vue plugin tests keep main's #1250 module-id tests and this branch's HMR CSS test, with both sides' node:fs imports. Main's #1125 already keeps the binding of a default-exported Vue component (const App = ...; export default App), so main's transform and shared compile test are kept, this branch's equivalent export-specifier rewrite and its vue-default-function-export changeset are dropped, and its Vue regression test, which passes on main's output, is kept. pnpm-lock.yaml is main's plus the entries this branch's lockfile added, re-resolved with the storybook-examples vue and vue-jsx-vapor pins moved to main's 3.6.0-rc.14 and 3.2.29 (#1296), so the README and llms.txt no longer list a Vue peer mismatch. Starting from main's lockfile alone resolved vue-component-meta 3.3.14, which brings @volar/* 2.4.30 and gives the VS Code extension two volar-service-typescript copies. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Under Vitest, a
.tsrxtest file can import another.tsrxfile by a relative path (#1247). Before, with@tsrx/vite-plugin-vueor@tsrx/vite-plugin-solid,import { Parent } from './fixtures/parent.tsrx'in a.test.tsrxfile failed withENOENT: no such file or directory, open '<root>/fixtures/parent.tsrx'. The React and Preact plugins already worked.Vitest asks for the test module by its root-relative URL (
/packages/vite-plugin-vue/tests/App.test.tsrx.tsx).resolveIdkept a virtual.tsrx.tsxid as written whenever it looked absolute, so that URL became the module's id.loadre-anchored it to find the file, but imports from the module resolved against a path that doesn't exist, so a relative import ended up at the root.resolveIdnow anchors such an id to the file under the root, the wayloadalready finds it, and spells it the way Vite's resolver does: the anchored path goes throughthis.resolve, which applies Vite's symlink rules, and then throughnormalizePath. So a file reached through a symlinked root (/tmpon macOS) has the same module id whether it's reached by URL or by import. An id that needs no anchoring stays as it is. The change sits at the start ofresolveId; #1101 changes its end, and the two merge without conflicts.This turned out to be in the published plugins, not only the repo's test setup: any project that runs Vitest with these plugins hits it. So the PR changes plugin code and has a patch changeset.
Verification
relative-imports.test.tsrxin the Vue and Solid runtime projects import./fixtures/relative-imports/parent.tsrx, which imports./child.tsrx, and render it. Both failed with the ENOENT above and pass now.resolveId('/tests/App.test.tsrx.tsx')returns<root>/tests/App.test.tsrx.tsx, and an absolute virtual id is kept. Both failed before./tests/App.test.tsrx.tsxby URL gives the real path, the same id as importing./tests/App.test.tsrx. This failed before the second commit, which returned the symlink spelling.npx vitest run: 10015 passed, 0 failed.pnpm typecheckclean,pnpm changeset:checkpasses, Prettier clean on changed files.Related
Fixes #1247
Related: #1200, #1229 (their runtime fixture lives in the shared harness directory because of this), #1101
🤖 Generated with Claude Code
Note
Medium Risk
Changes core module resolution in published Vite plugins; behavior is narrow (virtual
.tsrx.tsxids under Vitest) but incorrect anchoring could break imports or duplicate module instances.Overview
Fixes Vitest failures when a
.test.tsrxfile uses a relative import to another.tsrxfile with@tsrx/vite-plugin-vueor@tsrx/vite-plugin-solid. Vitest loads the test by a root-relative URL (e.g./tests/App.test.tsrx.tsx);resolveIdused to keep that URL as the module id, so nested relative imports resolved from the project root and hitENOENT.resolveIdnow re-anchors virtual.tsrx.tsxids to the on-disk file, using the sametoRealPath/to_real_pathlogic asload,this.resolve, and Vite'snormalizePath, so one stable id is used whether the module is reached by URL or by a normal import (including through a symlinked project root).Both plugins get unit tests for root-relative and symlink id spelling, plus
.tsrxintegration tests that import a parent fixture which imports a child. A patch changeset covers both packages.Reviewed by Cursor Bugbot for commit 847266c. Bugbot is set up for automated code reviews on this repo. Configure here.