fix(gateway): avoid viewer asset watch loops · openclaw/openclaw@04880ab
steipete
·
2026-05-28
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -31,7 +31,7 @@ if (!target) {
|
31 | 31 | const outputPath = path.join(repoRoot, target.output); |
32 | 32 | await fs.mkdir(path.dirname(outputPath), { recursive: true }); |
33 | 33 | |
34 | | -await build({ |
| 34 | +const result = await build({ |
35 | 35 | entryPoints: [path.join(repoRoot, target.entry)], |
36 | 36 | bundle: true, |
37 | 37 | platform: "browser", |
@@ -40,7 +40,7 @@ await build({
|
40 | 40 | minify: true, |
41 | 41 | legalComments: "none", |
42 | 42 | outfile: outputPath, |
43 | | -write: true, |
| 43 | +write: false, |
44 | 44 | plugins: target.shikiAlias |
45 | 45 | ? [ |
46 | 46 | { |
@@ -55,5 +55,21 @@ await build({
|
55 | 55 | : [], |
56 | 56 | }); |
57 | 57 | |
58 | | -const runtime = await fs.readFile(outputPath, "utf8"); |
59 | | -await fs.writeFile(outputPath, runtime.replace(/[ \t]+$/gm, "")); |
| 58 | +const outputFile = result.outputFiles?.[0]; |
| 59 | +if (!outputFile) { |
| 60 | +throw new Error(`esbuild did not produce ${target.output}`); |
| 61 | +} |
| 62 | + |
| 63 | +const runtime = outputFile.text.replace(/[ \t]+$/gm, ""); |
| 64 | +let previousRuntime = null; |
| 65 | +try { |
| 66 | +previousRuntime = await fs.readFile(outputPath, "utf8"); |
| 67 | +} catch (error) { |
| 68 | +if (error?.code !== "ENOENT") { |
| 69 | +throw error; |
| 70 | +} |
| 71 | +} |
| 72 | + |
| 73 | +if (previousRuntime !== runtime) { |
| 74 | +await fs.writeFile(outputPath, runtime); |
| 75 | +} |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。