- Delete src/features/reference-feature/presentation/reference-feature-runtime.tsx: it only re-exported the same-named .ts and nothing imported it by the .tsx path. - Move promotion-readiness.ts and performance-budgets.ts from src/application/policies to scripts/lib: only scripts and their unit tests import them. Imports updated in 5 scripts and 2 tests. config/testing/risk-coverage.json lists only src modules, so their two criticalModules/highRiskPaths entries are removed; the synthetic 14-file summary fixture now names two other existing src modules. - installed-feature-messages.ts composes one catalog per locale the installed features declare (composeInstalledMessageCatalogs) instead of a fixed ko-KR/en-US list that silently dropped other catalogs. The exported type still maps each declared locale to its exact key set. Verified: tests/unit/installed-feature-messages.test.ts (ko-KR/en-US content pinned first; derived-locale and duplicate-key cases RED before); app typecheck also passes with a zero-feature generated index; all gates PASS; check:ci PASS; check-bundle resolves the moved module (stops later on the absent artifacts/performance/bundle.json). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
110 lines
3.0 KiB
TypeScript
110 lines
3.0 KiB
TypeScript
import { readFile } from "node:fs/promises";
|
|
|
|
import { evaluateBundleBudget } from "./lib/performance-budgets.ts";
|
|
import {
|
|
bundleOutputInventoryArtifactSchema,
|
|
bundlePerformanceArtifactSchema,
|
|
} from "./contracts/release-artifacts.ts";
|
|
import { classifyViteJavascript } from "./lib/classify-vite-bundle.ts";
|
|
import { writeValidatedJsonArtifact } from "./lib/validated-json-artifact.ts";
|
|
|
|
type ViteManifest = Record<
|
|
string,
|
|
{ file: string; isEntry?: boolean; imports?: string[] }
|
|
>;
|
|
type BundleBudgets = {
|
|
initialJsGzipBytes: number;
|
|
lazyChunkGzipBytes: number;
|
|
};
|
|
|
|
const report = bundleOutputInventoryArtifactSchema.parse(
|
|
JSON.parse(await readFile("artifacts/performance/bundle.json", "utf8")) as unknown,
|
|
);
|
|
const viteManifest = JSON.parse(
|
|
await readFile("dist/.vite/manifest.json", "utf8"),
|
|
) as ViteManifest;
|
|
const budgets = JSON.parse(
|
|
await readFile("config/performance/budgets.json", "utf8"),
|
|
).bundle as BundleBudgets;
|
|
|
|
const outputByPath = new Map(
|
|
report.outputs.map((output) => [output.path.replace(/^dist\//, ""), output]),
|
|
);
|
|
const classification = classifyViteJavascript(viteManifest);
|
|
const initialJsGzipBytes = classification.initialFiles.reduce(
|
|
(total, file) => total + (outputByPath.get(file)?.gzipBytes ?? 0),
|
|
0,
|
|
);
|
|
const lazyChunks = classification.lazyFiles.map((file) => ({
|
|
path: file,
|
|
gzipBytes: outputByPath.get(file)?.gzipBytes ?? 0,
|
|
}));
|
|
const missingOutputs = [
|
|
...classification.initialFiles,
|
|
...classification.lazyFiles,
|
|
].filter((file) => !outputByPath.has(file));
|
|
const measurements = { initialJsGzipBytes, lazyChunks };
|
|
const result = evaluateBundleBudget(measurements, budgets);
|
|
const fixtures = [
|
|
{
|
|
name: "initial-js-over-budget",
|
|
passed:
|
|
!evaluateBundleBudget(
|
|
{
|
|
initialJsGzipBytes: budgets.initialJsGzipBytes + 1,
|
|
lazyChunks: [],
|
|
},
|
|
budgets,
|
|
).passed,
|
|
},
|
|
{
|
|
name: "lazy-chunk-over-budget",
|
|
passed:
|
|
!evaluateBundleBudget(
|
|
{
|
|
initialJsGzipBytes: 0,
|
|
lazyChunks: [
|
|
{
|
|
path: "fixture.js",
|
|
gzipBytes: budgets.lazyChunkGzipBytes + 1,
|
|
},
|
|
],
|
|
},
|
|
budgets,
|
|
).passed,
|
|
},
|
|
];
|
|
const passed =
|
|
result.passed &&
|
|
fixtures.every((fixture) => fixture.passed) &&
|
|
classification.missingImports.length === 0 &&
|
|
missingOutputs.length === 0;
|
|
const completedReport = {
|
|
...report,
|
|
measurements,
|
|
classification,
|
|
missingOutputs,
|
|
thresholds: budgets,
|
|
results: result,
|
|
fixtures,
|
|
passed,
|
|
};
|
|
|
|
await writeValidatedJsonArtifact({
|
|
path: "artifacts/performance/bundle.json",
|
|
schema: bundlePerformanceArtifactSchema,
|
|
value: completedReport,
|
|
});
|
|
if (!passed) {
|
|
process.stderr.write(
|
|
`Bundle budget or manifest integrity failed: ${[
|
|
...classification.missingImports,
|
|
...missingOutputs,
|
|
].join(", ")}\n`,
|
|
);
|
|
process.exit(1);
|
|
}
|
|
process.stdout.write(
|
|
`Bundle budget: PASS (initial JS ${initialJsGzipBytes} / ${budgets.initialJsGzipBytes} gzip bytes)\n`,
|
|
);
|