1
0

fix: 修复构建脚本跨平台 import specifier 路径规范化

- toImportSpecifier() 使用 replaceAll 替代 split(sep).join,明确 ESM import specifier 语义
- 增加 relativePath 可选参数支持测试注入 Windows relative 语义
- 重写 Windows 路径测试,使用 node:path.win32 显式模拟而非依赖当前平台 sep
- 更新 DEVELOPMENT.md 记录构建 code generation 约定
- 同步 static-asset-embedding 和 windows-test-compat spec 新增要求
This commit is contained in:
2026-05-21 09:32:43 +08:00
parent b432581444
commit 0d709c7681
5 changed files with 34 additions and 8 deletions

View File

@@ -56,3 +56,14 @@
#### Scenario: SVG 文件
- **WHEN** 请求路径以 `.svg` 结尾
- **THEN** Content-Type SHALL 为 `image/svg+xml`
### Requirement: 静态资源 import specifier SHALL 使用平台无关分隔符
构建时静态资源 code generation SHALL 将文件系统相对路径转换为 ESM import specifier并确保生成的 import 路径在 Windows、macOS、Linux 开发环境下都使用 `/` 作为分隔符。
#### Scenario: Windows 相对路径转换为 import specifier
- **WHEN** code generation 将 Windows 文件系统相对路径 `..\\dist\\web\\assets\\app.js` 转换为静态资源 import specifier
- **THEN** 生成的 import specifier SHALL 为 `../dist/web/assets/app.js`,且 MUST NOT 包含 `\\`
#### Scenario: POSIX 相对路径保持 import specifier 形式
- **WHEN** code generation 将 POSIX 文件系统相对路径 `../dist/web/assets/app.js` 转换为静态资源 import specifier
- **THEN** 生成的 import specifier SHALL 保持为 `../dist/web/assets/app.js`