mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-31 07:23:06 +08:00
co-authored by
Claude Opus 5.5
parent
506b7994ba
commit
40ca92fa13
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user