Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Malte Ubl
2026-10-19 13:31:49 -07:00
co-authored by Claude Opus 5.5
parent 506b7994ba
commit 40ca92fa13
4 changed files with 11 additions and 4 deletions
@@ -178,5 +178,7 @@ export const g = import_g.g;
`,
"/pkg/dist/index.js",
);
expect(result).toEqual({ degrade: expect.stringContaining("bundled CommonJS modules") as string });
expect(result).toEqual({
degrade: expect.stringContaining("bundled CommonJS modules") as string,
});
});
@@ -258,7 +258,10 @@ function strictPrologue(stmts: readonly ts.Statement[]): boolean {
/** A cheap text probe: the helper's name, or its minified body's
* `(m={exports:{}}).exports,m` fragment. */
export function mayBundleChunks(source: string): boolean {
return source.includes("__commonJS") || /\{\s*exports\s*:\s*\{\s*\}\s*\}\s*\)\s*\.exports\s*,/.test(source);
return (
source.includes("__commonJS") ||
/\{\s*exports\s*:\s*\{\s*\}\s*\}\s*\)\s*\.exports\s*,/.test(source)
);
}
/** Splits a CommonJS bundle's __commonJS chunks into virtual modules (see
+2 -1
View File
@@ -465,7 +465,8 @@ function loadFrontend(
if (npmStaticFileDegrades().size > 0) {
const loadable = npmStaticLoadableFiles(load.program, load.moduleOrder);
for (const [file, { pkg, reason }] of npmStaticFileDegrades()) {
if (!reasons.has(pkg) && (loadable === null || loadable.has(file))) reasons.set(pkg, reason);
if (!reasons.has(pkg) && (loadable === null || loadable.has(file)))
reasons.set(pkg, reason);
}
}
for (const d of preflight) {
+2 -1
View File
@@ -6045,7 +6045,8 @@ export function npmStaticLoadableFiles(
let computed = false;
while (work.length > 0 && !computed) {
const sf = work.pop()!;
const packageJs = npmStaticPackageOfPath(sf.fileName) !== null && isJsSourceFileName(sf.fileName);
const packageJs =
npmStaticPackageOfPath(sf.fileName) !== null && isJsSourceFileName(sf.fileName);
const follow = (spec: string, kind: "import" | "require"): void => {
if (canonicalBuiltinModule(spec) !== null) return;
add(resolveImport7(program, sf, spec, kind) ?? npmStaticDepSf7(program, sf, spec, kind));