build: stabilize a2ui bundle inputs

This commit is contained in:
Peter Steinberger
2026-04-20 17:24:01 +01:00
parent 18021818ce
commit 6e58da9750
3 changed files with 19 additions and 49 deletions

View File

@@ -5,7 +5,6 @@ import {
getBundleHashInputPaths,
getBundleHashRepoInputPaths,
getLocalRolldownCliCandidates,
getResolvedBundleDependencyPackageJsonPaths,
isBundleHashInputPath,
} from "../../scripts/bundle-a2ui.mjs";
@@ -52,34 +51,24 @@ describe("scripts/bundle-a2ui.mjs", () => {
]);
});
it("keeps repo-root package churn out of bundle hash inputs", () => {
it("tracks repo dependency manifests through lockfile inputs", () => {
const repoRoot = path.resolve("repo-root");
const inputPaths = getBundleHashRepoInputPaths(repoRoot);
expect(inputPaths).toContain(path.join(repoRoot, "package.json"));
expect(inputPaths).toContain(path.join(repoRoot, "pnpm-lock.yaml"));
expect(inputPaths).toContain(path.join(repoRoot, "ui", "package.json"));
expect(inputPaths).not.toContain(path.join(repoRoot, "package.json"));
expect(inputPaths).not.toContain(path.join(repoRoot, "pnpm-lock.yaml"));
});
it("tracks only the resolved bundle dependency manifests from node_modules", () => {
it("keeps local node_modules state out of bundle hash inputs", () => {
const repoRoot = process.cwd();
const dependencyPaths = getResolvedBundleDependencyPackageJsonPaths(repoRoot);
const relativeDependencyPaths = dependencyPaths.map((dependencyPath) =>
path.relative(repoRoot, dependencyPath).replaceAll(path.sep, "/"),
);
const inputPaths = getBundleHashInputPaths(repoRoot);
expect(
relativeDependencyPaths.map((relativePath) => relativePath.replace(/^ui\//u, "")),
).toEqual([
path.posix.join("node_modules", "lit", "package.json"),
path.posix.join("node_modules", "@lit/context", "package.json"),
path.posix.join("node_modules", "@lit-labs/signals", "package.json"),
path.posix.join("node_modules", "signal-utils", "package.json"),
]);
expect(
relativeDependencyPaths.every((relativePath) => /^(ui\/)?node_modules\//u.test(relativePath)),
).toBe(true);
expect(getBundleHashInputPaths(repoRoot)).not.toContain(path.join(repoRoot, "package.json"));
expect(getBundleHashInputPaths(repoRoot)).not.toContain(path.join(repoRoot, "pnpm-lock.yaml"));
expect(inputPaths).toContain(path.join(repoRoot, "package.json"));
expect(inputPaths).toContain(path.join(repoRoot, "pnpm-lock.yaml"));
expect(inputPaths).not.toContain(path.join(repoRoot, "node_modules", "lit", "package.json"));
expect(inputPaths).not.toContain(
path.join(repoRoot, "ui", "node_modules", "lit", "package.json"),
);
});
});