From 5bee8351fc890e0027aac7634aa366e7d6494cc2 Mon Sep 17 00:00:00 2001 From: Yarden Zamir Date: Sun, 25 Oct 2026 14:21:48 +0200 Subject: [PATCH] fix(build): the bundle scan reads the module comments of vite-plus 1.4 --- scripts/lib/cli-external-packages.test.ts | 4 ++-- scripts/lib/cli-external-packages.ts | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/lib/cli-external-packages.test.ts b/scripts/lib/cli-external-packages.test.ts index 729975d70b1a2..a27bc93ce3d83 100644 --- a/scripts/lib/cli-external-packages.test.ts +++ b/scripts/lib/cli-external-packages.test.ts @@ -123,9 +123,9 @@ it.layer(NodeServices.layer)("external package dependency closure", (it) => { }); describe("findInlinedExternalPackages", () => { - const region = (path: string) => `//#region ${path} + const region = (path: string) => `// ${path} +// A prose comment with a path/like token is not a module. var x = 1; -//#endregion `; it("flags an external package that was inlined", () => { diff --git a/scripts/lib/cli-external-packages.ts b/scripts/lib/cli-external-packages.ts index b6088ee1df023..6978d5dd33d46 100644 --- a/scripts/lib/cli-external-packages.ts +++ b/scripts/lib/cli-external-packages.ts @@ -61,16 +61,19 @@ export function findInlinedExternalPackages(source: string): { readonly inlined: ReadonlyArray; readonly inlinedPackages: ReadonlyArray; } { - // Rolldown marks each inlined module with a `//#region ` comment. - const regionPattern = /\/\/#region\s+(\S+)/g; + // Rolldown's default `attachDebugInfo: "simple"` starts each inlined module with a `// ` line. const packagePattern = /node_modules\/((?:@[^/\s]+\/)?[^/\s]+)\//g; let regionCount = 0; const inlined = new Set(); const inlinedPackages = new Set(); - for (const region of source.matchAll(regionPattern)) { + for (const line of source.split("\n")) { + if (!line.startsWith("// ")) continue; + const regionPath = line.slice("// ".length).trimEnd(); + if (!regionPath.includes("/") || regionPath.includes(" ") || regionPath.includes("\t")) { + continue; + } regionCount += 1; - const regionPath = region[1] ?? ""; for (const candidate of regionPath.matchAll(packagePattern)) { const name = candidate[1]; if (name === undefined || name === ".pnpm") continue;