fix(vite-plugin-uni): 修复 Windows 下 UTS 模块解析路径#5992
Open
6iedog wants to merge 1 commit into
Open
Conversation
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
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
Fix Windows + Node.js v24 compatibility for app UTS module resolution in dev mode.
When app UTS modules are resolved to raw Windows absolute paths like
C:/..., Vite may eventually pass them into ESM import flow, which can trigger:ERR_UNSUPPORTED_ESM_URL_SCHEME
Only URLs with a scheme in: file, data, and node are supported...
Received protocol 'd:'
This patch makes the app UTS resolver return Vite-compatible /@fs/ module ids on Windows instead of bare absolute paths.
Changes
update packages/vite-plugin-uni/src/config/resolve.ts
prefix Windows app UTS resolved paths with FS_PREFIX
preserve existing non-Windows behavior
add packages/vite-plugin-uni/tests/resolve.spec.ts
cover Windows app UTS resolver output for ?uts-proxy
Why here
The failing path is in the dev resolver used by vite-plugin-uni, and this is the smallest upstream-compatible fix:
it keeps existing UTS resolution logic
it follows Vite’s existing /@fs/ convention for filesystem paths
it avoids relying on Node loader hooks or user-side workarounds
Verification
Passed:
pnpm exec jest --runInBand --runTestsByPath "packages/vite-plugin-uni/tests/resolve.spec.ts"
pnpm exec jest --runInBand packages/vite-plugin-uni/tests/static.spec.ts packages/vite-plugin-uni/tests/sourcemap.spec.ts
Context
This addresses a Windows + Node.js v24 issue where bare absolute filesystem paths are no longer accepted when they later reach ESM import handling.