veryfront 0.1.781 → 0.1.782
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/esm/deno.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-executor.d.ts","sourceRoot":"","sources":["../../../src/src/release-assets/build-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;
|
|
1
|
+
{"version":3,"file":"build-executor.d.ts","sourceRoot":"","sources":["../../../src/src/release-assets/build-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAiCH,MAAM,WAAW,sBAAsB;IACrC,yDAAyD;IACzD,gBAAgB,EAAE,MAAM,CAAC;IACzB,oBAAoB;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,oBAAoB;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACjC,cAAc,EAAE,MAAM,CAAC;IACvB,yDAAyD;IACzD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oCAAoC;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gDAAgD;IAChD,MAAM,EAAE,uBAAuB,CAAC;IAChC,sDAAsD;IAEtD,OAAO,EAAE,GAAG,CAAC;IACb;;;;OAIG;IACH,SAAS,CAAC,EAAE,qBAAqB,CAAC;CACnC;AAED,MAAM,MAAM,qBAAqB,GAAG,CAClC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAElB,OAAO,EAAE,GAAG,EACZ,OAAO,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,OAAO,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,KAC9E,OAAO,CAAC,MAAM,CAAC,CAAC;AAErB,oEAAoE;AACpE,MAAM,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ACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAkCD,2DAA2D;AAC3D,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM/D;AA8TD;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,sBAAsB,EAC7B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,uBAAuB,CAAC,CA2ClC"}
|
|
@@ -23,7 +23,7 @@ import { transformToESM } from "../transforms/esm-transform.js";
|
|
|
23
23
|
import { PLATFORM_UTILITIES } from "../html/utils.js";
|
|
24
24
|
import { extractCandidatesFromFiles } from "../html/styles-builder/candidate-extractor.js";
|
|
25
25
|
import { sha256HexBytes } from "./hash.js";
|
|
26
|
-
import { RELEASE_ASSET_BASE_PATH, RELEASE_ASSET_CONTENT_TYPES, RELEASE_ASSET_MANIFEST_SCHEMA_VERSION, RELEASE_ASSET_MAX_SIZE_BYTES, RELEASE_ASSET_UPLOAD_CONCURRENCY, } from "./constants.js";
|
|
26
|
+
import { RELEASE_ASSET_BASE_PATH, RELEASE_ASSET_CONTENT_TYPES, RELEASE_ASSET_MANIFEST_SCHEMA_VERSION, RELEASE_ASSET_MAX_SIZE_BYTES, RELEASE_ASSET_UPLOAD_CONCURRENCY, releaseAssetUrl, } from "./constants.js";
|
|
27
27
|
const logger = serverLogger.component("release-asset-build");
|
|
28
28
|
/** Browser module source extensions eligible for transform. */
|
|
29
29
|
const BROWSER_MODULE_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js", ".mdx"];
|
|
@@ -121,6 +121,98 @@ function resolveStaticImports(source, moduleLogicalPath, knownPaths) {
|
|
|
121
121
|
}
|
|
122
122
|
return results;
|
|
123
123
|
}
|
|
124
|
+
function resolveKnownModulePath(path, knownPaths) {
|
|
125
|
+
const normalized = path
|
|
126
|
+
.replace(/^\/?_vf_modules\//, "")
|
|
127
|
+
.replace(/^\/+/, "")
|
|
128
|
+
.replace(/[?#].*$/, "");
|
|
129
|
+
if (normalized.startsWith("_veryfront/"))
|
|
130
|
+
return null;
|
|
131
|
+
if (knownPaths.has(normalized))
|
|
132
|
+
return normalized;
|
|
133
|
+
const withoutExt = normalized.replace(/\.(tsx|ts|jsx|mdx|js)$/, "");
|
|
134
|
+
for (const ext of BROWSER_MODULE_EXTENSIONS) {
|
|
135
|
+
const candidate = `${withoutExt}${ext}`;
|
|
136
|
+
if (knownPaths.has(candidate))
|
|
137
|
+
return candidate;
|
|
138
|
+
}
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
function collectVfModuleImports(code, knownPaths) {
|
|
142
|
+
const imports = new Map();
|
|
143
|
+
const re = /(["'])(\/_vf_modules\/[^"']+)\1/g;
|
|
144
|
+
let match;
|
|
145
|
+
while ((match = re.exec(code)) !== null) {
|
|
146
|
+
const specifier = match[2];
|
|
147
|
+
const logicalPath = resolveKnownModulePath(specifier, knownPaths);
|
|
148
|
+
if (logicalPath)
|
|
149
|
+
imports.set(specifier, logicalPath);
|
|
150
|
+
}
|
|
151
|
+
return imports;
|
|
152
|
+
}
|
|
153
|
+
function rewriteVfModuleImports(code, moduleAssets, knownPaths, dependencyUrls) {
|
|
154
|
+
return code.replace(/(["'])(\/_vf_modules\/[^"']+)\1/g, (full, quote, specifier) => {
|
|
155
|
+
const dependencyUrl = dependencyUrls.get(specifier.replace(/[?#].*$/, ""));
|
|
156
|
+
if (dependencyUrl)
|
|
157
|
+
return `${quote}${dependencyUrl}${quote}`;
|
|
158
|
+
const logicalPath = resolveKnownModulePath(specifier, knownPaths);
|
|
159
|
+
const asset = logicalPath ? moduleAssets.get(logicalPath) : undefined;
|
|
160
|
+
if (!asset)
|
|
161
|
+
return full;
|
|
162
|
+
return `${quote}${releaseAssetUrl(asset.contentHash, "js")}${quote}`;
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
function buildDependencyUrlMap(dependencies) {
|
|
166
|
+
const urls = new Map();
|
|
167
|
+
for (const [specifier, moduleUrl] of Object.entries(PLATFORM_UTILITIES)) {
|
|
168
|
+
const entry = dependencies[specifier];
|
|
169
|
+
if (!entry)
|
|
170
|
+
continue;
|
|
171
|
+
urls.set(moduleUrl, releaseAssetUrl(entry.contentHash, "js"));
|
|
172
|
+
}
|
|
173
|
+
return urls;
|
|
174
|
+
}
|
|
175
|
+
async function finalizeProjectModules(transformedModules, knownPaths, dependencyUrls, uploadQueue, pendingBytes, gaps) {
|
|
176
|
+
const finalized = new Map();
|
|
177
|
+
const unresolvedCycles = new Set();
|
|
178
|
+
async function finalize(logicalPath, stack) {
|
|
179
|
+
const existing = finalized.get(logicalPath);
|
|
180
|
+
if (existing)
|
|
181
|
+
return existing;
|
|
182
|
+
if (stack.includes(logicalPath)) {
|
|
183
|
+
const cycle = [...stack.slice(stack.indexOf(logicalPath)), logicalPath].join("->");
|
|
184
|
+
const gap = `cycle:${cycle}`;
|
|
185
|
+
if (!unresolvedCycles.has(gap)) {
|
|
186
|
+
unresolvedCycles.add(gap);
|
|
187
|
+
gaps.push(gap);
|
|
188
|
+
}
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
const transformed = transformedModules.get(logicalPath);
|
|
192
|
+
if (!transformed)
|
|
193
|
+
return null;
|
|
194
|
+
const nextStack = [...stack, logicalPath];
|
|
195
|
+
const imports = collectVfModuleImports(transformed.code, knownPaths);
|
|
196
|
+
for (const importedPath of imports.values()) {
|
|
197
|
+
await finalize(importedPath, nextStack);
|
|
198
|
+
}
|
|
199
|
+
const rewritten = rewriteVfModuleImports(transformed.code, finalized, knownPaths, dependencyUrls);
|
|
200
|
+
const entry = await addPreparedJavaScriptAsset(logicalPath, rewritten, uploadQueue, pendingBytes);
|
|
201
|
+
if (!entry)
|
|
202
|
+
return null;
|
|
203
|
+
finalized.set(logicalPath, entry);
|
|
204
|
+
return entry;
|
|
205
|
+
}
|
|
206
|
+
for (const logicalPath of transformedModules.keys()) {
|
|
207
|
+
const entry = await finalize(logicalPath, []);
|
|
208
|
+
if (!entry) {
|
|
209
|
+
const gap = `oversized:${logicalPath}`;
|
|
210
|
+
if (!gaps.includes(gap))
|
|
211
|
+
gaps.push(gap);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return Object.fromEntries(finalized);
|
|
215
|
+
}
|
|
124
216
|
async function addPreparedJavaScriptAsset(logicalPath, code, uploadQueue, pendingBytes) {
|
|
125
217
|
const bytes = new TextEncoder().encode(code);
|
|
126
218
|
if (bytes.byteLength > RELEASE_ASSET_MAX_SIZE_BYTES)
|
|
@@ -269,7 +361,7 @@ async function runBuildInner(input, tempDir, client, transform) {
|
|
|
269
361
|
}
|
|
270
362
|
// 3 + 4. Collect the browser module closure and transform each module
|
|
271
363
|
// through the SAME pipeline serveModule uses (browser, non-SSR).
|
|
272
|
-
const
|
|
364
|
+
const transformedModules = new Map();
|
|
273
365
|
const gaps = [];
|
|
274
366
|
const uploadQueue = [];
|
|
275
367
|
// Bytes are held per-hash only until uploaded, then dropped (M3).
|
|
@@ -308,19 +400,19 @@ async function runBuildInner(input, tempDir, client, transform) {
|
|
|
308
400
|
error: sanitized,
|
|
309
401
|
};
|
|
310
402
|
}
|
|
311
|
-
|
|
312
|
-
// M2: enforce 10 MB client-side limit — skip oversized modules with a gap.
|
|
313
|
-
if (!entry) {
|
|
314
|
-
gaps.push(`oversized:${logicalPath}`);
|
|
315
|
-
logger.warn("Module exceeds max size, skipping", {
|
|
316
|
-
path: logicalPath,
|
|
317
|
-
limit: RELEASE_ASSET_MAX_SIZE_BYTES,
|
|
318
|
-
});
|
|
319
|
-
continue;
|
|
320
|
-
}
|
|
321
|
-
modules[logicalPath] = entry;
|
|
403
|
+
transformedModules.set(logicalPath, { logicalPath, code });
|
|
322
404
|
}
|
|
323
405
|
const dependencies = await buildFrameworkDependencies(input, tempDir, transform, uploadQueue, pendingBytes, gaps);
|
|
406
|
+
const dependencyUrls = buildDependencyUrlMap(dependencies);
|
|
407
|
+
const modules = await finalizeProjectModules(transformedModules, knownPaths, dependencyUrls, uploadQueue, pendingBytes, gaps);
|
|
408
|
+
for (const logicalPath of transformedModules.keys()) {
|
|
409
|
+
if (modules[logicalPath])
|
|
410
|
+
continue;
|
|
411
|
+
logger.warn("Module exceeds max size, skipping", {
|
|
412
|
+
path: logicalPath,
|
|
413
|
+
limit: RELEASE_ASSET_MAX_SIZE_BYTES,
|
|
414
|
+
});
|
|
415
|
+
}
|
|
324
416
|
// 5b. CSS: compile project CSS where reachable, else record css:[] and note.
|
|
325
417
|
const css = [];
|
|
326
418
|
const cssHashes = [];
|