veryfront 0.1.1143 → 0.1.1144
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/rendering/orchestrator/module-loader/module-transform-cache.d.ts +3 -2
- package/esm/src/rendering/orchestrator/module-loader/module-transform-cache.d.ts.map +1 -1
- package/esm/src/rendering/orchestrator/module-loader/module-transform-cache.js +32 -21
- package/esm/src/transforms/esm/transform-cache.d.ts +3 -1
- package/esm/src/transforms/esm/transform-cache.d.ts.map +1 -1
- package/esm/src/transforms/esm/transform-cache.js +26 -4
- package/esm/src/transforms/pipeline/index.d.ts.map +1 -1
- package/esm/src/transforms/pipeline/index.js +6 -17
- package/esm/src/transforms/pipeline/stages/ssr-vf-modules/transform.d.ts.map +1 -1
- package/esm/src/transforms/pipeline/stages/ssr-vf-modules/transform.js +18 -3
- package/esm/src/transforms/shared/framework-bundle-paths.d.ts +7 -0
- package/esm/src/transforms/shared/framework-bundle-paths.d.ts.map +1 -1
- package/esm/src/transforms/shared/framework-bundle-paths.js +14 -0
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +5 -5
package/esm/deno.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @module rendering/orchestrator/module-loader/module-transform-cache
|
|
5
5
|
*/
|
|
6
6
|
import type { RuntimeAdapter } from "../../../platform/adapters/base.js";
|
|
7
|
-
import { initializeTransformCache, setCachedTransformAsync } from "../../../transforms/esm/transform-cache.js";
|
|
7
|
+
import { initializeTransformCache, setCachedTransformAsync, type TransformCachedEntryValidator } from "../../../transforms/esm/transform-cache.js";
|
|
8
8
|
import { getHttpBundleCacheDir } from "../../../utils/cache-dir.js";
|
|
9
9
|
import type { TransformProgressListener } from "../../../transforms/progress.js";
|
|
10
10
|
/** Pattern to detect unresolved /_vf_modules/ imports that will fail at runtime. */
|
|
@@ -37,9 +37,10 @@ interface PipelineResult {
|
|
|
37
37
|
}
|
|
38
38
|
export interface ModuleTransformCacheDeps {
|
|
39
39
|
initializeTransformCache: typeof initializeTransformCache;
|
|
40
|
-
getOrComputeTransform: (key: string, compute: (reportProgress?: TransformProgressListener) => Promise<string>, ttlSeconds: number, onProgress?: TransformProgressListener, signal?: AbortSignal) => Promise<TransformCacheResult>;
|
|
40
|
+
getOrComputeTransform: (key: string, compute: (reportProgress?: TransformProgressListener) => Promise<string>, ttlSeconds: number, onProgress?: TransformProgressListener, signal?: AbortSignal, validateCachedEntry?: TransformCachedEntryValidator) => Promise<TransformCacheResult>;
|
|
41
41
|
transformToESM: (code: string, filePath: string, projectDir: string, adapter: RuntimeAdapter, options: TransformOptions) => Promise<string>;
|
|
42
42
|
validateCachedBundlesByManifestOrCode: (code: string, bundleManifestId: string | undefined, cacheDir: string) => Promise<BundleValidationResult>;
|
|
43
|
+
findMissingFrameworkBundlePaths: (code: string) => Promise<string[]>;
|
|
43
44
|
getHttpBundleCacheDir: typeof getHttpBundleCacheDir;
|
|
44
45
|
setCachedTransformAsync: typeof setCachedTransformAsync;
|
|
45
46
|
runPipeline: (code: string, filePath: string, projectDir: string, options: TransformOptions) => Promise<PipelineResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-transform-cache.d.ts","sourceRoot":"","sources":["../../../../../src/src/rendering/orchestrator/module-loader/module-transform-cache.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAIzE,OAAO,EAGL,wBAAwB,EACxB,uBAAuB,
|
|
1
|
+
{"version":3,"file":"module-transform-cache.d.ts","sourceRoot":"","sources":["../../../../../src/src/rendering/orchestrator/module-loader/module-transform-cache.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAIzE,OAAO,EAGL,wBAAwB,EACxB,uBAAuB,EACvB,KAA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../../../transforms/esm-transform.js";
|
|
9
9
|
import { generateCacheKey as generateTransformCacheKey, getOrComputeTransform, initializeTransformCache, setCachedTransformAsync, } from "../../../transforms/esm/transform-cache.js";
|
|
10
10
|
import { validateCachedBundlesByManifestOrCode } from "../../../transforms/esm/cached-bundle-validation.js";
|
|
11
|
+
import { exists } from "../../../platform/compat/fs.js";
|
|
12
|
+
import { findMissingFrameworkBundlePaths } from "../../../transforms/shared/framework-bundle-paths.js";
|
|
11
13
|
import { getHttpBundleCacheDir } from "../../../utils/cache-dir.js";
|
|
12
14
|
import { TRANSFORM_DISTRIBUTED_TTL_SEC } from "../../../utils/constants/cache.js";
|
|
13
15
|
import { REACT_DEFAULT_VERSION } from "../../../utils/constants/cdn.js";
|
|
@@ -19,6 +21,14 @@ const defaultDeps = {
|
|
|
19
21
|
getOrComputeTransform,
|
|
20
22
|
transformToESM,
|
|
21
23
|
validateCachedBundlesByManifestOrCode,
|
|
24
|
+
findMissingFrameworkBundlePaths: (code) => findMissingFrameworkBundlePaths(code, exists, {
|
|
25
|
+
onError: (path, error) => {
|
|
26
|
+
logger.error("Framework bundle validation error", {
|
|
27
|
+
path,
|
|
28
|
+
error: error instanceof Error ? error.message : String(error),
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
}),
|
|
22
32
|
getHttpBundleCacheDir,
|
|
23
33
|
setCachedTransformAsync,
|
|
24
34
|
runPipeline: async (code, filePath, projectDir, options) => {
|
|
@@ -26,6 +36,27 @@ const defaultDeps = {
|
|
|
26
36
|
return await runPipeline(code, filePath, projectDir, options);
|
|
27
37
|
},
|
|
28
38
|
};
|
|
39
|
+
function createCachedTransformValidator(filePath, deps) {
|
|
40
|
+
return async (entry) => {
|
|
41
|
+
const [httpValidation, missingFrameworkBundles] = await Promise.all([
|
|
42
|
+
deps.validateCachedBundlesByManifestOrCode(entry.code, entry.bundleManifestId, deps.getHttpBundleCacheDir()),
|
|
43
|
+
deps.findMissingFrameworkBundlePaths(entry.code),
|
|
44
|
+
]);
|
|
45
|
+
if (httpValidation.valid && missingFrameworkBundles.length === 0) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
logger.warn("Cached transform dependency validation failed, re-transforming", {
|
|
49
|
+
filePath,
|
|
50
|
+
manifestId: entry.bundleManifestId?.slice(0, 12),
|
|
51
|
+
failedHashes: httpValidation.failedHashes,
|
|
52
|
+
reason: httpValidation.valid ? "framework_bundle_missing" : httpValidation.reason,
|
|
53
|
+
source: httpValidation.valid ? "framework-bundles" : httpValidation.source,
|
|
54
|
+
missingFrameworkBundleCount: missingFrameworkBundles.length,
|
|
55
|
+
firstMissingFrameworkBundle: missingFrameworkBundles[0]?.split("/").pop(),
|
|
56
|
+
});
|
|
57
|
+
return false;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
29
60
|
/** Transform module source through the shared cache and stale-cache retry checks. */
|
|
30
61
|
export async function transformModuleCodeWithCache(input) {
|
|
31
62
|
const deps = input.deps ?? defaultDeps;
|
|
@@ -50,29 +81,9 @@ export async function transformModuleCodeWithCache(input) {
|
|
|
50
81
|
const transformResult = await deps.getOrComputeTransform(cacheKey, (reportProgress) => {
|
|
51
82
|
logger.debug("Transform cache miss, transforming", { filePath: input.filePath });
|
|
52
83
|
return deps.transformToESM(input.fileContent, input.filePath, input.projectDir, input.adapter, { ...transformOptions, onProgress: reportProgress });
|
|
53
|
-
}, ttlSeconds, input.onProgress, input.signal);
|
|
84
|
+
}, ttlSeconds, input.onProgress, input.signal, createCachedTransformValidator(input.filePath, deps));
|
|
54
85
|
input.signal?.throwIfAborted();
|
|
55
86
|
let transformedCode = transformResult.code;
|
|
56
|
-
if (transformResult.cacheHit) {
|
|
57
|
-
const validation = await deps.validateCachedBundlesByManifestOrCode(transformedCode, transformResult.bundleManifestId, deps.getHttpBundleCacheDir());
|
|
58
|
-
input.signal?.throwIfAborted();
|
|
59
|
-
if (!validation.valid) {
|
|
60
|
-
logger.warn("Cached HTTP bundle validation failed, re-transforming", {
|
|
61
|
-
filePath: input.filePath,
|
|
62
|
-
manifestId: transformResult.bundleManifestId?.slice(0, 12),
|
|
63
|
-
failedHashes: validation.failedHashes,
|
|
64
|
-
reason: validation.reason,
|
|
65
|
-
source: validation.source,
|
|
66
|
-
});
|
|
67
|
-
transformedCode = await deps.transformToESM(input.fileContent, input.filePath, input.projectDir, input.adapter, transformOptions);
|
|
68
|
-
deps.setCachedTransformAsync(cacheKey, transformedCode, contentHash, ttlSeconds).catch((error) => {
|
|
69
|
-
logger.debug("Failed to update transform cache after re-transform", {
|
|
70
|
-
filePath: input.filePath,
|
|
71
|
-
error,
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
87
|
// CRITICAL: Validate that no unresolved /_vf_modules/ imports remain after transform.
|
|
77
88
|
// These imports should have been resolved to file:// paths by ssrVfModulesPlugin.
|
|
78
89
|
// If they're still present, retry the transform bypassing all caches.
|
|
@@ -45,6 +45,8 @@ interface TransformCacheResult {
|
|
|
45
45
|
/** Whether this was a cache hit */
|
|
46
46
|
cacheHit: boolean;
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
/** Decide whether a cached transform is safe to reuse in the current runtime. */
|
|
49
|
+
export type TransformCachedEntryValidator = (entry: TransformCacheResult) => boolean | Promise<boolean>;
|
|
50
|
+
export declare function getOrComputeTransform(key: string, computeFn: (reportProgress?: TransformProgressListener) => Promise<string>, ttlSeconds?: number, onProgress?: TransformProgressListener, signal?: AbortSignal, validateCachedEntry?: TransformCachedEntryValidator): Promise<TransformCacheResult>;
|
|
49
51
|
export {};
|
|
50
52
|
//# sourceMappingURL=transform-cache.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-cache.d.ts","sourceRoot":"","sources":["../../../../src/src/transforms/esm/transform-cache.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,YAAY,EAIlB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EAEV,yBAAyB,EA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OAAO,CAAC,EAAE,eAAe,GACxB,MAAM,CAER;AAED,wBAAsB,uBAAuB,CAC3C,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAgC1C;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,mBAAmB,GAAG,SAAS,CAI/E;AAED,wBAAsB,uBAAuB,CAC3C,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,UAAU,GAAE,MAA4B,EACxC,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC,IAAI,CAAC,CAyBf;AAED,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,UAAU,GAAE,MAA4B,GACvC,IAAI,CAoBN;AAWD,wBAAgB,qBAAqB,IAAI,IAAI,CAI5C;AAED,wBAAsB,8BAA8B,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAKnF;AAED,UAAU,oBAAoB;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,qFAAqF;IACrF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mCAAmC;IACnC,QAAQ,EAAE,OAAO,CAAC;CACnB;
|
|
1
|
+
{"version":3,"file":"transform-cache.d.ts","sourceRoot":"","sources":["../../../../src/src/transforms/esm/transform-cache.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,YAAY,EAIlB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EAEV,yBAAyB,EAC1B,MAAM,gBAAgB,CAAC;AAMxB,eAAO,MAAM,kCAAkC,QAAa,CAAC;AAY7D,UAAU,mBAAmB;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,yEAAyE;IACzE,gBAAgB,CAAC,EAAE,MAAM,CAAC;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sB,uBAAuB,CAC3C,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,UAAU,GAAE,MAA4B,EACxC,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC,IAAI,CAAC,CAyBf;AAED,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,UAAU,GAAE,MAA4B,GACvC,IAAI,CAoBN;AAWD,wBAAgB,qBAAqB,IAAI,IAAI,CAI5C;AAED,wBAAsB,8BAA8B,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAKnF;AAED,UAAU,oBAAoB;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,qFAAqF;IACrF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mCAAmC;IACnC,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,iFAAiF;AACjF,MAAM,MAAM,6BAA6B,GAAG,CAC1C,KAAK,EAAE,oBAAoB,KACxB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AA0BhC,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,CAAC,cAAc,CAAC,EAAE,yBAAyB,KAAK,OAAO,CAAC,MAAM,CAAC,EAC1E,UAAU,GAAE,MAA4B,EACxC,UAAU,CAAC,EAAE,yBAAyB,EACtC,MAAM,CAAC,EAAE,WAAW,EACpB,mBAAmB,CAAC,EAAE,6BAA6B,GAClD,OAAO,CAAC,oBAAoB,CAAC,CAmG/B"}
|
|
@@ -305,7 +305,7 @@ function publishComputedTransform(key, code, ttlSeconds) {
|
|
|
305
305
|
logger.debug("Failed to cache computed transform", { key, error });
|
|
306
306
|
});
|
|
307
307
|
}
|
|
308
|
-
export async function getOrComputeTransform(key, computeFn, ttlSeconds = DEFAULT_TTL_SECONDS, onProgress, signal) {
|
|
308
|
+
export async function getOrComputeTransform(key, computeFn, ttlSeconds = DEFAULT_TTL_SECONDS, onProgress, signal, validateCachedEntry) {
|
|
309
309
|
signal?.throwIfAborted();
|
|
310
310
|
const flightRegistry = transformFlight;
|
|
311
311
|
if (!flightRegistry.has(key)) {
|
|
@@ -331,13 +331,35 @@ export async function getOrComputeTransform(key, computeFn, ttlSeconds = DEFAULT
|
|
|
331
331
|
// Fall through to recompute
|
|
332
332
|
}
|
|
333
333
|
else {
|
|
334
|
-
|
|
335
|
-
reportProgress({ phase: "transform-cache:hit" });
|
|
336
|
-
return {
|
|
334
|
+
const cacheEntry = {
|
|
337
335
|
code: cached.code,
|
|
338
336
|
bundleManifestId: cached.bundleManifestId,
|
|
339
337
|
cacheHit: true,
|
|
340
338
|
};
|
|
339
|
+
if (validateCachedEntry) {
|
|
340
|
+
reportProgress({ phase: "transform-cache:validating" });
|
|
341
|
+
}
|
|
342
|
+
let cacheEntryValid = true;
|
|
343
|
+
let cacheValidationError;
|
|
344
|
+
if (validateCachedEntry) {
|
|
345
|
+
try {
|
|
346
|
+
cacheEntryValid = await validateCachedEntry(cacheEntry);
|
|
347
|
+
}
|
|
348
|
+
catch (error) {
|
|
349
|
+
cacheEntryValid = false;
|
|
350
|
+
cacheValidationError = error instanceof Error ? error.message : String(error);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
if (cacheEntryValid) {
|
|
354
|
+
logger.debug("Cache hit", { key });
|
|
355
|
+
reportProgress({ phase: "transform-cache:hit" });
|
|
356
|
+
return cacheEntry;
|
|
357
|
+
}
|
|
358
|
+
logger.warn("Cached transform failed validation, recomputing", {
|
|
359
|
+
key: key.slice(-60),
|
|
360
|
+
...(cacheValidationError ? { error: cacheValidationError } : {}),
|
|
361
|
+
});
|
|
362
|
+
reportProgress({ phase: "transform-cache:invalidated" });
|
|
341
363
|
}
|
|
342
364
|
}
|
|
343
365
|
logger.debug("Cache miss, computing", { key });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/transforms/pipeline/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAYH,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAEhB,eAAe,EAChB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/transforms/pipeline/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAYH,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAEhB,eAAe,EAChB,MAAM,YAAY,CAAC;AAoHpB,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,gBAAgB,EACzB,MAAM,CAAC,EAAE,cAAc,GACtB,OAAO,CAAC,eAAe,CAAC,CA+I1B;AAqBD,wBAAsB,cAAc,CAClC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,MAAM,CAAC,CASjB;AAmCD,YAAY,EACV,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,SAAS,EACT,KAAK,EACL,KAAK,EACL,YAAY,GACb,MAAM,cAAc,CAAC"}
|
|
@@ -13,7 +13,7 @@ import { browserNodeBuiltinImportsPlugin, browserServerExportsStripPlugin, compi
|
|
|
13
13
|
import { createFileSystem, exists } from "../../platform/compat/fs.js";
|
|
14
14
|
import { getHttpBundleCacheDir } from "../../utils/cache-dir.js";
|
|
15
15
|
import { validateCachedBundlesByManifestOrCode } from "../esm/cached-bundle-validation.js";
|
|
16
|
-
import {
|
|
16
|
+
import { findMissingFrameworkBundlePaths } from "../shared/framework-bundle-paths.js";
|
|
17
17
|
const SSR_PIPELINE = [
|
|
18
18
|
parsePlugin,
|
|
19
19
|
compilePlugin,
|
|
@@ -61,30 +61,19 @@ async function validateFrameworkBundles(code, cacheKey) {
|
|
|
61
61
|
});
|
|
62
62
|
return false;
|
|
63
63
|
}
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const missing = [];
|
|
68
|
-
for (const path of bundlePaths) {
|
|
69
|
-
try {
|
|
70
|
-
if (!(await exists(path))) {
|
|
71
|
-
missing.push(path);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
rendererLogger.error("Framework bundle validation error", {
|
|
64
|
+
const missing = await findMissingFrameworkBundlePaths(code, exists, {
|
|
65
|
+
onError: (path, error) => {
|
|
66
|
+
logger.error("Framework bundle validation error", {
|
|
76
67
|
path,
|
|
77
68
|
error: error instanceof Error ? error.message : String(error),
|
|
78
69
|
});
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
70
|
+
},
|
|
71
|
+
});
|
|
82
72
|
if (missing.length === 0)
|
|
83
73
|
return true;
|
|
84
74
|
logger.debug("Framework bundle validation failed", {
|
|
85
75
|
cacheKey: cacheKey.slice(-40),
|
|
86
76
|
failedCount: missing.length,
|
|
87
|
-
totalBundles: bundlePaths.length,
|
|
88
77
|
firstMissing: missing[0]?.split("/").pop(),
|
|
89
78
|
});
|
|
90
79
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/pipeline/stages/ssr-vf-modules/transform.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAmBrE,OAAO,EASL,KAAK,gBAAgB,EAGtB,MAAM,gBAAgB,CAAC;AAoBxB;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAExD;
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/pipeline/stages/ssr-vf-modules/transform.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAmBrE,OAAO,EASL,KAAK,gBAAgB,EAGtB,MAAM,gBAAgB,CAAC;AAoBxB;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAExD;AAaD;;;;;;;;;;GAUG;AACH,wBAAsB,oBAAoB,CACxC,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,EAAE,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,GACtC,OAAO,CAAC,MAAM,CAAC,CA2BjB;AAgBD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AA8MhE;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,gBAAgB,EACrB,oBAAoB,UAAQ,EAC5B,KAAK,SAAI,GACR,OAAO,CAAC,MAAM,CAAC,CAsCjB;AAsQD;;;GAGG;AACH,wBAAsB,kCAAkC,CACtD,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,gBAAgB,GACpB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA2DxB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oCAAoC,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAElF;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,EAAE,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,EACvC,UAAU,CAAC,EAAE,gBAAgB,CAAC,YAAY,CAAC,GAC1C,OAAO,CAAC,MAAM,CAAC,CAOjB"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { stripJsonImportAttributes, upgradeImportAssertions, } from "../../../esm/import-attributes.js";
|
|
8
8
|
import { ESBUILD_SUPPORTED_FEATURES } from "../../../esm/transform-utils.js";
|
|
9
|
-
import { join } from "../../../../platform/compat/path/index.js";
|
|
9
|
+
import { fromFileUrl, join } from "../../../../platform/compat/path/index.js";
|
|
10
10
|
import denoConfig from "../../../../../deno.js";
|
|
11
11
|
import { rendererLogger as logger } from "../../../../utils/index.js";
|
|
12
12
|
import { IMPORT_RESOLUTION_ERROR } from "../../../../errors/index.js";
|
|
@@ -45,6 +45,14 @@ const CYCLE_PLACEHOLDER_PREFIX = "/* Cycle detected:";
|
|
|
45
45
|
export function isCyclePlaceholder(code) {
|
|
46
46
|
return code.startsWith(CYCLE_PLACEHOLDER_PREFIX);
|
|
47
47
|
}
|
|
48
|
+
async function cachedFileUrlExists(fileUrl, fs) {
|
|
49
|
+
try {
|
|
50
|
+
return (await fs.stat(fromFileUrl(fileUrl))).isFile;
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
48
56
|
/**
|
|
49
57
|
* Cache transformed framework code and return the file:// path.
|
|
50
58
|
*
|
|
@@ -509,8 +517,15 @@ export async function resolveAndTransformVeryfrontImport(specifier, ctx) {
|
|
|
509
517
|
const transformKey = buildFrameworkTransformCacheKey(`${specifier}:${sourcePath}`, ctx.reactVersion, ctx.projectDir, content);
|
|
510
518
|
const cached = veryfrontTransformCache.get(transformKey);
|
|
511
519
|
if (cached) {
|
|
512
|
-
|
|
513
|
-
|
|
520
|
+
if (await cachedFileUrlExists(cached, ctx.fs)) {
|
|
521
|
+
ctx.onProgress?.({ phase: "framework:specifier-cache-hit", filePath: sourcePath });
|
|
522
|
+
return cached;
|
|
523
|
+
}
|
|
524
|
+
logger.debug(`${LOG_PREFIX} Cached #veryfront file URL is missing, invalidating`, {
|
|
525
|
+
specifier,
|
|
526
|
+
sourcePath: sourcePath.slice(-60),
|
|
527
|
+
});
|
|
528
|
+
veryfrontTransformCache.delete(transformKey);
|
|
514
529
|
}
|
|
515
530
|
// Transform the dependency (recursively handles its own #veryfront/ imports)
|
|
516
531
|
const transformed = await transformFrameworkCode(content, sourcePath, ctx, false);
|
|
@@ -3,4 +3,11 @@
|
|
|
3
3
|
* These are generated by the SSR VF modules transform.
|
|
4
4
|
*/
|
|
5
5
|
export declare function extractFrameworkBundlePaths(code: string): string[];
|
|
6
|
+
type FrameworkBundleExists = (path: string) => boolean | Promise<boolean>;
|
|
7
|
+
interface FindMissingFrameworkBundlePathsOptions {
|
|
8
|
+
onError?: (path: string, error: unknown) => void;
|
|
9
|
+
}
|
|
10
|
+
/** Return framework bundle paths referenced by code that are missing locally. */
|
|
11
|
+
export declare function findMissingFrameworkBundlePaths(code: string, exists: FrameworkBundleExists, options?: FindMissingFrameworkBundlePathsOptions): Promise<string[]>;
|
|
12
|
+
export {};
|
|
6
13
|
//# sourceMappingURL=framework-bundle-paths.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"framework-bundle-paths.d.ts","sourceRoot":"","sources":["../../../../src/src/transforms/shared/framework-bundle-paths.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAIlE"}
|
|
1
|
+
{"version":3,"file":"framework-bundle-paths.d.ts","sourceRoot":"","sources":["../../../../src/src/transforms/shared/framework-bundle-paths.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAIlE;AAED,KAAK,qBAAqB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAE1E,UAAU,sCAAsC;IAC9C,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CAClD;AAED,iFAAiF;AACjF,wBAAsB,+BAA+B,CACnD,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,qBAAqB,EAC7B,OAAO,GAAE,sCAA2C,GACnD,OAAO,CAAC,MAAM,EAAE,CAAC,CAcnB"}
|
|
@@ -10,3 +10,17 @@ export function extractFrameworkBundlePaths(code) {
|
|
|
10
10
|
return [];
|
|
11
11
|
return [...new Set(matches.map((match) => match.replace(/^file:\/\//, "")))];
|
|
12
12
|
}
|
|
13
|
+
/** Return framework bundle paths referenced by code that are missing locally. */
|
|
14
|
+
export async function findMissingFrameworkBundlePaths(code, exists, options = {}) {
|
|
15
|
+
const bundlePaths = extractFrameworkBundlePaths(code);
|
|
16
|
+
const checkedPaths = await Promise.all(bundlePaths.map(async (path) => {
|
|
17
|
+
try {
|
|
18
|
+
return await exists(path) ? undefined : path;
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
options.onError?.(path, error);
|
|
22
|
+
return path;
|
|
23
|
+
}
|
|
24
|
+
}));
|
|
25
|
+
return checkedPaths.filter((path) => path !== undefined);
|
|
26
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "veryfront",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1144",
|
|
4
4
|
"description": "The simplest way to build AI-powered apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -332,10 +332,10 @@
|
|
|
332
332
|
"@types/react": "19.2.14",
|
|
333
333
|
"@types/react-dom": "19.2.3",
|
|
334
334
|
"ws": "8.21.0",
|
|
335
|
-
"@veryfront/ext-bundler-esbuild": "0.1.
|
|
336
|
-
"@veryfront/ext-content-mdx": "0.1.
|
|
337
|
-
"@veryfront/ext-css-tailwind": "0.1.
|
|
338
|
-
"@veryfront/ext-parser-babel": "0.1.
|
|
335
|
+
"@veryfront/ext-bundler-esbuild": "0.1.1144",
|
|
336
|
+
"@veryfront/ext-content-mdx": "0.1.1144",
|
|
337
|
+
"@veryfront/ext-css-tailwind": "0.1.1144",
|
|
338
|
+
"@veryfront/ext-parser-babel": "0.1.1144"
|
|
339
339
|
},
|
|
340
340
|
"devDependencies": {
|
|
341
341
|
"@types/node": "20.9.0"
|