Reorganize repo structure and standards references

This commit is contained in:
david committed 2026-06-29 05:03:42 +02:00
1 parent 3cb93a81be
commit be2054274d
5885 files changed
+2588 -195

No files matched your search

@@ -0,0 +1,44 @@
import { describe, expect, it } from "vitest";
import { resolveAssetBase } from "./assetCdnBase";
describe("resolveAssetBase", () => {
it("returns '/' when ASSET_CDN_URL is unset", () => {
expect(resolveAssetBase({}, "production")).toBe("/");
});
it("returns '/' when ASSET_CDN_URL is empty or whitespace", () => {
expect(resolveAssetBase({ ASSET_CDN_URL: "" }, "production")).toBe("/");
expect(resolveAssetBase({ ASSET_CDN_URL: " " }, "production")).toBe("/");
});
it("returns '/' in development regardless of ASSET_CDN_URL (HMR / dev server)", () => {
expect(resolveAssetBase({ ASSET_CDN_URL: "https://cdn.example.com" }, "development")).toBe("/");
});
it("returns origin with trailing slash for a valid https URL", () => {
expect(resolveAssetBase({ ASSET_CDN_URL: "https://cdn.boiler.saas-ctrl.com" }, "production")).toBe(
"https://cdn.boiler.saas-ctrl.com/"
);
});
it("normalises trailing-slash variants to the same value", () => {
expect(resolveAssetBase({ ASSET_CDN_URL: "https://cdn.example.com/" }, "production")).toBe(
"https://cdn.example.com/"
);
});
it("strips paths from the CDN URL so vite controls the asset subdirectory", () => {
expect(resolveAssetBase({ ASSET_CDN_URL: "https://cdn.example.com/some/path" }, "production")).toBe(
"https://cdn.example.com/"
);
});
it("falls back to '/' for malformed URLs", () => {
expect(resolveAssetBase({ ASSET_CDN_URL: "not-a-url" }, "production")).toBe("/");
});
it("treats an absent mode as non-development", () => {
expect(resolveAssetBase({ ASSET_CDN_URL: "https://cdn.example.com" })).toBe("https://cdn.example.com/");
});
});
@@ -0,0 +1,32 @@
// Resolve the Vite `base` value from the ASSET_CDN_URL env variable.
//
// Kept in its own module (no React Router / Vite plugin imports) so the
// pure logic can be unit-tested under vitest without booting the full
// `apps/web/vite.config.ts` plugin graph.
//
// Behaviour:
// * Dev mode (`mode === "development"`): always returns `/` so the Vite
// dev server and HMR keep serving from the origin.
// * Production / build mode: when `ASSET_CDN_URL` is set to a valid URL,
// returns the origin with a trailing slash (e.g. `https://cdn.example.com/`).
// Vite then prefixes every emitted asset URL with that origin.
// * Empty / whitespace / malformed values fall back to `/` so a
// misconfigured deploy never breaks the build outright. The env-drift
// checks in CI are the right place to fail loudly on bad URLs.
//
// See: docs/improvement-plan/03-scaling-infrastructure/asset-cdn.md
// docs/ops/asset-cdn.md
export function resolveAssetBase(
env: Partial<Record<string, string | undefined>> = process.env,
mode: string | undefined = undefined
): string {
if (mode === "development") return "/";
const raw = env.ASSET_CDN_URL?.trim();
if (!raw) return "/";
try {
const url = new URL(raw);
return `${url.origin}/`;
} catch {
return "/";
}
}
@@ -0,0 +1,133 @@
import { describe, expect, it } from "vitest";
import { classifyBuildWarning, shouldSuppressBuildWarning } from "./buildWarningTriage";
describe("build warning triage", () => {
it("classifies large chunk warnings without suppressing them", () => {
const classification = classifyBuildWarning({
code: "PLUGIN_WARNING",
message: "Some chunks are larger than 1800 kB after minification. Consider code-splitting.",
});
expect(classification.class).toBe("large-chunk");
expect(classification.suppressed).toBe(false);
expect(shouldSuppressBuildWarning(classification)).toBe(false);
});
it("suppresses known empty chunk warnings that are covered by the bundle gate", () => {
const classification = classifyBuildWarning({
code: "EMPTY_BUNDLE",
message: 'Generated an empty chunk: "readyz".',
id: "apps/web/app/routes/readyz.tsx",
});
expect(classification.class).toBe("empty-chunk");
expect(classification.suppressed).toBe(true);
expect(shouldSuppressBuildWarning(classification)).toBe(true);
});
it("suppresses current React Router resource route empty chunks", () => {
const classification = classifyBuildWarning({
code: "EMPTY_BUNDLE",
message: 'Generated an empty chunk: "api.embed.forms._formKey.submit".',
});
expect(classification.class).toBe("empty-chunk");
expect(classification.suppressed).toBe(true);
expect(shouldSuppressBuildWarning(classification)).toBe(true);
});
it("keeps unknown empty chunk warnings visible", () => {
const classification = classifyBuildWarning({
code: "EMPTY_BUNDLE",
message: 'Generated an empty chunk: "new-empty-route".',
id: "apps/web/app/routes/new-empty-route.tsx",
});
expect(classification.class).toBe("empty-chunk");
expect(classification.suppressed).toBe(false);
expect(shouldSuppressBuildWarning(classification)).toBe(false);
});
it("classifies sourcemap resolve failures as suppressed", () => {
const classification = classifyBuildWarning({
code: "SOURCEMAP_ERROR",
message: "Can't resolve original location of error.",
id: "node_modules/example/index.js",
});
expect(classification.class).toBe("sourcemap-resolve-failure");
expect(classification.suppressed).toBe(true);
expect(shouldSuppressBuildWarning(classification)).toBe(true);
});
it("classifies production sourcemap warnings without suppressing them", () => {
const classification = classifyBuildWarning({
message: "Source maps are enabled in production",
});
expect(classification.class).toBe("production-sourcemap");
expect(classification.suppressed).toBe(false);
expect(shouldSuppressBuildWarning(classification)).toBe(false);
});
it("classifies AWS and Smithy circular chunk warnings without suppressing them", () => {
const classification = classifyBuildWarning({
message: [
'Export "Command" of module "../../node_modules/.pnpm/@smithy+core/node_modules/@smithy/core/dist-es/submodules/client/smithy-client/command.js"',
'was reexported through module "../../node_modules/.pnpm/@aws-sdk+nested-clients/node_modules/@aws-sdk/nested-clients/dist-es/index.js"',
"while both modules are dependencies of each other and will end up in different chunks by current Rollup settings.",
"This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.",
].join(" "),
});
expect(classification.class).toBe("aws-smithy-circular-chunk");
expect(classification.suppressed).toBe(false);
expect(shouldSuppressBuildWarning(classification)).toBe(false);
});
it("classifies dynamic/static import chunking warnings without suppressing them", () => {
const classification = classifyBuildWarning({
message:
"apps/web/app/utils/db.server.ts is dynamically imported by apps/web/app/routes/admin/marketing-leads/index.tsx but also statically imported by apps/web/app/modules/crm/services/CrmService.ts, dynamic import will not move module into another chunk.",
});
expect(classification.class).toBe("dynamic-static-import");
expect(classification.suppressed).toBe(false);
expect(shouldSuppressBuildWarning(classification)).toBe(false);
});
it("classifies next-themes invalid annotation warnings as suppressed", () => {
const classification = classifyBuildWarning({
code: "INVALID_ANNOTATION",
message: "Contains an annotation that Rollup cannot interpret.",
id: "/repo/node_modules/next-themes/dist/index.mjs",
});
expect(classification.class).toBe("next-themes-invalid-annotation");
expect(classification.suppressed).toBe(true);
expect(shouldSuppressBuildWarning(classification)).toBe(true);
});
it("keeps unknown warnings unsuppressed", () => {
const classification = classifyBuildWarning({
code: "CIRCULAR_DEPENDENCY",
message: "Circular dependency detected between route modules.",
file: "apps/web/app/routes/dashboard.tsx",
});
expect(classification.class).toBe("unknown");
expect(classification.suppressed).toBe(false);
expect(shouldSuppressBuildWarning(classification)).toBe(false);
});
it("handles casing drift for known warning codes and messages", () => {
const classification = classifyBuildWarning({
code: "sourcemap_error",
message: "can't resolve original location of error.",
});
expect(classification.class).toBe("sourcemap-resolve-failure");
expect(classification.suppressed).toBe(true);
});
});
@@ -0,0 +1,116 @@
export type BuildWarningInput = {
code?: string | null;
message?: string | null;
id?: string | null;
file?: string | null;
};
export type BuildWarningClass =
| "large-chunk"
| "empty-chunk"
| "production-sourcemap"
| "aws-smithy-circular-chunk"
| "dynamic-static-import"
| "sourcemap-resolve-failure"
| "next-themes-invalid-annotation"
| "unknown";
export type BuildWarningClassification = {
class: BuildWarningClass;
suppressed: boolean;
code?: string;
message: string;
id?: string;
file?: string;
};
const normalize = (value: string | null | undefined) => value?.toLowerCase() ?? "";
const EMPTY_CHUNK_ALLOWLIST = new Set([
"___entity.export",
"api.collab.token",
"api.embed.forms._formKey.submit",
"api.leads.capture",
"api.metrics",
"api.password-policy-remind",
"api.status",
"api.tenants._tenant.plugins",
"callback",
"dry-run",
"healthcheck",
"healthz",
"ip-address-log-labels",
"logout",
"null",
"onboarding._id",
"postman_collection_._json",
"preferences",
"readyz",
"start",
"stream",
"submit",
"swagger",
"track-click._deliveryId",
"track-open._deliveryId_.gif_",
"workflows._id.run.stream._executionId",
]);
function getEmptyChunkName(message: string): string | null {
const match = /generated an empty chunk:\s*["']?([^"'.]+(?:\.[^"'.]+)*)["']?/i.exec(message);
return match?.[1] ?? null;
}
export function classifyBuildWarning(warning: BuildWarningInput): BuildWarningClassification {
const code = warning.code ?? undefined;
const message = warning.message ?? "";
const id = warning.id ?? undefined;
const file = warning.file ?? undefined;
const normalizedCode = normalize(code);
const normalizedMessage = normalize(message);
const normalizedId = normalize(id);
let warningClass: BuildWarningClass = "unknown";
if (
normalizedMessage.includes("some chunks are larger than") ||
normalizedMessage.includes("chunk size limit") ||
normalizedMessage.includes("chunk size warning")
) {
warningClass = "large-chunk";
} else if (normalizedMessage.includes("generated an empty chunk") || normalizedMessage.includes("empty chunk")) {
warningClass = "empty-chunk";
} else if (normalizedMessage.includes("source maps are enabled in production")) {
warningClass = "production-sourcemap";
} else if (
normalizedMessage.includes("will end up in different chunks") &&
normalizedMessage.includes("circular dependency between chunks") &&
(normalizedMessage.includes("@aws-sdk") || normalizedMessage.includes("@smithy"))
) {
warningClass = "aws-smithy-circular-chunk";
} else if (
normalizedMessage.includes("is dynamically imported by") &&
normalizedMessage.includes("but also statically imported by") &&
normalizedMessage.includes("dynamic import will not move module into another chunk")
) {
warningClass = "dynamic-static-import";
} else if (normalizedCode === "sourcemap_error" && normalizedMessage.includes("can't resolve original location")) {
warningClass = "sourcemap-resolve-failure";
} else if (normalizedCode === "invalid_annotation" && normalizedId.includes("next-themes")) {
warningClass = "next-themes-invalid-annotation";
}
const emptyChunkName = warningClass === "empty-chunk" ? getEmptyChunkName(message) : null;
const suppressEmptyChunk = emptyChunkName !== null && EMPTY_CHUNK_ALLOWLIST.has(emptyChunkName);
return {
class: warningClass,
suppressed: suppressEmptyChunk || warningClass === "sourcemap-resolve-failure" || warningClass === "next-themes-invalid-annotation",
code,
message,
id,
file,
};
}
export function shouldSuppressBuildWarning(warning: BuildWarningInput): boolean {
return classifyBuildWarning(warning).suppressed;
}
@@ -0,0 +1,83 @@
import { describe, expect, it } from "vitest";
import { analyzeBundleScan, formatBundleScanSummary } from "./bundleScan";
describe("bundle scan", () => {
it("reports actionable over-budget vendor chunks", () => {
const result = analyzeBundleScan({
assets: [{ name: "assets/vendor-react.abcd.js", sizeKb: 620 }],
warnings: [
{
code: "PLUGIN_WARNING",
message: "Some chunks are larger than 500 kB after minification.",
},
],
});
expect(result.budgetViolations).toEqual([
{
name: "assets/vendor-react.abcd.js",
sizeKb: 620,
thresholdKb: 500,
budgetKind: "vendor",
},
]);
expect(result.warnings[0]?.class).toBe("large-chunk");
});
it("accepts chunks within explicit app, vendor and editor budgets", () => {
const result = analyzeBundleScan({
assets: [
{ name: "assets/routes-dashboard.js", sizeKb: 340 },
{ name: "assets/vendor-radix.js", sizeKb: 480 },
{ name: "assets/monaco-editor.js", sizeKb: 840 },
],
});
expect(result.budgetViolations).toEqual([]);
});
it("formats largest chunk summaries in deterministic size order", () => {
const result = analyzeBundleScan(
{
assets: [
{ name: "assets/workflow.js", sizeKb: 220 },
{ name: "assets/vendor-react.js", sizeKb: 500 },
{ name: "assets/editor-monaco.js", sizeKb: 500 },
{ name: "assets/settings.js", sizeKb: 120 },
],
},
{ largestChunkLimit: 3 },
);
expect(result.largestChunks.map((asset) => asset.name)).toEqual([
"assets/editor-monaco.js",
"assets/vendor-react.js",
"assets/workflow.js",
]);
expect(formatBundleScanSummary(result)).toContain("- assets/editor-monaco.js: 500 kB");
});
it("keeps unknown warnings visible instead of suppressing them", () => {
const result = analyzeBundleScan({
assets: [{ name: "assets/app.js", sizeKb: 100 }],
warnings: [
{
code: "SYNTHETIC_NEW_WARNING",
message: "Bundler emitted a warning this helper does not know yet.",
file: "apps/web/app/routes/dashboard.tsx",
},
],
});
expect(result.unknownWarnings).toHaveLength(1);
expect(result.unknownWarnings[0]).toMatchObject({
class: "unknown",
suppressed: false,
code: "SYNTHETIC_NEW_WARNING",
});
expect(formatBundleScanSummary(result)).toContain(
"- SYNTHETIC_NEW_WARNING: Bundler emitted a warning this helper does not know yet.",
);
});
});
@@ -0,0 +1,120 @@
import { type BuildWarningInput, classifyBuildWarning } from "./buildWarningTriage";
export type BundleAsset = {
name: string;
sizeKb: number;
};
export type BundleBudgetKind = "editor" | "vendor" | "app";
export type BundleBudget = {
kind: BundleBudgetKind;
thresholdKb: number;
};
export type BundleBudgetViolation = BundleAsset & {
thresholdKb: number;
budgetKind: BundleBudgetKind;
};
export type BundleScanOptions = {
budgets?: Partial<Record<BundleBudgetKind, number>>;
largestChunkLimit?: number;
};
export type BundleScanResult = {
assets: BundleAsset[];
largestChunks: BundleAsset[];
budgetViolations: BundleBudgetViolation[];
warnings: ReturnType<typeof classifyBuildWarning>[];
unknownWarnings: ReturnType<typeof classifyBuildWarning>[];
};
export const DEFAULT_BUNDLE_BUDGETS: Record<BundleBudgetKind, number> = {
app: 350,
vendor: 500,
editor: 850,
};
const EDITOR_ASSET_PATTERN = /(?:monaco|editor|codemirror)/i;
const VENDOR_ASSET_PATTERN = /(?:vendor|node_modules|react|radix|tiptap|recharts|xyflow)/i;
function getBudgetKind(assetName: string): BundleBudgetKind {
if (EDITOR_ASSET_PATTERN.test(assetName)) {
return "editor";
}
if (VENDOR_ASSET_PATTERN.test(assetName)) {
return "vendor";
}
return "app";
}
function sortLargestFirst(left: BundleAsset, right: BundleAsset) {
if (right.sizeKb !== left.sizeKb) {
return right.sizeKb - left.sizeKb;
}
return left.name.localeCompare(right.name);
}
export function analyzeBundleScan(
input: { assets: BundleAsset[]; warnings?: BuildWarningInput[] },
options: BundleScanOptions = {},
): BundleScanResult {
const budgets = { ...DEFAULT_BUNDLE_BUDGETS, ...options.budgets };
const assets = [...input.assets].sort((left, right) => left.name.localeCompare(right.name));
const warnings = (input.warnings ?? []).map((warning) => classifyBuildWarning(warning));
const largestChunkLimit = options.largestChunkLimit ?? 5;
const budgetViolations = assets
.map((asset) => {
const budgetKind = getBudgetKind(asset.name);
const thresholdKb = budgets[budgetKind];
return { ...asset, thresholdKb, budgetKind };
})
.filter((asset) => asset.sizeKb > asset.thresholdKb)
.sort((left, right) => {
if (right.sizeKb !== left.sizeKb) {
return right.sizeKb - left.sizeKb;
}
return left.name.localeCompare(right.name);
});
return {
assets,
largestChunks: [...assets].sort(sortLargestFirst).slice(0, largestChunkLimit),
budgetViolations,
warnings,
unknownWarnings: warnings.filter((warning) => warning.class === "unknown"),
};
}
export function formatBundleScanSummary(result: BundleScanResult): string {
const lines = [
`Bundle scan: ${result.assets.length} assets, ${result.budgetViolations.length} budget violations, ${result.unknownWarnings.length} unknown warnings.`,
"Largest chunks:",
...result.largestChunks.map((asset) => `- ${asset.name}: ${asset.sizeKb} kB`),
];
if (result.budgetViolations.length > 0) {
lines.push(
"Budget violations:",
...result.budgetViolations.map(
(asset) => `- ${asset.name}: ${asset.sizeKb} kB exceeds ${asset.thresholdKb} kB ${asset.budgetKind} budget`,
),
);
}
if (result.unknownWarnings.length > 0) {
lines.push(
"Unknown warnings:",
...result.unknownWarnings.map((warning) => `- ${warning.code ?? "NO_CODE"}: ${warning.message}`),
);
}
return lines.join("\n");
}
@@ -0,0 +1,49 @@
import { describe, expect, it } from "vitest";
import { getManualChunkName } from "./manualChunks";
describe("manual chunk boundaries", () => {
it.each([
["/repo/node_modules/react/index.js", "vendor-react"],
["/repo/node_modules/react-dom/client.js", "vendor-react"],
["/repo/node_modules/react-router/dist/development/index.mjs", "vendor-react"],
["/repo/node_modules/clsx/dist/clsx.mjs", "vendor-core-utils"],
["/repo/node_modules/tailwind-merge/dist/lib/index.mjs", "vendor-core-utils"],
["/repo/node_modules/class-variance-authority/dist/index.mjs", "vendor-core-utils"],
["/repo/node_modules/recharts/es6/index.js", "vendor-charts"],
["/repo/node_modules/d3-shape/src/index.js", "vendor-charts"],
["/repo/node_modules/@monaco-editor/react/dist/index.mjs", "vendor-monaco"],
["/repo/node_modules/monaco-editor/esm/vs/editor/editor.api.js", "vendor-monaco"],
["/repo/node_modules/marked/lib/marked.esm.js", "vendor-markdown"],
["/repo/node_modules/katex/dist/katex.mjs", "vendor-markdown"],
["/repo/node_modules/@tiptap/react/dist/index.js", "vendor-editor-tiptap"],
["/repo/node_modules/prosemirror-state/dist/index.js", "vendor-editor-prosemirror"],
["/repo/node_modules/@react-pdf/renderer/lib/react-pdf.browser.js", "vendor-pdf"],
["/repo/node_modules/@xyflow/react/dist/esm/index.js", "vendor-workflow"],
["/repo/node_modules/@aws-sdk/client-s3/dist-es/S3Client.js", "vendor-aws-sdk"],
["/repo/node_modules/@smithy/core/dist-es/submodules/client/index.js", "vendor-aws-sdk"],
["/repo/node_modules/@react-email/components/dist/index.mjs", "vendor-react-email"],
["/repo/node_modules/react-email/dist/index.js", "vendor-react-email"],
])("maps %s to %s", (id, chunkName) => {
expect(getManualChunkName(id)).toBe(chunkName);
});
it("supports Windows-like node_modules paths from Rollup ids", () => {
expect(getManualChunkName("C:\\repo\\node_modules\\monaco-editor\\esm\\vs\\editor\\editor.api.js")).toBe("vendor-monaco");
});
it.each([
"/repo/apps/web/app/components/monaco-editor/FakeEditor.tsx",
"/repo/apps/web/app/routes/workflows/workflow-builder.tsx",
"/repo/node_modules/streamdown/dist/index.js",
"/repo/node_modules/remark-gfm/index.js",
"/repo/node_modules/hast-util-to-jsx-runtime/index.js",
"/repo/node_modules/shiki/dist/index.mjs",
"/repo/node_modules/@shikijs/langs/dist/javascript.mjs",
"/repo/node_modules/mermaid/dist/mermaid.esm.mjs",
"/repo/node_modules/cytoscape/dist/cytoscape.esm.mjs",
"/repo/node_modules/@tiptap-adjacent/react/index.js",
])("leaves non-heavy or app module %s unchunked", (id) => {
expect(getManualChunkName(id)).toBeUndefined();
});
});
@@ -0,0 +1,46 @@
const NODE_MODULES_SEGMENT = "/node_modules/";
const CHUNK_MATCHERS: Array<{ chunkName: string; packages: string[] }> = [
{ chunkName: "vendor-react", packages: ["react", "react-dom", "react-router", "scheduler", "use-sync-external-store"] },
{ chunkName: "vendor-core-utils", packages: ["clsx", "tailwind-merge", "class-variance-authority"] },
{ chunkName: "vendor-charts", packages: ["recharts", "victory-vendor", "d3-", "d3"] },
{ chunkName: "vendor-markdown", packages: ["marked", "katex"] },
{ chunkName: "vendor-monaco", packages: ["@monaco-editor/react", "monaco-editor"] },
{ chunkName: "vendor-editor-tiptap", packages: ["@tiptap/"] },
{ chunkName: "vendor-editor-prosemirror", packages: ["prosemirror-"] },
{ chunkName: "vendor-pdf", packages: ["@react-pdf/renderer"] },
{ chunkName: "vendor-workflow", packages: ["@xyflow/react"] },
{ chunkName: "vendor-aws-sdk", packages: ["@aws-sdk/", "@smithy/"] },
// Lighthouse-CI (#70) — splits the React-Email render path off the
// critical render bundle so transactional-email pages don't bloat the
// marketing TTI score. Matches the budget declared in scripts/bundle-budgets.json.
{ chunkName: "vendor-react-email", packages: ["@react-email/", "react-email"] },
];
const normalizeModuleId = (id: string) => id.replace(/\\/g, "/");
const hasPackageBoundary = (moduleId: string, packageName: string) => {
const packageRoot = `node_modules/${packageName}`;
if (packageName.endsWith("/") || packageName.endsWith("-")) {
return moduleId.includes(packageRoot);
}
return moduleId.includes(`${packageRoot}/`) || moduleId.endsWith(packageRoot);
};
export function getManualChunkName(id: string): string | undefined {
const normalizedId = normalizeModuleId(id);
if (!normalizedId.includes(NODE_MODULES_SEGMENT)) {
return undefined;
}
for (const matcher of CHUNK_MATCHERS) {
if (matcher.packages.some((packageName) => hasPackageBoundary(normalizedId, packageName))) {
return matcher.chunkName;
}
}
return undefined;
}
@@ -0,0 +1,31 @@
import { readFile } from "node:fs/promises";
import { resolve } from "node:path";
import { describe, expect, it } from "vitest";
const readViteConfigSource = () => readFile(resolve(process.cwd(), "apps/web/vite.config.ts"), "utf8");
describe("vite config integration wiring", () => {
it("wires the manual chunk helper into Rollup output without running a build", async () => {
const source = await readViteConfigSource();
expect(source).toContain('import { getManualChunkName } from "./app/utils/build/manualChunks";');
expect(source).toMatch(/rollupOptions:\s*{[\s\S]*output:\s*{[\s\S]*manualChunks:\s*getManualChunkName/);
});
it("keeps build warning triage connected to Rollup onwarn", async () => {
const source = await readViteConfigSource();
expect(source).toContain('import { shouldSuppressBuildWarning } from "./app/utils/build/buildWarningTriage";');
expect(source).toMatch(/onwarn\(warning,\s*defaultHandler\)\s*{[\s\S]*shouldSuppressBuildWarning\(warning\)/);
expect(source).toMatch(/defaultHandler\(warning\)/);
});
it("keeps production source maps opt-in for Sentry release lanes", async () => {
const source = await readViteConfigSource();
expect(source).toContain('process.env.TOOLCTRL_BUILD_SOURCEMAPS === "1"');
expect(source).toContain("process.env.SENTRY_AUTH_TOKEN && buildSourcemapsEnabled");
expect(source).toMatch(/sourcemap:\s*buildSourcemapsEnabled/);
});
});