Skip to content

fix(vite-plugin-uni): 修复 Windows 下 UTS 模块解析路径#5992

Open
6iedog wants to merge 1 commit into
dcloudio:uni-app-vue3-devfrom
6iedog:fix/windows-node24-uts-fs-prefix
Open

fix(vite-plugin-uni): 修复 Windows 下 UTS 模块解析路径#5992
6iedog wants to merge 1 commit into
dcloudio:uni-app-vue3-devfrom
6iedog:fix/windows-node24-uts-fs-prefix

Conversation

@6iedog
Copy link
Copy Markdown

@6iedog 6iedog commented Apr 29, 2026

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.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
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.

1 participant