veryfront 0.1.837 → 0.1.839
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/modules/server/module-server.d.ts.map +1 -1
- package/esm/src/modules/server/module-server.js +27 -13
- package/esm/src/release-assets/manifest-cache.d.ts +9 -1
- package/esm/src/release-assets/manifest-cache.d.ts.map +1 -1
- package/esm/src/release-assets/manifest-cache.js +31 -10
- package/esm/src/release-assets/module-consumption.d.ts +4 -1
- package/esm/src/release-assets/module-consumption.d.ts.map +1 -1
- package/esm/src/release-assets/module-consumption.js +23 -3
- 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":"module-server.d.ts","sourceRoot":"","sources":["../../../../src/src/modules/server/module-server.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAG5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"module-server.d.ts","sourceRoot":"","sources":["../../../../src/src/modules/server/module-server.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAG5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AA0DtE;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAwDrD,CAAC;AAyEF,MAAM,WAAW,mBAAmB;IAClC,yDAAyD;IACzD,SAAS,EAAE,MAAM,CAAC;IAClB,6BAA6B;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,sBAAsB;IACtB,OAAO,EAAE,cAAc,CAAC;IACxB,uBAAuB;IACvB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,+DAA+D;IAC/D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mDAAmD;IACnD,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sFAAsF;IACtF,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,sDAAsD;AACtD,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAqczF;AAwWD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAGrD"}
|
|
@@ -20,7 +20,7 @@ import { FRAMEWORK_ROOT, resolveFrameworkSourcePath, } from "../../platform/comp
|
|
|
20
20
|
import { getReactUrls, REACT_DEFAULT_VERSION } from "../../utils/constants/cdn.js";
|
|
21
21
|
import { readLimitedCrossProjectSource } from "./cross-project-source-limit.js";
|
|
22
22
|
import { sha256Short } from "../../cache/hash.js";
|
|
23
|
-
import { getReleaseDependencyRewriteManifestState, rewriteReleaseDependencyImportsForModule, } from "../../release-assets/module-consumption.js";
|
|
23
|
+
import { getReleaseDependencyRewriteManifestState, hasReleaseDependencyImportSpecifiers, rewriteReleaseDependencyImportsForModule, } from "../../release-assets/module-consumption.js";
|
|
24
24
|
import { RELEASE_ASSET_IMMUTABLE_MAX_AGE_SECONDS, RELEASE_MODULE_RUNTIME_VERSION_PARAM, RELEASE_MODULE_VERSION_PARAM, } from "../../release-assets/constants.js";
|
|
25
25
|
import { buildSourceMissCacheKey, hasSourceMiss, rememberSourceMiss, } from "./module-source-resolution-cache.js";
|
|
26
26
|
import { buildReleaseModuleResponseCacheKey, getReleaseModuleResponse, rememberReleaseModuleResponse, } from "./module-response-cache.js";
|
|
@@ -337,17 +337,18 @@ export function serveModule(req, options) {
|
|
|
337
337
|
shouldCacheReleaseVersionedModule(url, options, isSSR);
|
|
338
338
|
let releaseDependencyManifest = null;
|
|
339
339
|
let releaseDependencyManifestVersion = null;
|
|
340
|
-
let
|
|
340
|
+
let releaseDependencyRewriteEnabled = false;
|
|
341
341
|
if (canCacheReleaseVersionedModule) {
|
|
342
|
-
const manifestState = await getReleaseDependencyRewriteManifestState(options.releaseId
|
|
342
|
+
const manifestState = await getReleaseDependencyRewriteManifestState(options.releaseId, {
|
|
343
|
+
refreshCachedNull: true,
|
|
344
|
+
});
|
|
343
345
|
if (manifestState.enabled) {
|
|
346
|
+
releaseDependencyRewriteEnabled = true;
|
|
344
347
|
releaseDependencyManifest = manifestState.manifest;
|
|
345
348
|
releaseDependencyManifestVersion = manifestState.manifest?.manifestVersion ?? null;
|
|
346
|
-
releaseDependencyManifestReady = manifestState.manifest !== null;
|
|
347
349
|
}
|
|
348
350
|
}
|
|
349
|
-
const releaseModuleResponseCacheKey = canCacheReleaseVersionedModule
|
|
350
|
-
releaseDependencyManifestReady
|
|
351
|
+
const releaseModuleResponseCacheKey = canCacheReleaseVersionedModule
|
|
351
352
|
? buildReleaseModuleResponseCacheKey({
|
|
352
353
|
projectIdentity: effectiveProjectId,
|
|
353
354
|
projectDir,
|
|
@@ -363,11 +364,16 @@ export function serveModule(req, options) {
|
|
|
363
364
|
if (releaseModuleResponseCacheKey) {
|
|
364
365
|
const cachedResponse = await getReleaseModuleResponse(releaseModuleResponseCacheKey);
|
|
365
366
|
if (cachedResponse?.entry) {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
367
|
+
const canUseCachedResponse = !releaseDependencyRewriteEnabled ||
|
|
368
|
+
!(await hasReleaseDependencyImportSpecifiers(cachedResponse.entry.body));
|
|
369
|
+
if (canUseCachedResponse) {
|
|
370
|
+
markRequestProfilePhase("module.response_cache_hit");
|
|
371
|
+
if (cachedResponse.source === "distributed") {
|
|
372
|
+
markRequestProfilePhase("module.response_cache_distributed_hit");
|
|
373
|
+
}
|
|
374
|
+
return createModuleResponse(method, cachedResponse.entry.body, cachedResponse.entry.status, Object.fromEntries(cachedResponse.entry.headers));
|
|
369
375
|
}
|
|
370
|
-
|
|
376
|
+
markRequestProfilePhase("module.response_cache_dependency_blocked");
|
|
371
377
|
}
|
|
372
378
|
markRequestProfilePhase("module.response_cache_miss");
|
|
373
379
|
}
|
|
@@ -459,20 +465,28 @@ export function serveModule(req, options) {
|
|
|
459
465
|
if (!isSSR) {
|
|
460
466
|
code = await rewriteReleaseDependencyImportsForModule(code, {
|
|
461
467
|
releaseId: options.releaseId,
|
|
462
|
-
manifest: releaseDependencyManifest
|
|
468
|
+
manifest: releaseDependencyRewriteEnabled ? releaseDependencyManifest : undefined,
|
|
469
|
+
manifestReadOptions: { refreshCachedNull: true },
|
|
463
470
|
readDependencySource: (path) => platformFs.readTextFile(path),
|
|
464
471
|
});
|
|
465
472
|
code = await addReleaseVersionToFallbackImports(code, modulePath, options.releaseId);
|
|
466
473
|
}
|
|
467
474
|
}
|
|
475
|
+
const hasUnrewrittenReleaseDependencyImports = releaseDependencyRewriteEnabled &&
|
|
476
|
+
await hasReleaseDependencyImportSpecifiers(code);
|
|
477
|
+
const canCacheModuleResponse = releaseModuleResponseCacheKey !== null &&
|
|
478
|
+
!hasUnrewrittenReleaseDependencyImports;
|
|
479
|
+
if (hasUnrewrittenReleaseDependencyImports) {
|
|
480
|
+
markRequestProfilePhase("module.response_cache_dependency_blocked");
|
|
481
|
+
}
|
|
468
482
|
const headers = getModuleHeaders(modulePath, {
|
|
469
|
-
cacheable:
|
|
483
|
+
cacheable: canCacheModuleResponse,
|
|
470
484
|
});
|
|
471
485
|
logger.debug("Request complete", {
|
|
472
486
|
path: modulePath,
|
|
473
487
|
durationMs: (performance.now() - startTime).toFixed(1),
|
|
474
488
|
});
|
|
475
|
-
if (
|
|
489
|
+
if (canCacheModuleResponse && method === "GET") {
|
|
476
490
|
void rememberReleaseModuleResponse(releaseModuleResponseCacheKey, {
|
|
477
491
|
body: code,
|
|
478
492
|
status: HTTP_OK,
|
|
@@ -23,6 +23,14 @@
|
|
|
23
23
|
* @module release-assets/manifest-cache
|
|
24
24
|
*/
|
|
25
25
|
import { type ReleaseAssetManifest } from "./manifest-schema.js";
|
|
26
|
+
export interface ReadyManifestReadOptions {
|
|
27
|
+
/**
|
|
28
|
+
* Retry a cached non-ready result after a short throttle instead of waiting
|
|
29
|
+
* for the full null TTL. Used by module responses that cannot be cached
|
|
30
|
+
* safely until dependency imports can be rewritten through the manifest.
|
|
31
|
+
*/
|
|
32
|
+
refreshCachedNull?: boolean;
|
|
33
|
+
}
|
|
26
34
|
/**
|
|
27
35
|
* Fetcher used to retrieve a manifest for a release. Registered per-releaseId
|
|
28
36
|
* by the runtime adapter that owns that release, so the correct project-scoped
|
|
@@ -73,7 +81,7 @@ export declare function getReadyManifestForRender(releaseId: string | null | und
|
|
|
73
81
|
* falls back to null when the flag is off, no fetcher is registered, the
|
|
74
82
|
* manifest is unavailable, or the fetch fails.
|
|
75
83
|
*/
|
|
76
|
-
export declare function getReadyManifestForRenderAsync(releaseId: string | null | undefined): Promise<ReleaseAssetManifest | null>;
|
|
84
|
+
export declare function getReadyManifestForRenderAsync(releaseId: string | null | undefined, options?: ReadyManifestReadOptions): Promise<ReleaseAssetManifest | null>;
|
|
77
85
|
/** Clear cached manifest bodies while keeping registered fetchers intact. */
|
|
78
86
|
export declare function clearCachedReleaseAssetManifests(): void;
|
|
79
87
|
/** Clear the cache and fetcher registry (tests / adapter teardown). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest-cache.d.ts","sourceRoot":"","sources":["../../../src/src/release-assets/manifest-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAWH,OAAO,EAA6B,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"manifest-cache.d.ts","sourceRoot":"","sources":["../../../src/src/release-assets/manifest-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAWH,OAAO,EAA6B,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAgC5F,MAAM,WAAW,wBAAwB;IACvC;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAOD;;;;GAIG;AACH,MAAM,WAAW,2BAA2B;IAC1C,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAC1B;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,oBAAoB,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAChE,CAAC;CACH;AAKD;;;;;;GAMG;AACH,wBAAgB,iCAAiC,CAC/C,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,2BAA2B,GACnC,IAAI,CAEN;AAED;;;;GAIG;AACH,wBAAgB,mCAAmC,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAE3E;AAED;;;;;GAKG;AACH,wBAAgB,oCAAoC,CAClD,OAAO,EAAE,2BAA2B,GAAG,SAAS,GAC/C,IAAI,CAMN;AASD,yEAAyE;AACzE,wBAAgB,6BAA6B,IAAI,OAAO,CAKvD;AAiCD;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACnC,oBAAoB,GAAG,IAAI,CAgC7B;AAED;;;;;;;GAOG;AACH,wBAAsB,8BAA8B,CAClD,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAkCtC;AAgGD,6EAA6E;AAC7E,wBAAgB,gCAAgC,IAAI,IAAI,CAIvD;AAED,uEAAuE;AACvE,wBAAgB,8BAA8B,IAAI,IAAI,CAGrD"}
|
|
@@ -34,6 +34,8 @@ const logger = serverLogger.component("release-asset-manifest");
|
|
|
34
34
|
const MAX_CACHED_MANIFESTS = 500;
|
|
35
35
|
/** Short TTL for non-ready / missing results (ms). */
|
|
36
36
|
const NON_READY_TTL_MS = 30_000;
|
|
37
|
+
/** Minimum delay before an awaited consumer can retry a cached non-ready result. */
|
|
38
|
+
const NON_READY_REVALIDATE_MS = 5_000;
|
|
37
39
|
/** TTL for ready manifests — long but finite so superseded entries are picked up (15 min). */
|
|
38
40
|
const READY_TTL_MS = 15 * 60 * 1000;
|
|
39
41
|
/** Background revalidation interval for ready manifests (1 min). */
|
|
@@ -162,7 +164,7 @@ export function getReadyManifestForRender(releaseId) {
|
|
|
162
164
|
* falls back to null when the flag is off, no fetcher is registered, the
|
|
163
165
|
* manifest is unavailable, or the fetch fails.
|
|
164
166
|
*/
|
|
165
|
-
export async function getReadyManifestForRenderAsync(releaseId) {
|
|
167
|
+
export async function getReadyManifestForRenderAsync(releaseId, options = {}) {
|
|
166
168
|
if (!releaseId) {
|
|
167
169
|
markManifestDecision("no_release_id");
|
|
168
170
|
return null;
|
|
@@ -181,8 +183,13 @@ export async function getReadyManifestForRenderAsync(releaseId) {
|
|
|
181
183
|
maybeScheduleReadyRefresh(releaseId, best);
|
|
182
184
|
return best.manifest;
|
|
183
185
|
}
|
|
186
|
+
const now = Date.now();
|
|
184
187
|
const plain = manifestCache.get(releaseId);
|
|
185
|
-
if (plain && plain.expiresAt >
|
|
188
|
+
if (plain && plain.expiresAt > now) {
|
|
189
|
+
if (options.refreshCachedNull && (plain.refreshAfter ?? plain.expiresAt) <= now) {
|
|
190
|
+
markManifestDecision("cached_null_refresh");
|
|
191
|
+
return await fetchManifest(releaseId);
|
|
192
|
+
}
|
|
186
193
|
markManifestDecision("cached_null");
|
|
187
194
|
return null;
|
|
188
195
|
}
|
|
@@ -211,14 +218,15 @@ function fetchManifest(releaseId) {
|
|
|
211
218
|
return null;
|
|
212
219
|
if (!result) {
|
|
213
220
|
markManifestDecision("fetch_missing");
|
|
214
|
-
|
|
221
|
+
cacheNonReadyManifest(releaseId);
|
|
215
222
|
return null;
|
|
216
223
|
}
|
|
217
|
-
const
|
|
224
|
+
const manifestState = normalizeManifestState(result.state);
|
|
225
|
+
const manifest = isUsableManifestState(result.state) && result.manifest
|
|
218
226
|
? parseReleaseAssetManifest(result.manifest)
|
|
219
227
|
: null;
|
|
220
228
|
if (manifest) {
|
|
221
|
-
markManifestDecision("fetch_ready");
|
|
229
|
+
markManifestDecision(manifestState === "partial" ? "fetch_partial" : "fetch_ready");
|
|
222
230
|
const key = cacheKey(releaseId, manifest.manifestVersion);
|
|
223
231
|
manifestCache.set(key, {
|
|
224
232
|
manifest,
|
|
@@ -228,17 +236,16 @@ function fetchManifest(releaseId) {
|
|
|
228
236
|
logger.debug("Cached ready manifest", {
|
|
229
237
|
releaseId,
|
|
230
238
|
manifestVersion: manifest.manifestVersion,
|
|
239
|
+
state: result.state,
|
|
231
240
|
ttlMs: READY_TTL_MS,
|
|
232
241
|
refreshMs: READY_REVALIDATE_MS,
|
|
233
242
|
});
|
|
234
243
|
return manifest;
|
|
235
244
|
}
|
|
236
245
|
else {
|
|
246
|
+
markManifestDecision(`fetch_${manifestState}`);
|
|
237
247
|
markManifestDecision("fetch_not_ready");
|
|
238
|
-
|
|
239
|
-
manifest: null,
|
|
240
|
-
expiresAt: Date.now() + NON_READY_TTL_MS,
|
|
241
|
-
});
|
|
248
|
+
cacheNonReadyManifest(releaseId);
|
|
242
249
|
return null;
|
|
243
250
|
}
|
|
244
251
|
}
|
|
@@ -250,7 +257,7 @@ function fetchManifest(releaseId) {
|
|
|
250
257
|
if (fetchGeneration !== cacheGeneration)
|
|
251
258
|
return null;
|
|
252
259
|
markManifestDecision("fetch_failed");
|
|
253
|
-
|
|
260
|
+
cacheNonReadyManifest(releaseId);
|
|
254
261
|
return null;
|
|
255
262
|
}
|
|
256
263
|
finally {
|
|
@@ -263,6 +270,20 @@ function fetchManifest(releaseId) {
|
|
|
263
270
|
inFlight.set(releaseId, { generation: fetchGeneration, token, promise });
|
|
264
271
|
return promise;
|
|
265
272
|
}
|
|
273
|
+
function isUsableManifestState(state) {
|
|
274
|
+
return state === "ready" || state === "partial";
|
|
275
|
+
}
|
|
276
|
+
function normalizeManifestState(state) {
|
|
277
|
+
return state.toLowerCase().replace(/[^a-z0-9_]/g, "_").slice(0, 32) || "unknown";
|
|
278
|
+
}
|
|
279
|
+
function cacheNonReadyManifest(releaseId) {
|
|
280
|
+
const now = Date.now();
|
|
281
|
+
manifestCache.set(releaseId, {
|
|
282
|
+
manifest: null,
|
|
283
|
+
expiresAt: now + NON_READY_TTL_MS,
|
|
284
|
+
refreshAfter: now + NON_READY_REVALIDATE_MS,
|
|
285
|
+
});
|
|
286
|
+
}
|
|
266
287
|
/** Clear cached manifest bodies while keeping registered fetchers intact. */
|
|
267
288
|
export function clearCachedReleaseAssetManifests() {
|
|
268
289
|
cacheGeneration++;
|
|
@@ -8,17 +8,20 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @module release-assets/module-consumption
|
|
10
10
|
*/
|
|
11
|
+
import { type ReadyManifestReadOptions } from "./manifest-cache.js";
|
|
11
12
|
import type { ReleaseAssetManifest } from "./manifest-schema.js";
|
|
12
13
|
export interface RewriteReleaseDependencyImportsOptions {
|
|
13
14
|
releaseId?: string | null;
|
|
14
15
|
readDependencySource: (path: string) => Promise<string>;
|
|
15
16
|
manifest?: ReleaseAssetManifest | null;
|
|
17
|
+
manifestReadOptions?: ReadyManifestReadOptions;
|
|
16
18
|
}
|
|
17
19
|
export interface ReleaseDependencyRewriteManifestState {
|
|
18
20
|
enabled: boolean;
|
|
19
21
|
manifest: ReleaseAssetManifest | null;
|
|
20
22
|
}
|
|
21
23
|
export declare function isReleaseDependencyImportMapRewriteEnabled(): boolean;
|
|
22
|
-
export declare function
|
|
24
|
+
export declare function hasReleaseDependencyImportSpecifiers(code: string): Promise<boolean>;
|
|
25
|
+
export declare function getReleaseDependencyRewriteManifestState(releaseId: string | null | undefined, options?: ReadyManifestReadOptions): Promise<ReleaseDependencyRewriteManifestState>;
|
|
23
26
|
export declare function rewriteReleaseDependencyImportsForModule(code: string, options: RewriteReleaseDependencyImportsOptions): Promise<string>;
|
|
24
27
|
//# sourceMappingURL=module-consumption.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-consumption.d.ts","sourceRoot":"","sources":["../../../src/src/release-assets/module-consumption.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"module-consumption.d.ts","sourceRoot":"","sources":["../../../src/src/release-assets/module-consumption.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH,OAAO,EAAkC,KAAK,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AACpG,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,MAAM,WAAW,sCAAsC;IACrD,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,oBAAoB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACxD,QAAQ,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAAC;IACvC,mBAAmB,CAAC,EAAE,wBAAwB,CAAC;CAChD;AAED,MAAM,WAAW,qCAAqC;IACpD,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,oBAAoB,GAAG,IAAI,CAAC;CACvC;AAED,wBAAgB,0CAA0C,IAAI,OAAO,CAEpE;AAWD,wBAAsB,oCAAoC,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CASzF;AAED,wBAAsB,wCAAwC,CAC5D,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,qCAAqC,CAAC,CAShD;AAmDD,wBAAsB,wCAAwC,CAC5D,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,sCAAsC,GAC9C,OAAO,CAAC,MAAM,CAAC,CA6BjB"}
|
|
@@ -17,13 +17,33 @@ import { getReadyManifestForRenderAsync } from "./manifest-cache.js";
|
|
|
17
17
|
export function isReleaseDependencyImportMapRewriteEnabled() {
|
|
18
18
|
return getHostEnv(RELEASE_ASSET_DEPENDENCY_IMPORT_MAP_ENV_FLAG) === "1";
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
function isHttpImportSpecifier(specifier) {
|
|
21
|
+
try {
|
|
22
|
+
const url = new URL(specifier);
|
|
23
|
+
return url.protocol === "http:" || url.protocol === "https:";
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export async function hasReleaseDependencyImportSpecifiers(code) {
|
|
30
|
+
if (!code.includes("http") && !code.includes("veryfront-http-bundle"))
|
|
31
|
+
return false;
|
|
32
|
+
for (const imp of await parseImports(code)) {
|
|
33
|
+
if (!imp.n)
|
|
34
|
+
continue;
|
|
35
|
+
if (isHttpImportSpecifier(imp.n) || localHttpBundlePath(imp.n))
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
export async function getReleaseDependencyRewriteManifestState(releaseId, options = {}) {
|
|
21
41
|
if (!releaseId || !isReleaseDependencyImportMapRewriteEnabled()) {
|
|
22
42
|
return { enabled: false, manifest: null };
|
|
23
43
|
}
|
|
24
44
|
return {
|
|
25
45
|
enabled: true,
|
|
26
|
-
manifest: await getReadyManifestForRenderAsync(releaseId),
|
|
46
|
+
manifest: await getReadyManifestForRenderAsync(releaseId, options),
|
|
27
47
|
};
|
|
28
48
|
}
|
|
29
49
|
function dependencyAssetUrl(manifest, specifier) {
|
|
@@ -81,7 +101,7 @@ export async function rewriteReleaseDependencyImportsForModule(code, options) {
|
|
|
81
101
|
return code;
|
|
82
102
|
const manifest = options.manifest !== undefined
|
|
83
103
|
? options.manifest
|
|
84
|
-
: await getReadyManifestForRenderAsync(options.releaseId);
|
|
104
|
+
: await getReadyManifestForRenderAsync(options.releaseId, options.manifestReadOptions);
|
|
85
105
|
if (!manifest || Object.keys(manifest.dependencies).length === 0)
|
|
86
106
|
return code;
|
|
87
107
|
const replacements = new Map();
|