import { rollup, type OutputAsset, type Plugin } from "rollup"; import uiPageSourceManifest from "../../src/ui-page-source-manifest"; import type { UiPageSourceManifest } from "../../src/ui-page-source-manifest"; /** * Integration tests for the ui-page-source-manifest rollup plugin. * * The plugin generates a `.ui-source-manifest.json` for each HTML entry * in the bundle, listing every source file that contributed to that page. * * Assumed project layout (mirrors BYOUI apps): * * /project/ ← rootDir * └── src/client/ ← clientDir * ├── index.html ← HTML entry (emitted as asset) * ├── admin/settings.html ← nested HTML entry * ├── app.tsx ← JS entry (emitted as chunk) * ├── components/Button.tsx ← source module bundled into chunk * └── data/status.ts ← may be dynamically imported * * Rollup output bundle (what the plugin inspects): * * { * "app.js": OutputChunk (isEntry: true, facadeModuleId: app.tsx) * "lazy-abc.js": OutputChunk (isEntry: false, dynamic import chunk) * "index.html": OutputAsset (', }, }); const m = getManifest(output, "index.ui-source-manifest.json"); expect(m.html).toBe("src/client/index.html"); expect(m.entry).toBe("src/client/app.tsx"); expect(m.files).toEqual([ "src/client/app.tsx", "src/client/components/Button.tsx", "src/client/index.html", ]); }); test("nested HTML file places manifest alongside", async () => { const output = await build({ entry: { settings: "/project/src/client/admin/settings.tsx" }, files: { "/project/src/client/admin/settings.tsx": 'export default "settings";', }, htmlAssets: { "admin/settings.html": '', }, }); const m = getManifest(output, "admin/settings.ui-source-manifest.json"); expect(m.html).toBe("src/client/admin/settings.html"); expect(m.files).toContain("src/client/admin/settings.html"); expect(m.files).toContain("src/client/admin/settings.tsx"); }); test("files list is sorted for consistency", async () => { const output = await build({ entry: { app: "/project/src/client/app.tsx" }, files: { "/project/src/client/app.tsx": ` import "./z-module"; import "./a-module"; export default "app"; `, "/project/src/client/z-module.tsx": 'export const z = "z";', "/project/src/client/a-module.tsx": 'export const a = "a";', }, htmlAssets: { "index.html": '', }, }); const m = getManifest(output, "index.ui-source-manifest.json"); const sorted = [...m.files].sort(); expect(m.files).toEqual(sorted); }); test("multiple entries with separate HTML files", async () => { const output = await build({ entry: { dashboard: "/project/src/client/dashboard.tsx", settings: "/project/src/client/settings.tsx", }, files: { "/project/src/client/dashboard.tsx": ` import { Widget } from "./components/Widget"; export default function Dashboard() { return Widget(); } `, "/project/src/client/settings.tsx": ` import { Form } from "./components/Form"; export default function Settings() { return Form(); } `, "/project/src/client/components/Widget.tsx": 'export function Widget() { return "widget"; }', "/project/src/client/components/Form.tsx": 'export function Form() { return "form"; }', }, htmlAssets: { "dashboard.html": '', "settings.html": '', }, }); const dash = getManifest(output, "dashboard.ui-source-manifest.json"); const sett = getManifest(output, "settings.ui-source-manifest.json"); expect(dash.entry).toBe("src/client/dashboard.tsx"); expect(dash.files).toContain("src/client/components/Widget.tsx"); expect(dash.files).not.toContain("src/client/components/Form.tsx"); expect(sett.entry).toBe("src/client/settings.tsx"); expect(sett.files).toContain("src/client/components/Form.tsx"); expect(sett.files).not.toContain("src/client/components/Widget.tsx"); }); test("deduplicates files when shared module is imported", async () => { const output = await build({ entry: { app: "/project/src/client/app.tsx" }, files: { "/project/src/client/app.tsx": ` import { util } from "./shared"; import { helper } from "./helper"; export default function App() { return util() + helper(); } `, "/project/src/client/shared.tsx": ` export function util() { return "shared"; } `, "/project/src/client/helper.tsx": ` import { util } from "./shared"; export function helper() { return util() + "!"; } `, }, htmlAssets: { "index.html": '', }, }); const m = getManifest(output, "index.ui-source-manifest.json"); // shared.tsx imported by both app.tsx and helper.tsx — should appear only once const sharedCount = m.files.filter( (f) => f === "src/client/shared.tsx", ).length; expect(sharedCount).toBe(1); }); test("entry file name differs from HTML file name", async () => { const output = await build({ entry: { "status-app": "/project/src/client/status-app.tsx" }, files: { "/project/src/client/status-app.tsx": 'export default "status";', }, htmlAssets: { "status.html": '', }, }); const m = getManifest(output, "status.ui-source-manifest.json"); expect(m.html).toBe("src/client/status.html"); expect(m.entry).toBe("src/client/status-app.tsx"); }); test("chained static imports (entry → A → B → C)", async () => { const output = await build({ entry: { app: "/project/src/client/app.tsx" }, files: { "/project/src/client/app.tsx": ` import { a } from "./moduleA"; export default a; `, "/project/src/client/moduleA.tsx": ` import { b } from "./moduleB"; export const a = b + "A"; `, "/project/src/client/moduleB.tsx": ` import { c } from "./moduleC"; export const b = c + "B"; `, "/project/src/client/moduleC.tsx": ` export const c = "C"; `, }, htmlAssets: { "index.html": '', }, }); const m = getManifest(output, "index.ui-source-manifest.json"); expect(m.files).toContain("src/client/moduleA.tsx"); expect(m.files).toContain("src/client/moduleB.tsx"); expect(m.files).toContain("src/client/moduleC.tsx"); }); }); describe("Filtering", () => { test("excludes node_modules by default", async () => { const output = await build({ entry: { app: "/project/src/client/app.tsx" }, files: { "/project/src/client/app.tsx": ` import { dep } from "/project/node_modules/some-lib/index.js"; export default dep; `, "/project/node_modules/some-lib/index.js": 'export const dep = "lib";', }, htmlAssets: { "index.html": '', }, }); const m = getManifest(output, "index.ui-source-manifest.json"); expect(m.files).not.toContain(expect.stringContaining("node_modules")); expect(m.files).toContain("src/client/app.tsx"); }); test("supports custom exclude patterns", async () => { const output = await build({ entry: { app: "/project/src/client/app.tsx" }, files: { "/project/src/client/app.tsx": ` import { gen } from "/project/src/generated/data.ts"; export default gen; `, "/project/src/generated/data.ts": 'export const gen = "data";', }, htmlAssets: { "index.html": '', }, excludePatterns: ["**/generated/**"], }); const m = getManifest(output, "index.ui-source-manifest.json"); expect(m.files).not.toContain(expect.stringContaining("generated")); expect(m.files).toContain("src/client/app.tsx"); }); test("empty exclude patterns allows all files", async () => { const output = await build({ entry: { app: "/project/src/client/app.tsx" }, files: { "/project/src/client/app.tsx": ` import { dep } from "/project/node_modules/some-lib/index.js"; export default dep; `, "/project/node_modules/some-lib/index.js": 'export const dep = "lib";', }, htmlAssets: { "index.html": '', }, excludePatterns: [], }); const m = getManifest(output, "index.ui-source-manifest.json"); // With empty excludes, node_modules files should be included expect(m.files).toContainEqual(expect.stringContaining("node_modules")); }); test("filters rollup internals ($insertStyle, ___)", async () => { const output = await build({ entry: { app: "/project/src/client/app.tsx" }, files: { "/project/src/client/app.tsx": ` import { style } from "/project/src/client/___$insertStyle"; import { internal } from "/project/src/client/___module"; export default style + internal; `, "/project/src/client/___$insertStyle.ts": 'export const style = "injected";', "/project/src/client/___module.ts": 'export const internal = "internal";', }, htmlAssets: { "index.html": '', }, }); const m = getManifest(output, "index.ui-source-manifest.json"); expect(m.files).toContain("src/client/app.tsx"); expect(m.files).not.toContainEqual( expect.stringContaining("$insertStyle"), ); expect(m.files).not.toContainEqual(expect.stringContaining("___module")); }); test("strips query suffixes from imported module ids", async () => { // Plugins like @rollup/plugin-commonjs append a query suffix // (e.g. "?commonjs-es-import") to a real file path id. The // manifest should record the clean path, not the raw id with // its query string attached. const output = await build({ entry: { app: "/project/src/client/app.tsx" }, files: { "/project/src/client/app.tsx": ` import { util } from "./utils-query"; export default util; `, // Deliberately not registered under its plain path in the // virtual fs — only reachable via the query-appending // plugin below, so we know the query-suffixed id is what // the manifest plugin actually observed. "/project/src/client/utils.tsx": 'export const util = "util";', }, htmlAssets: { "index.html": '', }, extraPlugins: [ { name: "append-query", resolveId(source, importer) { if (source === "./utils-query" && importer) { return "/project/src/client/utils.tsx?commonjs-es-import"; } return null; }, load(id) { if (id === "/project/src/client/utils.tsx?commonjs-es-import") { return 'export const util = "util";'; } return null; }, }, ], }); const m = getManifest(output, "index.ui-source-manifest.json"); expect(m.files).toContain("src/client/utils.tsx"); expect(m.files).not.toContainEqual( expect.stringContaining("commonjs-es-import"), ); }); test("strips query suffix from entry facadeModuleId", async () => { // If the entry point itself resolves with a query suffix, the // manifest's "entry" field must still be the clean path. const output = await build({ // Entry specifier deliberately doesn't match a plain path in // the virtual fs, so it's only resolvable via the // query-appending plugin below — proving the manifest plugin // observed the query-suffixed facadeModuleId. entry: { app: "/project/src/client/app-entry" }, files: { "/project/src/client/app.tsx": 'export default "app";', }, htmlAssets: { "index.html": '', }, extraPlugins: [ { name: "append-query-to-entry", resolveId(source) { if (source === "/project/src/client/app-entry") { return "/project/src/client/app.tsx?commonjs-es-import"; } return null; }, load(id) { if (id === "/project/src/client/app.tsx?commonjs-es-import") { return 'export default "app";'; } return null; }, }, ], }); const m = getManifest(output, "index.ui-source-manifest.json"); expect(m.entry).toBe("src/client/app.tsx"); }); test("filters virtual modules (starting with \\0)", async () => { // Virtual modules are an internal rollup concept — they never // appear in generated output, so there is nothing to assert // except that the plugin doesn't crash when they are present. const output = await build({ entry: { app: "/project/src/client/app.tsx" }, files: { "/project/src/client/app.tsx": 'export default "app";', }, htmlAssets: { "index.html": '', }, }); const m = getManifest(output, "index.ui-source-manifest.json"); expect(m.files.every((f) => !f.startsWith("\0"))).toBe(true); }); test("excludes modules outside the project root", async () => { const output = await build({ entry: { app: "/project/src/client/app.tsx" }, files: { "/project/src/client/app.tsx": ` import { btn } from "/uxasset/externals/@servicenow/now-button/index.jsdbx"; export default btn; `, "/uxasset/externals/@servicenow/now-button/index.jsdbx": 'export const btn = "button";', }, htmlAssets: { "index.html": '', }, }); const m = getManifest(output, "index.ui-source-manifest.json"); expect(m.files).toContain("src/client/app.tsx"); expect(m.files).not.toContainEqual(expect.stringContaining("uxasset")); expect(m.files).not.toContainEqual(expect.stringMatching(/^\.\./)); }); }); describe("Tree-shaken imports", () => { test("includes source files that are imported but tree-shaken", async () => { const output = await build({ entry: { app: "/project/src/client/app.tsx" }, files: { "/project/src/client/app.tsx": ` import { unused } from "./utils"; export default "app"; `, "/project/src/client/utils.tsx": ` export function unused() { return "never called"; } `, }, htmlAssets: { "index.html": '', }, }); const m = getManifest(output, "index.ui-source-manifest.json"); // utils.tsx is imported but tree-shaken — still a source dependency expect(m.files).toContain("src/client/utils.tsx"); }); test("includes pure function imports whose call result is discarded", async () => { const output = await build({ entry: { app: "/project/src/client/app.tsx" }, files: { "/project/src/client/app.tsx": ` import { formatLog } from "./log-formatter"; export default function App() { try { return "ok"; } catch(e) { formatLog("err", "Error"); } } `, "/project/src/client/log-formatter.tsx": ` export function formatLog(msg, level) { return \`[\${level}] \${msg}\`; } `, }, htmlAssets: { "index.html": '', }, }); const m = getManifest(output, "index.ui-source-manifest.json"); expect(m.files).toContain("src/client/log-formatter.tsx"); }); }); describe("Dynamic imports", () => { test("includes dynamically imported module sources", async () => { const output = await build({ entry: { app: "/project/src/client/app.tsx" }, files: { "/project/src/client/app.tsx": ` export default async function App() { const mod = await import("./lazy"); return mod.default; } `, "/project/src/client/lazy.tsx": ` export default "lazy loaded"; `, }, htmlAssets: { "index.html": '', }, }); const m = getManifest(output, "index.ui-source-manifest.json"); expect(m.files).toContain("src/client/lazy.tsx"); }); test("includes nested dynamic import sources", async () => { const output = await build({ entry: { app: "/project/src/client/app.tsx" }, files: { "/project/src/client/app.tsx": ` export default async function App() { const mod = await import("./level1"); return mod.default; } `, "/project/src/client/level1.tsx": ` export default async function Level1() { const mod = await import("./level2"); return mod.default; } `, "/project/src/client/level2.tsx": ` export default "deeply nested"; `, }, htmlAssets: { "index.html": '', }, }); const m = getManifest(output, "index.ui-source-manifest.json"); expect(m.files).toContain("src/client/level1.tsx"); expect(m.files).toContain("src/client/level2.tsx"); }); }); describe("Shared modules", () => { test("shared module appears in both entry manifests", async () => { const output = await build({ entry: { page1: "/project/src/client/page1.tsx", page2: "/project/src/client/page2.tsx", }, files: { "/project/src/client/page1.tsx": ` import { shared } from "./shared-utils"; export default shared + " page1"; `, "/project/src/client/page2.tsx": ` import { shared } from "./shared-utils"; export default shared + " page2"; `, "/project/src/client/shared-utils.tsx": ` export const shared = "shared"; `, }, htmlAssets: { "page1.html": '', "page2.html": '', }, }); const m1 = getManifest(output, "page1.ui-source-manifest.json"); const m2 = getManifest(output, "page2.ui-source-manifest.json"); // Both entries import shared-utils — it should appear in both manifests expect(m1.files).toContain("src/client/shared-utils.tsx"); expect(m2.files).toContain("src/client/shared-utils.tsx"); }); test("dynamic import of same module does not cross-contaminate manifests", async () => { // Two entries each dynamically import the same module. // Each manifest should include the shared module's sources, // but page1's unique module should NOT appear in page2's manifest. const output = await build({ entry: { page1: "/project/src/client/page1.tsx", page2: "/project/src/client/page2.tsx", }, files: { "/project/src/client/page1.tsx": ` import { unique1 } from "./unique1"; export default async function Page1() { const mod = await import("./shared-lazy"); return unique1 + mod.default; } `, "/project/src/client/page2.tsx": ` import { unique2 } from "./unique2"; export default async function Page2() { const mod = await import("./shared-lazy"); return unique2 + mod.default; } `, "/project/src/client/unique1.tsx": 'export const unique1 = "only-page1";', "/project/src/client/unique2.tsx": 'export const unique2 = "only-page2";', "/project/src/client/shared-lazy.tsx": 'export default "lazy-shared";', }, htmlAssets: { "page1.html": '', "page2.html": '', }, }); const m1 = getManifest(output, "page1.ui-source-manifest.json"); const m2 = getManifest(output, "page2.ui-source-manifest.json"); // shared-lazy appears in both manifests expect(m1.files).toContain("src/client/shared-lazy.tsx"); expect(m2.files).toContain("src/client/shared-lazy.tsx"); // unique modules don't cross over expect(m1.files).toContain("src/client/unique1.tsx"); expect(m1.files).not.toContain("src/client/unique2.tsx"); expect(m2.files).toContain("src/client/unique2.tsx"); expect(m2.files).not.toContain("src/client/unique1.tsx"); // Per-entry isolation means rollup never sees both entries at once, // so it cannot code-split static imports into shared chunks whose // content depends on which entries exist. Dynamic imports (like // shared-lazy) still produce separate chunk files on disk that both // entries reference, but their content is deterministic — it only // depends on the source of the imported module, not on other entries. const chunks = output.filter((o) => o.type === "chunk"); // No chunk should contain code from both entries' unique modules for (const chunk of chunks) { const hasPage1Code = chunk.code.includes("only-page1"); const hasPage2Code = chunk.code.includes("only-page2"); expect(hasPage1Code && hasPage2Code).toBe(false); } }); }); describe("CSS url() assets via module metadata", () => { /** * Creates a mock plugin that simulates the css-url + sass pipeline: * transforms SCSS into valid JS (like sass does) while attaching * css-url asset metadata (like css-url does). */ const mockCssUrlPlugin = ( assetsByModule: Record, ): Plugin => ({ name: "mock-css-url-sass", transform(code, id) { if (id.endsWith(".scss")) { const assets = assetsByModule[id]; return { // Transform SCSS to valid JS (like the real sass plugin would) code: "export default '';\n", meta: assets ? { "css-url": { assets } } : undefined, }; } return null; }, }); test("includes css-url asset paths from module meta", async () => { const output = await build({ entry: { app: "/project/src/client/app.tsx" }, files: { "/project/src/client/app.tsx": ` import "./styles.scss"; export default "app"; `, "/project/src/client/styles.scss": `.bg { background: url('./assets/bg.jpg'); }`, }, htmlAssets: { "index.html": '', }, extraPlugins: [ mockCssUrlPlugin({ "/project/src/client/styles.scss": [ "/project/src/client/assets/logo.png", "/project/src/client/assets/bg.jpg", ], }), ], }); const m = getManifest(output, "index.ui-source-manifest.json"); expect(m.files).toContain("src/client/assets/logo.png"); expect(m.files).toContain("src/client/assets/bg.jpg"); expect(m.files).toContain("src/client/styles.scss"); }); test("excludes css-url assets outside project root", async () => { const output = await build({ entry: { app: "/project/src/client/app.tsx" }, files: { "/project/src/client/app.tsx": ` import "./styles.scss"; export default "app"; `, "/project/src/client/styles.scss": `@font-face { src: url('./font.woff'); }`, }, htmlAssets: { "index.html": '', }, extraPlugins: [ mockCssUrlPlugin({ "/project/src/client/styles.scss": ["/outside/project/font.woff"], }), ], }); const m = getManifest(output, "index.ui-source-manifest.json"); expect(m.files).not.toContainEqual(expect.stringContaining("font.woff")); }); test("applies exclude patterns to css-url assets", async () => { const output = await build({ entry: { app: "/project/src/client/app.tsx" }, files: { "/project/src/client/app.tsx": ` import "./styles.scss"; export default "app"; `, "/project/src/client/styles.scss": `.icon { mask: url('./icon.svg'); }`, }, htmlAssets: { "index.html": '', }, extraPlugins: [ mockCssUrlPlugin({ "/project/src/client/styles.scss": [ "/project/node_modules/lib/icon.png", "/project/src/client/icon.svg", ], }), ], }); const m = getManifest(output, "index.ui-source-manifest.json"); // node_modules should be excluded by default expect(m.files).not.toContainEqual( expect.stringContaining("node_modules"), ); // Project-local asset should be included expect(m.files).toContain("src/client/icon.svg"); }); test("deduplicates css-url assets with module graph sources", async () => { const output = await build({ entry: { app: "/project/src/client/app.tsx" }, files: { "/project/src/client/app.tsx": ` import "./styles.scss"; export default "app"; `, "/project/src/client/styles.scss": `.bg { color: red; }`, }, htmlAssets: { "index.html": '', }, extraPlugins: [ mockCssUrlPlugin({ // Asset path same as the module itself — should deduplicate "/project/src/client/styles.scss": [ "/project/src/client/styles.scss", ], }), ], }); const m = getManifest(output, "index.ui-source-manifest.json"); const scssCount = m.files.filter( (f) => f === "src/client/styles.scss", ).length; expect(scssCount).toBe(1); }); }); describe("HTML matching", () => { test("multiple script entries in the same HTML", async () => { const output = await build({ entry: { app: "/project/src/client/app.tsx", vendor: "/project/src/client/vendor.tsx", }, files: { "/project/src/client/app.tsx": ` import { helper } from "./helper"; export default helper; `, "/project/src/client/helper.tsx": 'export function helper() { return "help"; }', "/project/src/client/vendor.tsx": "export const vendor = true;", }, htmlAssets: { "index.html": ` `, }, }); const m = getManifest(output, "index.ui-source-manifest.json"); // Both entries' sources should be merged into the single manifest expect(m.files).toContain("src/client/app.tsx"); expect(m.files).toContain("src/client/helper.tsx"); expect(m.files).toContain("src/client/vendor.tsx"); }); test("matches chunk to HTML via script src stem", async () => { const output = await build({ entry: { app: "/project/src/client/app.tsx" }, files: { "/project/src/client/app.tsx": 'export default "app";', }, htmlAssets: { // Script src uses .jsdbx extension while chunk is .js "index.html": '', }, }); const m = getManifest(output, "index.ui-source-manifest.json"); expect(m.files).toContain("src/client/app.tsx"); }); test("matches chunk when script src has query params", async () => { const output = await build({ entry: { app: "/project/src/client/app.tsx" }, files: { "/project/src/client/app.tsx": 'export default "app";', }, htmlAssets: { "index.html": '', }, }); const m = getManifest(output, "index.ui-source-manifest.json"); expect(m.files).toContain("src/client/app.tsx"); }); test("no manifest when no HTML files in bundle", async () => { const output = await build({ entry: { app: "/project/src/client/app.tsx" }, files: { "/project/src/client/app.tsx": 'export default "app";', }, // No HTML assets htmlAssets: {}, }); const manifests = getManifests(output); expect(manifests).toHaveLength(0); }); test("does not false-match substring chunk names", async () => { // "app" should not match "app-admin" const output = await build({ entry: { app: "/project/src/client/app.tsx", "app-admin": "/project/src/client/app-admin.tsx", }, files: { "/project/src/client/app.tsx": 'export default "main";', "/project/src/client/app-admin.tsx": 'export default "admin";', }, htmlAssets: { "index.html": '', "admin.html": '', }, }); const main = getManifest(output, "index.ui-source-manifest.json"); const admin = getManifest(output, "admin.ui-source-manifest.json"); expect(main.files).toContain("src/client/app.tsx"); expect(main.files).not.toContain("src/client/app-admin.tsx"); expect(admin.files).toContain("src/client/app-admin.tsx"); expect(admin.files).not.toContain("src/client/app.tsx"); }); }); describe("Manifest format", () => { test("produces valid JSON with html, entry, and files fields", async () => { const output = await build({ entry: { app: "/project/src/client/app.tsx" }, files: { "/project/src/client/app.tsx": 'export default "app";', }, htmlAssets: { "index.html": '', }, }); const m = getManifest(output, "index.ui-source-manifest.json"); expect(m).toHaveProperty("html"); expect(m).toHaveProperty("entry"); expect(m).toHaveProperty("files"); expect(typeof m.html).toBe("string"); expect(typeof m.entry).toBe("string"); expect(Array.isArray(m.files)).toBe(true); }); test("includes vendors field with empty array when no vendor chunks", async () => { const output = await build({ entry: { app: "/project/src/client/app.tsx" }, files: { "/project/src/client/app.tsx": 'export default "app";', }, htmlAssets: { "index.html": '', }, }); const m = getManifest(output, "index.ui-source-manifest.json"); expect(m.vendors).toEqual([]); }); test("includes vendor chunks in vendors field", async () => { // Simulate extractLargeModules by using manualChunks to create // a chunk whose name starts with "vendor-", then a generateBundle // hook that renames it to the final content-hash format that the // real extractLargeModules produces. const vendorPlugin: Plugin = { name: "fake-vendor", outputOptions(options) { return { ...options, manualChunks(id) { if (id.includes("big-lib")) return "vendor-big-lib--placeholder"; return undefined; }, }; }, generateBundle(_, bundle) { // Rename to the deterministic format extractLargeModules // produces: vendor---.ext for (const [fileName, chunk] of Object.entries(bundle)) { if (chunk.type !== "chunk") continue; if (!chunk.name?.startsWith("vendor-")) continue; const ext = fileName.slice(fileName.indexOf(".")); const newFileName = `vendor-big-lib--d217b640${ext}`; chunk.fileName = newFileName; bundle[newFileName] = chunk; delete bundle[fileName]; } }, }; const output = await build({ entry: { app: "/project/src/client/app.tsx" }, files: { "/project/src/client/app.tsx": 'import x from "./big-lib"; export default x;', "/project/src/client/big-lib.tsx": 'export default "big";', }, htmlAssets: { "index.html": '', }, // Place vendor plugin BEFORE source-manifest so its // generateBundle runs first (matching real plugin ordering). extraPlugins: [vendorPlugin], }); const m = getManifest(output, "index.ui-source-manifest.json"); expect(m.vendors).toHaveLength(1); expect(m.vendors[0][0]).toBe("vendor-big-lib--d217b640.js"); expect(m.vendors[0][1]).toBe("d217b640"); }); test("uses 2-space indentation", async () => { const output = await build({ entry: { app: "/project/src/client/app.tsx" }, files: { "/project/src/client/app.tsx": 'export default "app";', }, htmlAssets: { "index.html": '', }, }); const asset = output.find( (o) => o.type === "asset" && o.fileName === "index.ui-source-manifest.json", ) as OutputAsset; const raw = asset.source as string; // Re-parse with 2-space indent and compare const reparsed = JSON.stringify(JSON.parse(raw), null, 2); expect(raw).toBe(reparsed); }); }); });