veryfront 0.1.754 → 0.1.755
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/cache/dependency-graph.d.ts +1 -0
- package/esm/src/cache/dependency-graph.d.ts.map +1 -1
- package/esm/src/cache/dependency-graph.js +7 -1
- package/esm/src/modules/server/module-batch-handler.d.ts.map +1 -1
- package/esm/src/modules/server/module-batch-handler.js +47 -35
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/index.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/index.js +17 -15
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/persistence.d.ts +34 -0
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/persistence.d.ts.map +1 -0
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/persistence.js +30 -0
- 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
|
@@ -21,6 +21,7 @@ export interface DependencyHashCache {
|
|
|
21
21
|
contentHashes: Map<string, string>;
|
|
22
22
|
completedModules: Set<string>;
|
|
23
23
|
inProgressModules: Map<string, Promise<void>>;
|
|
24
|
+
buildQueue: Promise<void>;
|
|
24
25
|
}
|
|
25
26
|
export declare function createDependencyHashCache(): DependencyHashCache;
|
|
26
27
|
export declare function extractImports(code: string): Promise<string[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependency-graph.d.ts","sourceRoot":"","sources":["../../../src/src/cache/dependency-graph.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,qBAAa,eAAe;IAC1B,OAAO,CAAC,YAAY,CAAkC;IACtD,OAAO,CAAC,UAAU,CAAkC;IAEpD,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,IAAI;IAczD,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE;IAIjD,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE;IAUrD,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE;IAUzC,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO;IAInD,KAAK,IAAI,IAAI;IAKb,aAAa,IAAI,MAAM,EAAE;IAIzB,OAAO,CAAC,WAAW;IAiBnB,OAAO,CAAC,uBAAuB;IAsB/B,OAAO,CAAC,iBAAiB;CAgB1B;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,eAAe,CAAC;IACvB,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9B,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"dependency-graph.d.ts","sourceRoot":"","sources":["../../../src/src/cache/dependency-graph.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,qBAAa,eAAe;IAC1B,OAAO,CAAC,YAAY,CAAkC;IACtD,OAAO,CAAC,UAAU,CAAkC;IAEpD,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,IAAI;IAczD,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE;IAIjD,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE;IAUrD,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE;IAUzC,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO;IAInD,KAAK,IAAI,IAAI;IAKb,aAAa,IAAI,MAAM,EAAE;IAIzB,OAAO,CAAC,WAAW;IAiBnB,OAAO,CAAC,uBAAuB;IAsB/B,OAAO,CAAC,iBAAiB;CAgB1B;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,eAAe,CAAC;IACvB,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9B,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9C,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B;AAED,wBAAgB,yBAAyB,IAAI,mBAAmB,CAQ/D;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAGpE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAWjE;AAED,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,GACjB,MAAM,CAsBR;AAMD,wBAAsB,eAAe,CACnC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,EAC7C,UAAU,EAAE,MAAM,EAClB,KAAK,GAAE,mBAAiD,GACvD,OAAO,CAAC,MAAM,CAAC,CAgBjB"}
|
|
@@ -85,6 +85,7 @@ export function createDependencyHashCache() {
|
|
|
85
85
|
contentHashes: new Map(),
|
|
86
86
|
completedModules: new Set(),
|
|
87
87
|
inProgressModules: new Map(),
|
|
88
|
+
buildQueue: Promise.resolve(),
|
|
88
89
|
};
|
|
89
90
|
}
|
|
90
91
|
export async function extractImports(code) {
|
|
@@ -129,7 +130,7 @@ function normalizeExtension(path) {
|
|
|
129
130
|
return path.replace(/\.(tsx?|jsx)$/, ".js");
|
|
130
131
|
}
|
|
131
132
|
export async function computeDepsHash(filePath, getContent, projectDir, cache = createDependencyHashCache()) {
|
|
132
|
-
await buildDependencyGraph(filePath, cache, getContent, projectDir);
|
|
133
|
+
await enqueueDependencyGraphBuild(cache, () => buildDependencyGraph(filePath, cache, getContent, projectDir));
|
|
133
134
|
const deps = [filePath, ...cache.graph.getTransitiveDependencies(filePath)].sort();
|
|
134
135
|
const combinedHash = deps
|
|
135
136
|
.map((dep) => cache.contentHashes.get(dep) ?? "")
|
|
@@ -137,6 +138,11 @@ export async function computeDepsHash(filePath, getContent, projectDir, cache =
|
|
|
137
138
|
.join(":");
|
|
138
139
|
return computeHash(combinedHash);
|
|
139
140
|
}
|
|
141
|
+
async function enqueueDependencyGraphBuild(cache, build) {
|
|
142
|
+
const queuedBuild = cache.buildQueue.then(build);
|
|
143
|
+
cache.buildQueue = queuedBuild.catch(() => { });
|
|
144
|
+
await queuedBuild;
|
|
145
|
+
}
|
|
140
146
|
async function buildDependencyGraph(filePath, cache, getContent, projectDir, visited = new Set()) {
|
|
141
147
|
if (cache.completedModules.has(filePath))
|
|
142
148
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-batch-handler.d.ts","sourceRoot":"","sources":["../../../../src/src/modules/server/module-batch-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AASH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAiGtE,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,cAAc,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC,CA6K/F;
|
|
1
|
+
{"version":3,"file":"module-batch-handler.d.ts","sourceRoot":"","sources":["../../../../src/src/modules/server/module-batch-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AASH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAiGtE,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,cAAc,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC,CA6K/F;AA2QD;;GAEG;AACH,wBAAgB,eAAe,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAc1D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CAKrE"}
|
|
@@ -179,7 +179,7 @@ export function handleModuleBatch(req, options) {
|
|
|
179
179
|
headers: { "Content-Type": "text/plain" },
|
|
180
180
|
});
|
|
181
181
|
}
|
|
182
|
-
const
|
|
182
|
+
const bundleStream = createBatchBundleStream(successes, failures);
|
|
183
183
|
const duration = performance.now() - startTime;
|
|
184
184
|
const isSlow = duration > SLOW_REQUEST_THRESHOLD_MS;
|
|
185
185
|
const logMethod = isSlow ? logger.warn.bind(logger) : logger.info.bind(logger);
|
|
@@ -202,7 +202,7 @@ export function handleModuleBatch(req, options) {
|
|
|
202
202
|
})),
|
|
203
203
|
});
|
|
204
204
|
}
|
|
205
|
-
return new Response(
|
|
205
|
+
return new Response(bundleStream, {
|
|
206
206
|
status: HTTP_OK,
|
|
207
207
|
headers: {
|
|
208
208
|
"Content-Type": "application/javascript; charset=utf-8",
|
|
@@ -336,50 +336,62 @@ function createBatchSSRTargetCacheBusterResolver(options) {
|
|
|
336
336
|
return promise;
|
|
337
337
|
};
|
|
338
338
|
}
|
|
339
|
+
function createBatchBundleStream(successes, failures) {
|
|
340
|
+
const encoder = new TextEncoder();
|
|
341
|
+
return new ReadableStream({
|
|
342
|
+
start(controller) {
|
|
343
|
+
let isFirstChunk = true;
|
|
344
|
+
for (const chunk of generateBatchBundleChunks(successes, failures)) {
|
|
345
|
+
if (!isFirstChunk)
|
|
346
|
+
controller.enqueue(encoder.encode("\n"));
|
|
347
|
+
controller.enqueue(encoder.encode(chunk));
|
|
348
|
+
isFirstChunk = false;
|
|
349
|
+
}
|
|
350
|
+
controller.close();
|
|
351
|
+
},
|
|
352
|
+
});
|
|
353
|
+
}
|
|
339
354
|
/**
|
|
340
|
-
* Generate the batch bundle code
|
|
341
|
-
* Creates a module that exports all loaded modules by path
|
|
355
|
+
* Generate the batch bundle code chunks.
|
|
356
|
+
* Creates a module that exports all loaded modules by path.
|
|
342
357
|
*/
|
|
343
|
-
function
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
"",
|
|
351
|
-
];
|
|
358
|
+
function* generateBatchBundleChunks(successes, failures) {
|
|
359
|
+
yield "// Veryfront Module Batch Bundle";
|
|
360
|
+
yield "// Generated: " + new Date().toISOString();
|
|
361
|
+
yield `// Modules: ${successes.length} loaded, ${failures.length} failed`;
|
|
362
|
+
yield "";
|
|
363
|
+
yield "const __vf_batch_modules = new Map();";
|
|
364
|
+
yield "";
|
|
352
365
|
for (let i = 0; i < successes.length; i++) {
|
|
353
366
|
const item = successes[i];
|
|
354
367
|
if (!item)
|
|
355
368
|
continue;
|
|
356
369
|
const { path, code } = item;
|
|
357
370
|
const varName = `__mod_${i}`;
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
371
|
+
yield `// Module: ${path}`;
|
|
372
|
+
yield `const ${varName} = await (async () => {`;
|
|
373
|
+
yield " const exports = {};";
|
|
374
|
+
yield " const module = { exports };";
|
|
375
|
+
yield " // --- Module code start ---";
|
|
376
|
+
yield transformExportsForBundle(code);
|
|
377
|
+
yield " // --- Module code end ---";
|
|
378
|
+
yield " return exports;";
|
|
379
|
+
yield "})();";
|
|
380
|
+
yield `__vf_batch_modules.set("${path}", ${varName});`;
|
|
381
|
+
yield "";
|
|
369
382
|
}
|
|
370
383
|
for (const { path, error } of failures) {
|
|
371
|
-
|
|
372
|
-
|
|
384
|
+
yield `// Failed: ${path} - ${error}`;
|
|
385
|
+
yield `__vf_batch_modules.set("${path}", { __vf_error: "${error}" });`;
|
|
373
386
|
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
return parts.join("\n");
|
|
387
|
+
yield "";
|
|
388
|
+
yield "export const batchModules = __vf_batch_modules;";
|
|
389
|
+
yield "";
|
|
390
|
+
yield "export function getModule(path) {";
|
|
391
|
+
yield " return __vf_batch_modules.get(path);";
|
|
392
|
+
yield "}";
|
|
393
|
+
yield "";
|
|
394
|
+
yield "export default { batchModules, getModule };";
|
|
383
395
|
}
|
|
384
396
|
/**
|
|
385
397
|
* Transform module code for inclusion in batch bundle
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/mdx/esm-module-loader/module-fetcher/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAG5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/mdx/esm-module-loader/module-fetcher/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAG5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAexD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAS9B;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,KAAK;gBACtC,cAAc,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAOtD;AAED;;GAEG;AACH,qBAAa,6BAA8B,SAAQ,KAAK;gBAC1C,SAAS,EAAE,MAAM;CAI9B;AAcD;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,oBAAoB,EAC7B,gBAAgB,CAAC,EAAE,MAAM,EACzB,OAAO,GAAE,GAAG,CAAC,MAAM,CAAa,GAC/B,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAwFxB;AA8JD;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,cAAc,EACvB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE;IACR,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,GACA,oBAAoB,CAUtB"}
|
|
@@ -20,10 +20,11 @@ import { resolveModuleFile } from "../resolution/file-finder.js";
|
|
|
20
20
|
import { buildMissingModuleError } from "../missing-module.js";
|
|
21
21
|
import { getTransformCacheKey, getVersionedPathCacheKey } from "./cache-keys.js";
|
|
22
22
|
import { resolveNestedModuleImports } from "./nested-imports.js";
|
|
23
|
-
import { readDistributedCache
|
|
23
|
+
import { readDistributedCache } from "./distributed-cache.js";
|
|
24
24
|
import { fetchModuleViaHTTP } from "./http-fetcher.js";
|
|
25
25
|
import { cacheModule, normalizePath } from "./module-cache.js";
|
|
26
26
|
import { readValidCachedModulePath } from "./path-cache-lookup.js";
|
|
27
|
+
import { persistResolvedModule } from "./persistence.js";
|
|
27
28
|
import { transformResolvedModuleSource } from "./source-transform.js";
|
|
28
29
|
// Re-export extracted modules for backward compatibility
|
|
29
30
|
export { rewriteDntImports } from "./import-rewriter.js";
|
|
@@ -219,23 +220,24 @@ async function doFetchAndCacheModule(normalizedPath, context, fetchAndCacheModul
|
|
|
219
220
|
fetchAndCacheModule: fetchAndCacheModuleFn,
|
|
220
221
|
log,
|
|
221
222
|
});
|
|
222
|
-
|
|
223
|
-
// This ensures other pods get fully-resolved code without /_vf_modules/ paths.
|
|
224
|
-
if (needsDistributedCacheWrite && distResult?.distributedCache && transformCacheKey) {
|
|
225
|
-
writeDistributedCache(distResult.distributedCache, transformCacheKey, projectId, contentSourceId, moduleCode, normalizedPath, log);
|
|
226
|
-
}
|
|
227
|
-
log.debug(`${LOG_PREFIX_MDX_LOADER} [fetchAndCacheModule] cacheModule START`, {
|
|
228
|
-
projectSlug,
|
|
223
|
+
return await persistResolvedModule({
|
|
229
224
|
normalizedPath,
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
225
|
+
moduleCode,
|
|
226
|
+
esmCacheDir,
|
|
227
|
+
pathCache,
|
|
228
|
+
log,
|
|
234
229
|
projectSlug,
|
|
235
|
-
|
|
236
|
-
|
|
230
|
+
reactVersion: effectiveReactVersion,
|
|
231
|
+
distributedCacheWrite: needsDistributedCacheWrite && distResult?.distributedCache && transformCacheKey &&
|
|
232
|
+
contentSourceId
|
|
233
|
+
? {
|
|
234
|
+
distributedCache: distResult.distributedCache,
|
|
235
|
+
transformCacheKey,
|
|
236
|
+
projectId,
|
|
237
|
+
contentSourceId,
|
|
238
|
+
}
|
|
239
|
+
: undefined,
|
|
237
240
|
});
|
|
238
|
-
return finalCachedPath;
|
|
239
241
|
}
|
|
240
242
|
catch (error) {
|
|
241
243
|
log.warn(`${LOG_PREFIX_MDX_LOADER} Failed to process ${normalizedPath}`, error);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Final persistence phase for the MDX ESM module fetcher.
|
|
3
|
+
*
|
|
4
|
+
* @module transforms/mdx/esm-module-loader/module-fetcher/persistence
|
|
5
|
+
*/
|
|
6
|
+
import type { Logger } from "../../../../utils/logger/logger.js";
|
|
7
|
+
import { cacheModule } from "./module-cache.js";
|
|
8
|
+
import { writeDistributedCache } from "./distributed-cache.js";
|
|
9
|
+
type CacheLocalModuleFn = typeof cacheModule;
|
|
10
|
+
type WriteDistributedCacheFn = typeof writeDistributedCache;
|
|
11
|
+
type DistributedCache = Parameters<WriteDistributedCacheFn>[0];
|
|
12
|
+
export interface PersistResolvedModuleInput {
|
|
13
|
+
normalizedPath: string;
|
|
14
|
+
moduleCode: string;
|
|
15
|
+
esmCacheDir: string;
|
|
16
|
+
pathCache: Map<string, string>;
|
|
17
|
+
log: Logger;
|
|
18
|
+
projectSlug: string;
|
|
19
|
+
reactVersion?: string;
|
|
20
|
+
distributedCacheWrite?: {
|
|
21
|
+
distributedCache: DistributedCache;
|
|
22
|
+
transformCacheKey: string;
|
|
23
|
+
projectId: string;
|
|
24
|
+
contentSourceId: string;
|
|
25
|
+
};
|
|
26
|
+
cacheLocalModule?: CacheLocalModuleFn;
|
|
27
|
+
writeToDistributedCache?: WriteDistributedCacheFn;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Persist fully resolved module code to distributed and local caches.
|
|
31
|
+
*/
|
|
32
|
+
export declare function persistResolvedModule(input: PersistResolvedModuleInput): Promise<string | null>;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=persistence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persistence.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/mdx/esm-module-loader/module-fetcher/persistence.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,KAAK,kBAAkB,GAAG,OAAO,WAAW,CAAC;AAC7C,KAAK,uBAAuB,GAAG,OAAO,qBAAqB,CAAC;AAC5D,KAAK,gBAAgB,GAAG,UAAU,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAAC;AAE/D,MAAM,WAAW,0BAA0B;IACzC,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qBAAqB,CAAC,EAAE;QACtB,gBAAgB,EAAE,gBAAgB,CAAC;QACnC,iBAAiB,EAAE,MAAM,CAAC;QAC1B,SAAS,EAAE,MAAM,CAAC;QAClB,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;IACF,gBAAgB,CAAC,EAAE,kBAAkB,CAAC;IACtC,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;CACnD;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,0BAA0B,GAChC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAoCxB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Final persistence phase for the MDX ESM module fetcher.
|
|
3
|
+
*
|
|
4
|
+
* @module transforms/mdx/esm-module-loader/module-fetcher/persistence
|
|
5
|
+
*/
|
|
6
|
+
import { LOG_PREFIX_MDX_LOADER } from "../constants.js";
|
|
7
|
+
import { cacheModule } from "./module-cache.js";
|
|
8
|
+
import { writeDistributedCache } from "./distributed-cache.js";
|
|
9
|
+
/**
|
|
10
|
+
* Persist fully resolved module code to distributed and local caches.
|
|
11
|
+
*/
|
|
12
|
+
export async function persistResolvedModule(input) {
|
|
13
|
+
const writeToDistributedCache = input.writeToDistributedCache ?? writeDistributedCache;
|
|
14
|
+
const cacheLocalModule = input.cacheLocalModule ?? cacheModule;
|
|
15
|
+
if (input.distributedCacheWrite) {
|
|
16
|
+
writeToDistributedCache(input.distributedCacheWrite.distributedCache, input.distributedCacheWrite.transformCacheKey, input.distributedCacheWrite.projectId, input.distributedCacheWrite.contentSourceId, input.moduleCode, input.normalizedPath, input.log);
|
|
17
|
+
}
|
|
18
|
+
input.log.debug(`${LOG_PREFIX_MDX_LOADER} [fetchAndCacheModule] cacheModule START`, {
|
|
19
|
+
projectSlug: input.projectSlug,
|
|
20
|
+
normalizedPath: input.normalizedPath,
|
|
21
|
+
});
|
|
22
|
+
const cacheStart = performance.now();
|
|
23
|
+
const finalCachedPath = await cacheLocalModule(input.normalizedPath, input.moduleCode, input.esmCacheDir, input.pathCache, input.log, input.reactVersion);
|
|
24
|
+
input.log.debug(`${LOG_PREFIX_MDX_LOADER} [fetchAndCacheModule] cacheModule DONE`, {
|
|
25
|
+
projectSlug: input.projectSlug,
|
|
26
|
+
normalizedPath: input.normalizedPath,
|
|
27
|
+
cacheMs: (performance.now() - cacheStart).toFixed(1),
|
|
28
|
+
});
|
|
29
|
+
return finalCachedPath;
|
|
30
|
+
}
|