fix(webui): keep syntax highlighting chunks acyclic

This commit is contained in:
chengyongru
2026-07-11 00:57:37 +08:00
committed by Xubin Ren
parent 1ee4349a08
commit 137fbf875e
3 changed files with 56 additions and 28 deletions
@@ -43,9 +43,11 @@ describe("DiffSyntaxHighlight with Prism", () => {
const highlighted = await screen.findByTestId("syntax-highlighted-diff-hunk");
await waitFor(
() => {
expect(highlighted.querySelectorAll('td:last-child span[style*="color"]')).not.toHaveLength(
0,
const tokens = highlighted.querySelectorAll<HTMLElement>(
'td:last-child span[style*="color"]',
);
expect(tokens).not.toHaveLength(0);
expect(new Set([...tokens].map((token) => token.style.color)).size).toBeGreaterThan(1);
},
{ timeout: 10_000 },
);
+21
View File
@@ -0,0 +1,21 @@
import { describe, expect, it } from "vitest";
import { webuiManualChunk } from "../../vite.config";
describe("webuiManualChunk", () => {
it("keeps Refractor's selector parser in the syntax highlighting chunk", () => {
expect(
webuiManualChunk("/repo/node_modules/hast-util-parse-selector/index.js"),
).toBe("syntax-highlight");
});
it("keeps markdown-only hast utilities in the markdown chunk", () => {
expect(
webuiManualChunk("/repo/node_modules/hast-util-to-jsx-runtime/lib/index.js"),
).toBe("markdown-vendor");
});
it("leaves language grammars as independently loaded chunks", () => {
expect(webuiManualChunk("/repo/node_modules/refractor/lang/python.js")).toBeUndefined();
});
});