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:
@@ -1,5 +1,5 @@
|
||||
import { readdir, rm, writeFile } from "node:fs/promises";
|
||||
import { join, relative, sep } from "node:path";
|
||||
import { join, relative } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import { validateVersion } from "./bump-version-logic";
|
||||
@@ -104,8 +104,12 @@ export async function scanDir(dir: string, prefix: string): Promise<string[]> {
|
||||
return paths;
|
||||
}
|
||||
|
||||
export function toImportSpecifier(fromDir: string, targetPath: string) {
|
||||
return relative(fromDir, targetPath).split(sep).join("/");
|
||||
export function toImportSpecifier(
|
||||
fromDir: string,
|
||||
targetPath: string,
|
||||
relativePath: (from: string, to: string) => string = relative,
|
||||
) {
|
||||
return relativePath(fromDir, targetPath).replaceAll("\\", "/");
|
||||
}
|
||||
|
||||
export async function viteBuild() {
|
||||
|
||||
Reference in New Issue
Block a user