fix: 修复桌面字体转换依赖启动崩溃
This commit is contained in:
@@ -12,7 +12,10 @@ await build({
|
||||
banner: {
|
||||
js: [
|
||||
'import { createRequire as __mdToPdfCreateRequire } from "node:module";',
|
||||
"const require = __mdToPdfCreateRequire(import.meta.url);"
|
||||
'import { dirname as __mdToPdfDirname } from "node:path";',
|
||||
'import { fileURLToPath as __mdToPdfFileURLToPath } from "node:url";',
|
||||
"const require = __mdToPdfCreateRequire(import.meta.url);",
|
||||
"const __dirname = __mdToPdfDirname(__mdToPdfFileURLToPath(import.meta.url));"
|
||||
].join("\n")
|
||||
}
|
||||
});
|
||||
|
||||
@@ -92,6 +92,23 @@ describe("桌面发行构建链", () => {
|
||||
expect(buildScript).toContain("dist/docx-media-filter.lua");
|
||||
});
|
||||
|
||||
it("为 ESM 主进程中的 CommonJS 字体转换依赖保留 __dirname", () => {
|
||||
const buildScript = readFileSync(
|
||||
`${desktopRoot}/scripts/build-main.mjs`,
|
||||
"utf8"
|
||||
);
|
||||
|
||||
expect(buildScript).toContain(
|
||||
'dirname as __mdToPdfDirname'
|
||||
);
|
||||
expect(buildScript).toContain(
|
||||
'fileURLToPath as __mdToPdfFileURLToPath'
|
||||
);
|
||||
expect(buildScript).toContain(
|
||||
"const __dirname = __mdToPdfDirname(__mdToPdfFileURLToPath(import.meta.url));"
|
||||
);
|
||||
});
|
||||
|
||||
it("在 Docker Web 构建前复制样例并保留到运行镜像", () => {
|
||||
const dockerfile = readFileSync(
|
||||
`${projectRoot}/deploy/Dockerfile`,
|
||||
|
||||
Reference in New Issue
Block a user