veryfront 0.1.778 → 0.1.780
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 +1 -1
- package/esm/src/html/html-shell-generator.d.ts.map +1 -1
- package/esm/src/html/html-shell-generator.js +2 -0
- package/esm/src/html/utils.d.ts +3 -0
- package/esm/src/html/utils.d.ts.map +1 -1
- package/esm/src/html/utils.js +31 -4
- package/esm/src/integrations/_data.d.ts.map +1 -1
- package/esm/src/integrations/_data.js +9 -1
- package/esm/src/release-assets/build-executor.d.ts.map +1 -1
- package/esm/src/release-assets/build-executor.js +76 -16
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +1 -1
package/esm/deno.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-shell-generator.d.ts","sourceRoot":"","sources":["../../../src/src/html/html-shell-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AA0BxE,OAAO,EAGL,aAAa,EACd,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAqCxD,KAAK,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,GAAG,IAAI,CAAC;AA2EzE,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,qBAAqB,EAC9B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAC1C,KAAK,CAAC,EAAE,cAAc,EACtB,kBAAkB,CAAC,EAAE,MAAM,EAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAC5C,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAmBzC;
|
|
1
|
+
{"version":3,"file":"html-shell-generator.d.ts","sourceRoot":"","sources":["../../../src/src/html/html-shell-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AA0BxE,OAAO,EAGL,aAAa,EACd,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAqCxD,KAAK,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,GAAG,IAAI,CAAC;AA2EzE,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,qBAAqB,EAC9B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAC1C,KAAK,CAAC,EAAE,cAAc,EACtB,kBAAkB,CAAC,EAAE,MAAM,EAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAC5C,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAmBzC;AA8QD,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,qBAAqB,EAC9B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAC1C,KAAK,CAAC,EAAE,cAAc,EACtB,iBAAiB,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAC5C,OAAO,CAAC,MAAM,CAAC,CAoBjB"}
|
|
@@ -134,11 +134,13 @@ async function generateHTMLShellPartsImpl(meta, options, params, props, contentF
|
|
|
134
134
|
// Enable dev scripts for local dev OR preview mode (for HMR support in Studio),
|
|
135
135
|
// unless a caller explicitly forces production client scripts for fair benchmarking.
|
|
136
136
|
const useDevScripts = !options.forceProductionScripts && (isLocalProject || isPreviewMode);
|
|
137
|
+
const releaseManifest = options.studioEmbed ? null : getReadyManifestForRender(options.releaseId);
|
|
137
138
|
const importMapPromise = buildImportMap({
|
|
138
139
|
projectDir: options.projectDir,
|
|
139
140
|
config: options.config,
|
|
140
141
|
customImports: options.importMap,
|
|
141
142
|
pretty: useDevScripts,
|
|
143
|
+
releaseAssetManifest: releaseManifest,
|
|
142
144
|
});
|
|
143
145
|
const hydrationDataJson = generateHydrationData(meta.slug || "", params ?? {}, props ?? {}, options, { pretty: useDevScripts });
|
|
144
146
|
const nonce = options.nonce ?? "";
|
package/esm/src/html/utils.d.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import type { VeryfrontConfig } from "../config/index.js";
|
|
2
|
+
import type { ReleaseAssetManifest } from "../release-assets/manifest-schema.js";
|
|
2
3
|
export declare function buildRootAttributes(slug: string, mode: string, noLayout: boolean, ssrHash?: string): string;
|
|
3
4
|
export interface BuiltImportMap {
|
|
4
5
|
imports: Record<string, string>;
|
|
5
6
|
json: string;
|
|
6
7
|
}
|
|
8
|
+
export declare const PLATFORM_UTILITIES: Record<string, string>;
|
|
7
9
|
interface BuildImportMapOptions {
|
|
8
10
|
projectDir?: string;
|
|
9
11
|
config?: VeryfrontConfig;
|
|
10
12
|
customImports?: Record<string, string>;
|
|
11
13
|
pretty?: boolean;
|
|
14
|
+
releaseAssetManifest?: ReleaseAssetManifest | null;
|
|
12
15
|
}
|
|
13
16
|
export declare function buildImportMap(options?: BuildImportMapOptions | Record<string, string>): Promise<BuiltImportMap>;
|
|
14
17
|
export declare function buildImportMapJson(options?: BuildImportMapOptions | Record<string, string>): Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/src/html/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":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,7 @@ const AI_MODULE_UTILITIES = {
|
|
|
63
63
|
"veryfront/mdx": PLATFORM_UTILITY_PATHS.mdx,
|
|
64
64
|
"veryfront/workflow": PLATFORM_UTILITY_PATHS.workflow,
|
|
65
65
|
};
|
|
66
|
-
const PLATFORM_UTILITIES = {
|
|
66
|
+
export const PLATFORM_UTILITIES = {
|
|
67
67
|
...CORE_PLATFORM_UTILITIES,
|
|
68
68
|
...AI_MODULE_UTILITIES,
|
|
69
69
|
};
|
|
@@ -186,10 +186,34 @@ function stableMapKey(imports) {
|
|
|
186
186
|
? JSON.stringify(Object.entries(imports).sort(([a], [b]) => a.localeCompare(b)))
|
|
187
187
|
: "";
|
|
188
188
|
}
|
|
189
|
+
function stableManifestDependencyKey(manifest) {
|
|
190
|
+
return manifest
|
|
191
|
+
? JSON.stringify({
|
|
192
|
+
assetBasePath: manifest.assetBasePath,
|
|
193
|
+
dependencies: Object.entries(manifest.dependencies)
|
|
194
|
+
.map(([specifier, entry]) => [specifier, entry.contentHash])
|
|
195
|
+
.sort(([a], [b]) => String(a).localeCompare(String(b))),
|
|
196
|
+
})
|
|
197
|
+
: "";
|
|
198
|
+
}
|
|
199
|
+
function applyManifestDependencies(imports, manifest) {
|
|
200
|
+
if (!manifest)
|
|
201
|
+
return imports;
|
|
202
|
+
let rewritten = null;
|
|
203
|
+
for (const specifier of Object.keys(imports)) {
|
|
204
|
+
const entry = manifest.dependencies[specifier];
|
|
205
|
+
if (!entry || entry.contentType !== "text/javascript")
|
|
206
|
+
continue;
|
|
207
|
+
rewritten ??= { ...imports };
|
|
208
|
+
rewritten[specifier] = `${manifest.assetBasePath}/${entry.contentHash}.js`;
|
|
209
|
+
}
|
|
210
|
+
return rewritten ?? imports;
|
|
211
|
+
}
|
|
189
212
|
function isImportMapOnlyOptions(options) {
|
|
190
213
|
return !("projectDir" in options) &&
|
|
191
214
|
!("config" in options) &&
|
|
192
215
|
!("customImports" in options) &&
|
|
216
|
+
!("releaseAssetManifest" in options) &&
|
|
193
217
|
!("pretty" in options);
|
|
194
218
|
}
|
|
195
219
|
export async function buildImportMap(options) {
|
|
@@ -199,19 +223,20 @@ export async function buildImportMap(options) {
|
|
|
199
223
|
return { imports, json: stringifyImportMap(imports) };
|
|
200
224
|
}
|
|
201
225
|
}
|
|
202
|
-
const { projectDir, config, customImports, pretty = true } = (options ?? {});
|
|
226
|
+
const { projectDir, config, customImports, pretty = true, releaseAssetManifest } = (options ?? {});
|
|
203
227
|
const mode = config?.client?.moduleResolution ?? "cdn";
|
|
204
228
|
const versions = projectDir ? await resolveVersions(projectDir, config) : DEFAULT_VERSIONS;
|
|
205
229
|
if (mode === "bundled") {
|
|
206
230
|
const reactTemplates = CDN_URL_TEMPLATES["esm.sh"];
|
|
207
|
-
|
|
231
|
+
let imports = {
|
|
208
232
|
react: reactTemplates.react(versions.react),
|
|
209
233
|
"react-dom": reactTemplates.reactDom(versions.react),
|
|
210
234
|
"react-dom/client": reactTemplates.reactDomClient(versions.react),
|
|
211
235
|
"react/jsx-runtime": reactTemplates.jsxRuntime(versions.react),
|
|
212
236
|
"react/jsx-dev-runtime": reactTemplates.jsxDevRuntime(versions.react),
|
|
213
|
-
...customImports,
|
|
214
237
|
};
|
|
238
|
+
imports = applyManifestDependencies(imports, releaseAssetManifest);
|
|
239
|
+
imports = { ...imports, ...customImports };
|
|
215
240
|
return { imports, json: stringifyImportMap(imports, pretty) };
|
|
216
241
|
}
|
|
217
242
|
let imports;
|
|
@@ -222,6 +247,7 @@ export async function buildImportMap(options) {
|
|
|
222
247
|
imports = getCdnImportMap(versions, (config?.client?.cdn?.provider ?? "esm.sh"));
|
|
223
248
|
}
|
|
224
249
|
imports["@/"] = "/_vf_modules/";
|
|
250
|
+
imports = applyManifestDependencies(imports, releaseAssetManifest);
|
|
225
251
|
if (customImports) {
|
|
226
252
|
imports = { ...imports, ...customImports };
|
|
227
253
|
}
|
|
@@ -233,6 +259,7 @@ export async function buildImportMap(options) {
|
|
|
233
259
|
veryfront: versions.veryfront,
|
|
234
260
|
pretty,
|
|
235
261
|
customImports: stableMapKey(customImports),
|
|
262
|
+
manifestDependencies: stableManifestDependencyKey(releaseAssetManifest),
|
|
236
263
|
});
|
|
237
264
|
const cached = importMapJsonCache.get(cacheKey);
|
|
238
265
|
if (cached)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_data.d.ts","sourceRoot":"","sources":["../../../src/src/integrations/_data.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,eAAO,MAAM,UAAU,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"_data.d.ts","sourceRoot":"","sources":["../../../src/src/integrations/_data.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,eAAO,MAAM,UAAU,EAAE,iBAAiB,EAk61DzC,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAyZxC,CAAC"}
|
|
@@ -13005,7 +13005,14 @@ export const connectors = [
|
|
|
13005
13005
|
"body": {
|
|
13006
13006
|
"file": {
|
|
13007
13007
|
"type": "string",
|
|
13008
|
-
"description": "
|
|
13008
|
+
"description": "Base64-encoded content of the document (e.g. a PDF invoice), sent decoded as the binary multipart 'file' part",
|
|
13009
|
+
"required": true,
|
|
13010
|
+
"encoding": "base64",
|
|
13011
|
+
"partFilenameField": "file_name",
|
|
13012
|
+
},
|
|
13013
|
+
"file_name": {
|
|
13014
|
+
"type": "string",
|
|
13015
|
+
"description": "Filename for the uploaded document, e.g. invoice.pdf",
|
|
13009
13016
|
"required": true,
|
|
13010
13017
|
},
|
|
13011
13018
|
"metadata": {
|
|
@@ -13013,6 +13020,7 @@ export const connectors = [
|
|
|
13013
13020
|
"description": 'Optional JSON metadata part, e.g. { "document_type": "Rechnungseingang", "note": "..." }. Use List Document Types to find valid document types.',
|
|
13014
13021
|
},
|
|
13015
13022
|
},
|
|
13023
|
+
"bodyMode": "form-data",
|
|
13016
13024
|
"contentType": "multipart/form-data",
|
|
13017
13025
|
},
|
|
13018
13026
|
}],
|
|
@@ -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;AA+BH,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,WAAW,uBAAuB;IACt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MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AA6BD,2DAA2D;AAC3D,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM/D;AA8LD;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,sBAAsB,EAC7B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,uBAAuB,CAAC,CA2ClC"}
|
|
@@ -18,7 +18,9 @@ import { serverLogger } from "../utils/index.js";
|
|
|
18
18
|
import { VERSION } from "../utils/version.js";
|
|
19
19
|
import { createFileSystem } from "../platform/compat/fs.js";
|
|
20
20
|
import { dirname, join } from "../platform/compat/path/index.js";
|
|
21
|
+
import { resolveFrameworkSourcePath } from "../platform/compat/framework-source-resolver.js";
|
|
21
22
|
import { transformToESM } from "../transforms/esm-transform.js";
|
|
23
|
+
import { PLATFORM_UTILITIES } from "../html/utils.js";
|
|
22
24
|
import { sha256HexBytes } from "./hash.js";
|
|
23
25
|
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";
|
|
24
26
|
const logger = serverLogger.component("release-asset-build");
|
|
@@ -26,6 +28,14 @@ const logger = serverLogger.component("release-asset-build");
|
|
|
26
28
|
const BROWSER_MODULE_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js", ".mdx"];
|
|
27
29
|
/** Directories whose modules are part of the browser closure. */
|
|
28
30
|
const BROWSER_MODULE_DIRS = ["pages/", "components/", "layouts/", "lib/", "src/"];
|
|
31
|
+
const FRAMEWORK_MODULE_URL_PREFIX = "/_vf_modules/_veryfront/";
|
|
32
|
+
function frameworkModuleUrlToSourceKey(moduleUrl) {
|
|
33
|
+
if (!moduleUrl.startsWith(FRAMEWORK_MODULE_URL_PREFIX))
|
|
34
|
+
return null;
|
|
35
|
+
return moduleUrl
|
|
36
|
+
.slice(FRAMEWORK_MODULE_URL_PREFIX.length)
|
|
37
|
+
.replace(/\.(mjs|cjs|js|jsx|ts|tsx)$/, "");
|
|
38
|
+
}
|
|
29
39
|
/** Sanitize an error for state reporting (no internal paths / stack traces). */
|
|
30
40
|
function sanitizeError(error) {
|
|
31
41
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -110,6 +120,64 @@ function resolveStaticImports(source, moduleLogicalPath, knownPaths) {
|
|
|
110
120
|
}
|
|
111
121
|
return results;
|
|
112
122
|
}
|
|
123
|
+
async function addPreparedJavaScriptAsset(logicalPath, code, uploadQueue, pendingBytes) {
|
|
124
|
+
const bytes = new TextEncoder().encode(code);
|
|
125
|
+
if (bytes.byteLength > RELEASE_ASSET_MAX_SIZE_BYTES)
|
|
126
|
+
return null;
|
|
127
|
+
const contentHash = await sha256HexBytes(bytes);
|
|
128
|
+
const entry = {
|
|
129
|
+
logicalPath,
|
|
130
|
+
contentHash,
|
|
131
|
+
size: bytes.byteLength,
|
|
132
|
+
contentType: RELEASE_ASSET_CONTENT_TYPES.js,
|
|
133
|
+
};
|
|
134
|
+
if (!pendingBytes.has(contentHash)) {
|
|
135
|
+
pendingBytes.set(contentHash, { bytes, contentType: RELEASE_ASSET_CONTENT_TYPES.js });
|
|
136
|
+
uploadQueue.push(entry);
|
|
137
|
+
}
|
|
138
|
+
return entry;
|
|
139
|
+
}
|
|
140
|
+
async function buildFrameworkDependencies(input, tempDir, transform, uploadQueue, pendingBytes, gaps) {
|
|
141
|
+
const fs = createFileSystem();
|
|
142
|
+
const dependencies = {};
|
|
143
|
+
for (const [specifier, moduleUrl] of Object.entries(PLATFORM_UTILITIES)) {
|
|
144
|
+
const sourceKey = frameworkModuleUrlToSourceKey(moduleUrl);
|
|
145
|
+
if (!sourceKey)
|
|
146
|
+
continue;
|
|
147
|
+
const frameworkSource = await resolveFrameworkSourcePath(sourceKey, {
|
|
148
|
+
extraLookupDirs: [join(tempDir, "src")],
|
|
149
|
+
});
|
|
150
|
+
if (!frameworkSource) {
|
|
151
|
+
gaps.push(`dependency-missing:${specifier}`);
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
let code;
|
|
155
|
+
try {
|
|
156
|
+
const source = await fs.readTextFile(frameworkSource.path);
|
|
157
|
+
code = await transform(source, frameworkSource.path, tempDir, input.adapter, {
|
|
158
|
+
projectId: input.projectId,
|
|
159
|
+
dev: false,
|
|
160
|
+
ssr: false,
|
|
161
|
+
reactVersion: input.reactVersion,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
gaps.push(`dependency-transform-failed:${specifier}`);
|
|
166
|
+
logger.warn("Framework dependency transform failed during release asset build", {
|
|
167
|
+
specifier,
|
|
168
|
+
error: sanitizeError(error),
|
|
169
|
+
});
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
const entry = await addPreparedJavaScriptAsset(`__dependencies__/${specifier}`, code, uploadQueue, pendingBytes);
|
|
173
|
+
if (!entry) {
|
|
174
|
+
gaps.push(`dependency-oversized:${specifier}`);
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
dependencies[specifier] = entry;
|
|
178
|
+
}
|
|
179
|
+
return dependencies;
|
|
180
|
+
}
|
|
113
181
|
/**
|
|
114
182
|
* Walk the static import graph from a set of entry points using BFS.
|
|
115
183
|
* Returns all reachable logical paths (entries included).
|
|
@@ -239,31 +307,19 @@ async function runBuildInner(input, tempDir, client, transform) {
|
|
|
239
307
|
error: sanitized,
|
|
240
308
|
};
|
|
241
309
|
}
|
|
242
|
-
|
|
243
|
-
const bytes = new TextEncoder().encode(code);
|
|
310
|
+
const entry = await addPreparedJavaScriptAsset(logicalPath, code, uploadQueue, pendingBytes);
|
|
244
311
|
// M2: enforce 10 MB client-side limit — skip oversized modules with a gap.
|
|
245
|
-
if (
|
|
312
|
+
if (!entry) {
|
|
246
313
|
gaps.push(`oversized:${logicalPath}`);
|
|
247
314
|
logger.warn("Module exceeds max size, skipping", {
|
|
248
315
|
path: logicalPath,
|
|
249
|
-
size: bytes.byteLength,
|
|
250
316
|
limit: RELEASE_ASSET_MAX_SIZE_BYTES,
|
|
251
317
|
});
|
|
252
318
|
continue;
|
|
253
319
|
}
|
|
254
|
-
const contentHash = await sha256HexBytes(bytes);
|
|
255
|
-
const entry = {
|
|
256
|
-
logicalPath,
|
|
257
|
-
contentHash,
|
|
258
|
-
size: bytes.byteLength,
|
|
259
|
-
contentType: RELEASE_ASSET_CONTENT_TYPES.js,
|
|
260
|
-
};
|
|
261
320
|
modules[logicalPath] = entry;
|
|
262
|
-
if (!pendingBytes.has(contentHash)) {
|
|
263
|
-
pendingBytes.set(contentHash, { bytes, contentType: RELEASE_ASSET_CONTENT_TYPES.js });
|
|
264
|
-
uploadQueue.push(entry);
|
|
265
|
-
}
|
|
266
321
|
}
|
|
322
|
+
const dependencies = await buildFrameworkDependencies(input, tempDir, transform, uploadQueue, pendingBytes, gaps);
|
|
267
323
|
// 5b. CSS: compile project CSS where reachable, else record css:[] and note.
|
|
268
324
|
const css = [];
|
|
269
325
|
const cssHashes = [];
|
|
@@ -365,7 +421,11 @@ async function runBuildInner(input, tempDir, client, transform) {
|
|
|
365
421
|
}])),
|
|
366
422
|
css,
|
|
367
423
|
routes,
|
|
368
|
-
dependencies: {
|
|
424
|
+
dependencies: Object.fromEntries(Object.entries(dependencies).map(([specifier, entry]) => [specifier, {
|
|
425
|
+
contentHash: entry.contentHash,
|
|
426
|
+
size: entry.size,
|
|
427
|
+
contentType: entry.contentType,
|
|
428
|
+
}])),
|
|
369
429
|
fallback: { mode: "jit", gaps },
|
|
370
430
|
};
|
|
371
431
|
const result = await client.putReleaseAssetManifest(input.releaseVersionRef, manifest);
|