문제 c15345c의 플러그인은 apply: "serve"라 Vitest가 Vite를 띄울 때도 돌아, test:unit마다 자식 프로세스로 manifest를 쓴다. 출력 위치 src/.generated/dev-release-manifest.json에는 자리표시자의 routeChunks(샘플 경로)가 들어 있다. test:sample-removal의 잔여 검사는 src/를 훑으므로 FE-GATE-020이 "fixture-id-residue: src/.generated/dev-release-manifest.json"으로 실패한다. 고른 방법 - 출력을 빌드의 contract set 생성물 옆 .generated/frontend-runtime/로 옮긴다 (무시 대상). - apply가 serve이면서 VITEST가 없을 때만 돈다. 테스트는 서버에서 manifest를 받지 않는다. 검증 - browser-files capability spec(dev server) chromium 3건 통과, 생성물이 새 위치에 생긴다. - test:unit 2,880건 통과, 실행 뒤 src/.generated에 manifest가 없다. Refs: docs/reviews/2026-11-03-maturity-review/README.md 14.6 X2 #3
49 lines
2.1 KiB
TypeScript
49 lines
2.1 KiB
TypeScript
import { execFileSync } from "node:child_process";
|
|
import { readFileSync } from "node:fs";
|
|
import path from "node:path";
|
|
|
|
import type { Plugin } from "vite";
|
|
|
|
/**
|
|
* Generated at dev server start, beside the build's generated contract set and
|
|
* ignored with it. Not under src/: the removal drills scan src/ for the
|
|
* sample's names, and this copies the placeholder's route chunks.
|
|
*/
|
|
export const DEV_RELEASE_MANIFEST_PATH = ".generated/frontend-runtime/dev-release-manifest.json";
|
|
|
|
/**
|
|
* Serve only. The dev server answers the runtime's release-manifest request
|
|
* with scripts/write-dev-release-manifest.ts's output instead of the committed
|
|
* placeholder, so a feature that `create:feature` just added boots in
|
|
* `corepack pnpm dev` and in the dev-server browser tests. The manifest is
|
|
* written in a child process because it imports the installed feature
|
|
* declarations, which this config must not load. A build never uses it: the
|
|
* built manifest comes from scripts/generate-build-manifest.ts.
|
|
*/
|
|
export function devReleaseManifestPlugin(repositoryRoot = process.cwd()): Plugin {
|
|
return {
|
|
name: "frontend-dev-release-manifest",
|
|
// Vitest also starts Vite in serve mode; tests never fetch the manifest
|
|
// from a server, so they skip the child process.
|
|
apply: (_config, env) => env.command === "serve" && !process.env["VITEST"],
|
|
configureServer(server) {
|
|
execFileSync(
|
|
process.execPath,
|
|
[path.join(repositoryRoot, "scripts/write-dev-release-manifest.ts")],
|
|
{ cwd: repositoryRoot, stdio: "inherit" },
|
|
);
|
|
const manifest = path.join(repositoryRoot, DEV_RELEASE_MANIFEST_PATH);
|
|
server.middlewares.use((request, response, next) => {
|
|
const pathname = new URL(request.url ?? "/", "http://dev.invalid").pathname;
|
|
if (request.method !== "GET" || !pathname.endsWith("/release-manifest.json")) {
|
|
next();
|
|
return;
|
|
}
|
|
response.setHeader("content-type", "application/json");
|
|
response.setHeader("cache-control", "no-store");
|
|
response.end(readFileSync(manifest));
|
|
});
|
|
},
|
|
};
|
|
}
|