feat: semantic sharding for unnamed modules (__helpers/__vendor/__polyfill)
This commit is contained in:
parent
e6e9c1ada1
commit
6c270a9470
1 changed files with 10 additions and 1 deletions
|
|
@ -51,13 +51,22 @@ export default async function code(progress: Progress, _code: string[]) {
|
|||
|
||||
const rawFiles = await scanDir(modulesPath, modulesPath);
|
||||
|
||||
function classifyUnmapped(relativePath: string): string {
|
||||
if (/^module_\d+\.js$/.test(relativePath)) return "__polyfill";
|
||||
const rest = relativePath.replace(/^\d+_/, "");
|
||||
if (rest.startsWith("_")) return "__helpers";
|
||||
return "__vendor";
|
||||
}
|
||||
|
||||
function resolveDest(relativePath: string): string {
|
||||
const id = extractModuleId(relativePath);
|
||||
if (id !== undefined) {
|
||||
const sourcePath = modulePaths.get(id);
|
||||
if (sourcePath) return sanitizePath(sourcePath);
|
||||
const bucket = Math.floor(id / 1000);
|
||||
return `__unmapped/${String(bucket).padStart(2, "0")}xxx/${relativePath}`;
|
||||
const bucketStr = `${String(bucket).padStart(2, "0")}xxx`;
|
||||
const cat = classifyUnmapped(relativePath);
|
||||
return `${cat}/${bucketStr}/${relativePath}`;
|
||||
}
|
||||
return `__unmapped/${relativePath}`;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue