veryfront 0.1.94 → 0.1.96
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/schemas/html.schema.d.ts +2 -2
- package/esm/src/modules/react-loader/ssr-module-loader/loader.d.ts.map +1 -1
- package/esm/src/modules/react-loader/ssr-module-loader/loader.js +32 -1
- package/esm/src/modules/react-loader/ssr-module-loader/ssr-cache-manager.d.ts.map +1 -1
- package/esm/src/modules/react-loader/ssr-module-loader/ssr-cache-manager.js +31 -2
- package/esm/src/modules/react-loader/ssr-module-loader/vf-module-resolver.d.ts.map +1 -1
- package/esm/src/modules/react-loader/ssr-module-loader/vf-module-resolver.js +1 -0
- package/esm/src/rendering/orchestrator/module-loader/index.d.ts.map +1 -1
- package/esm/src/rendering/orchestrator/module-loader/index.js +6 -1
- package/esm/src/server/handlers/dev/scripts/hmr-scripts.d.ts.map +1 -1
- package/esm/src/server/handlers/dev/scripts/hmr-scripts.js +1 -0
- package/esm/src/transforms/mdx/esm-module-loader/cache/index.d.ts +5 -1
- package/esm/src/transforms/mdx/esm-module-loader/cache/index.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/cache/index.js +18 -2
- package/esm/src/transforms/mdx/esm-module-loader/cache-format.d.ts +2 -1
- package/esm/src/transforms/mdx/esm-module-loader/cache-format.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/cache-format.js +12 -5
- package/esm/src/transforms/mdx/esm-module-loader/loader-helpers.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/loader-helpers.js +1 -0
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/cache-keys.d.ts +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/cache-keys.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/cache-keys.js +2 -2
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/dependency-recovery.d.ts +23 -0
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/dependency-recovery.d.ts.map +1 -0
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/dependency-recovery.js +112 -0
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/distributed-cache.d.ts +2 -2
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/distributed-cache.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/distributed-cache.js +33 -4
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/framework-validator.d.ts +6 -1
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/framework-validator.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/framework-validator.js +31 -1
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/index.d.ts +1 -0
- 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 +15 -6
- package/esm/src/transforms/mdx/esm-module-loader/types.d.ts +1 -0
- package/esm/src/transforms/mdx/esm-module-loader/types.d.ts.map +1 -1
- package/esm/src/utils/version.d.ts +1 -1
- package/esm/src/utils/version.js +1 -1
- package/package.json +1 -1
- package/src/deno.js +1 -1
- package/src/src/modules/react-loader/ssr-module-loader/loader.ts +34 -0
- package/src/src/modules/react-loader/ssr-module-loader/ssr-cache-manager.ts +34 -2
- package/src/src/modules/react-loader/ssr-module-loader/vf-module-resolver.ts +1 -0
- package/src/src/rendering/orchestrator/module-loader/index.ts +12 -1
- package/src/src/server/handlers/dev/scripts/hmr-scripts.ts +1 -0
- package/src/src/transforms/mdx/esm-module-loader/cache/index.ts +18 -1
- package/src/src/transforms/mdx/esm-module-loader/cache-format.ts +33 -1
- package/src/src/transforms/mdx/esm-module-loader/loader-helpers.ts +1 -0
- package/src/src/transforms/mdx/esm-module-loader/module-fetcher/cache-keys.ts +2 -1
- package/src/src/transforms/mdx/esm-module-loader/module-fetcher/dependency-recovery.ts +173 -0
- package/src/src/transforms/mdx/esm-module-loader/module-fetcher/distributed-cache.ts +43 -3
- package/src/src/transforms/mdx/esm-module-loader/module-fetcher/framework-validator.ts +37 -0
- package/src/src/transforms/mdx/esm-module-loader/module-fetcher/index.ts +26 -11
- package/src/src/transforms/mdx/esm-module-loader/types.ts +1 -0
- package/src/src/utils/version.ts +1 -1
|
@@ -18,6 +18,9 @@ import { getDistributedTransformBackend } from "../../../esm/transform-cache.js"
|
|
|
18
18
|
import { TRANSFORM_DISTRIBUTED_TTL_SEC } from "../../../../utils/constants/cache.js";
|
|
19
19
|
import { hasUnresolvedImports } from "./nested-imports.js";
|
|
20
20
|
import { findMissingFileDependenciesInCode, hasIncompatibleFrameworkPaths, } from "./framework-validator.js";
|
|
21
|
+
import { ensureMdxModuleDependencies } from "./dependency-recovery.js";
|
|
22
|
+
import { buildMdxEsmModuleFileName, buildMdxEsmModuleRecoveryCacheKey } from "../cache-format.js";
|
|
23
|
+
import { hashString } from "../utils/hash.js";
|
|
21
24
|
/** TTL for cached transforms (uses centralized config) */
|
|
22
25
|
const TRANSFORM_CACHE_TTL_SECONDS = TRANSFORM_DISTRIBUTED_TTL_SEC;
|
|
23
26
|
/**
|
|
@@ -34,7 +37,7 @@ const TRANSFORM_CACHE_TTL_SECONDS = TRANSFORM_DISTRIBUTED_TTL_SEC;
|
|
|
34
37
|
* Returns null only if no distributed cache backend is available.
|
|
35
38
|
* Otherwise returns `{ code, distributedCache }` where `code` may be null (cache miss).
|
|
36
39
|
*/
|
|
37
|
-
export async function readDistributedCache(transformCacheKey, normalizedPath, projectSlug, projectDir, reactVersion, log) {
|
|
40
|
+
export async function readDistributedCache(transformCacheKey, projectId, contentSourceId, normalizedPath, projectSlug, projectDir, reactVersion, log) {
|
|
38
41
|
const distributedCache = await getDistributedTransformBackend();
|
|
39
42
|
if (!distributedCache)
|
|
40
43
|
return null;
|
|
@@ -87,8 +90,23 @@ export async function readDistributedCache(transformCacheKey, normalizedPath, pr
|
|
|
87
90
|
// that don't exist on this machine.
|
|
88
91
|
if (moduleCode) {
|
|
89
92
|
const missingDeps = await findMissingFileDependenciesInCode(moduleCode, log);
|
|
90
|
-
if (missingDeps.length > 0) {
|
|
91
|
-
|
|
93
|
+
if (missingDeps.length > 0 && contentSourceId) {
|
|
94
|
+
const recovered = await ensureMdxModuleDependencies(moduleCode, {
|
|
95
|
+
distributedCache,
|
|
96
|
+
projectId,
|
|
97
|
+
contentSourceId,
|
|
98
|
+
log,
|
|
99
|
+
});
|
|
100
|
+
if (recovered.recovered.length > 0) {
|
|
101
|
+
log.debug(`${LOG_PREFIX_MDX_LOADER} Recovered missing vfmod dependencies from cache`, {
|
|
102
|
+
normalizedPath,
|
|
103
|
+
recovered: recovered.recovered.slice(0, 5),
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const unresolvedDeps = await findMissingFileDependenciesInCode(moduleCode, log);
|
|
108
|
+
if (unresolvedDeps.length > 0) {
|
|
109
|
+
log.warn(`${LOG_PREFIX_MDX_LOADER} Cached code has ${unresolvedDeps.length} missing file dependencies, invalidating`, { normalizedPath, missingDeps: unresolvedDeps.slice(0, 5) });
|
|
92
110
|
moduleCode = null;
|
|
93
111
|
}
|
|
94
112
|
}
|
|
@@ -127,7 +145,7 @@ export async function readDistributedCache(transformCacheKey, normalizedPath, pr
|
|
|
127
145
|
*
|
|
128
146
|
* This is fire-and-forget: errors are logged but do not propagate.
|
|
129
147
|
*/
|
|
130
|
-
export function writeDistributedCache(distributedCache, transformCacheKey, moduleCode, normalizedPath, log) {
|
|
148
|
+
export function writeDistributedCache(distributedCache, transformCacheKey, projectId, contentSourceId, moduleCode, normalizedPath, log) {
|
|
131
149
|
// Tokenize all cache paths for cross-environment portability
|
|
132
150
|
// Uses aggressive tokenization to catch paths from ANY environment (build server, other pods)
|
|
133
151
|
const portableCode = tokenizeAllVeryFrontPaths(moduleCode);
|
|
@@ -140,6 +158,17 @@ export function writeDistributedCache(distributedCache, transformCacheKey, modul
|
|
|
140
158
|
error,
|
|
141
159
|
});
|
|
142
160
|
});
|
|
161
|
+
const moduleFileName = buildMdxEsmModuleFileName(hashString(normalizedPath + moduleCode));
|
|
162
|
+
const moduleRecoveryKey = buildMdxEsmModuleRecoveryCacheKey(projectId, contentSourceId, moduleFileName);
|
|
163
|
+
distributedCache
|
|
164
|
+
.set(moduleRecoveryKey, portableCode, TRANSFORM_CACHE_TTL_SECONDS)
|
|
165
|
+
.catch((error) => {
|
|
166
|
+
log.debug(`${LOG_PREFIX_MDX_LOADER} Distributed vfmod recovery set failed`, {
|
|
167
|
+
normalizedPath,
|
|
168
|
+
moduleRecoveryKey,
|
|
169
|
+
error,
|
|
170
|
+
});
|
|
171
|
+
});
|
|
143
172
|
// Create and store bundle manifest companion key for atomic validation
|
|
144
173
|
const bundlePaths = extractHttpBundlePaths(moduleCode);
|
|
145
174
|
if (bundlePaths.length > 0) {
|
|
@@ -7,6 +7,10 @@
|
|
|
7
7
|
* @module transforms/mdx/esm-module-loader/module-fetcher/framework-validator
|
|
8
8
|
*/
|
|
9
9
|
import type { Logger } from "../../../../utils/logger/logger.js";
|
|
10
|
+
interface MdxRecoveryOptions {
|
|
11
|
+
projectId: string;
|
|
12
|
+
contentSourceId: string;
|
|
13
|
+
}
|
|
10
14
|
/**
|
|
11
15
|
* Check if cached code has file:// paths that are incompatible with this environment.
|
|
12
16
|
* Returns true if the cached code should be invalidated (has paths from a different environment).
|
|
@@ -29,5 +33,6 @@ export declare function hasIncompatibleFrameworkPaths(code: string, log: Logger)
|
|
|
29
33
|
* to vfmod modules that were created on a different pod/run with different hashes.
|
|
30
34
|
*/
|
|
31
35
|
export declare function findMissingFileDependenciesInCode(code: string, log: Logger): Promise<string[]>;
|
|
32
|
-
export declare function validateCachedModule(normalizedPath: string, cachedPath: string, cachedCode: string, log: Logger, pathCache: Map<string, string>, versionedKey: string): Promise<boolean>;
|
|
36
|
+
export declare function validateCachedModule(normalizedPath: string, cachedPath: string, cachedCode: string, log: Logger, pathCache: Map<string, string>, versionedKey: string, recoveryOptions?: MdxRecoveryOptions): Promise<boolean>;
|
|
37
|
+
export {};
|
|
33
38
|
//# sourceMappingURL=framework-validator.d.ts.map
|
package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/framework-validator.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"framework-validator.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/mdx/esm-module-loader/module-fetcher/framework-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"framework-validator.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/mdx/esm-module-loader/module-fetcher/framework-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AASjE,UAAU,kBAAkB;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,6BAA6B,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAqE/F;AAED;;;;;;GAMG;AACH,wBAAsB,iCAAiC,CACrD,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,MAAM,EAAE,CAAC,CA6BnB;AAYD,wBAAsB,oBAAoB,CACxC,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,YAAY,EAAE,MAAM,EACpB,eAAe,CAAC,EAAE,kBAAkB,GACnC,OAAO,CAAC,OAAO,CAAC,CAgFlB"}
|
|
@@ -12,6 +12,7 @@ import { getLocalFs } from "../cache/index.js";
|
|
|
12
12
|
import { extractHttpBundlePaths } from "../../../../modules/react-loader/ssr-module-loader/http-bundle-helpers.js";
|
|
13
13
|
import { ensureHttpBundlesExist } from "../../../esm/http-cache.js";
|
|
14
14
|
import { MDX_ESM_MJS_FILE_URL_PATTERN_SOURCE } from "../cache-format.js";
|
|
15
|
+
import { ensureMdxModuleDependencies } from "./dependency-recovery.js";
|
|
15
16
|
/**
|
|
16
17
|
* Check if cached code has file:// paths that are incompatible with this environment.
|
|
17
18
|
* Returns true if the cached code should be invalidated (has paths from a different environment).
|
|
@@ -133,7 +134,7 @@ function hasRawHttpImports(code) {
|
|
|
133
134
|
const httpImportPattern = /from\s+["'](https?:\/\/[^"']+)["']/gi;
|
|
134
135
|
return httpImportPattern.test(code);
|
|
135
136
|
}
|
|
136
|
-
export async function validateCachedModule(normalizedPath, cachedPath, cachedCode, log, pathCache, versionedKey) {
|
|
137
|
+
export async function validateCachedModule(normalizedPath, cachedPath, cachedCode, log, pathCache, versionedKey, recoveryOptions) {
|
|
137
138
|
// Reject caches with raw HTTP URLs - all modules should use file:// paths.
|
|
138
139
|
// This ensures consistency between compiled and non-compiled modes.
|
|
139
140
|
if (hasRawHttpImports(cachedCode)) {
|
|
@@ -164,6 +165,35 @@ export async function validateCachedModule(normalizedPath, cachedPath, cachedCod
|
|
|
164
165
|
return false;
|
|
165
166
|
}
|
|
166
167
|
}
|
|
168
|
+
if (recoveryOptions) {
|
|
169
|
+
const recovered = await ensureMdxModuleDependencies(cachedCode, {
|
|
170
|
+
...recoveryOptions,
|
|
171
|
+
log,
|
|
172
|
+
});
|
|
173
|
+
if (recovered.recovered.length > 0) {
|
|
174
|
+
log.debug(`${LOG_PREFIX_MDX_LOADER} Recovered cached module vfmod dependencies`, {
|
|
175
|
+
normalizedPath,
|
|
176
|
+
cachedPath,
|
|
177
|
+
recovered: recovered.recovered.slice(0, 5),
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const missingDeps = await findMissingFileDependenciesInCode(cachedCode, log);
|
|
182
|
+
if (missingDeps.length > 0) {
|
|
183
|
+
log.warn(`${LOG_PREFIX_MDX_LOADER} Cached module has missing vfmod dependencies`, {
|
|
184
|
+
normalizedPath,
|
|
185
|
+
cachedPath,
|
|
186
|
+
missingDeps: missingDeps.slice(0, 5),
|
|
187
|
+
});
|
|
188
|
+
pathCache.delete(versionedKey);
|
|
189
|
+
try {
|
|
190
|
+
await getLocalFs().remove(cachedPath);
|
|
191
|
+
}
|
|
192
|
+
catch (_) {
|
|
193
|
+
/* expected: cached file may already be removed */
|
|
194
|
+
}
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
167
197
|
if (!(await hasIncompatibleFrameworkPaths(cachedCode, log)))
|
|
168
198
|
return true;
|
|
169
199
|
log.warn(`${LOG_PREFIX_MDX_LOADER} Cached module has incompatible framework paths`, {
|
|
@@ -37,6 +37,7 @@ export declare function fetchAndCacheModule(modulePath: string, context: ModuleF
|
|
|
37
37
|
* Create a module fetcher context.
|
|
38
38
|
*/
|
|
39
39
|
export declare function createModuleFetcherContext(esmCacheDir: string, adapter: RuntimeAdapter, projectDir: string, projectId: string, options?: {
|
|
40
|
+
contentSourceId?: string;
|
|
40
41
|
isLocalProject?: boolean;
|
|
41
42
|
projectSlug?: string;
|
|
42
43
|
reactVersion?: string;
|
|
@@ -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;AAM5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAexD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAS5E;;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;
|
|
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;AAM5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAexD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAS5E;;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;AAqRD;;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"}
|
|
@@ -148,7 +148,7 @@ export async function fetchAndCacheModule(modulePath, context, parentModulePath,
|
|
|
148
148
|
*/
|
|
149
149
|
async function doFetchAndCacheModule(normalizedPath, context, fetchAndCacheModuleFn, projectSlug, parentModulePath) {
|
|
150
150
|
const log = getLog(context);
|
|
151
|
-
const { esmCacheDir, adapter, projectDir, projectId } = context;
|
|
151
|
+
const { esmCacheDir, adapter, projectDir, projectId, contentSourceId } = context;
|
|
152
152
|
const pathCache = await getModulePathCache(esmCacheDir);
|
|
153
153
|
const versionedKey = getVersionedPathCacheKey(normalizedPath);
|
|
154
154
|
const cachedPath = pathCache.get(versionedKey);
|
|
@@ -157,7 +157,12 @@ async function doFetchAndCacheModule(normalizedPath, context, fetchAndCacheModul
|
|
|
157
157
|
const stat = await getLocalFs().stat(cachedPath);
|
|
158
158
|
if (stat?.isFile) {
|
|
159
159
|
const cachedCode = await getLocalFs().readTextFile(cachedPath);
|
|
160
|
-
if (await validateCachedModule(normalizedPath, cachedPath, cachedCode, log, pathCache, versionedKey
|
|
160
|
+
if (await validateCachedModule(normalizedPath, cachedPath, cachedCode, log, pathCache, versionedKey, context.contentSourceId
|
|
161
|
+
? {
|
|
162
|
+
projectId: context.projectId,
|
|
163
|
+
contentSourceId: context.contentSourceId,
|
|
164
|
+
}
|
|
165
|
+
: undefined)) {
|
|
161
166
|
recordModuleToSession(normalizedPath);
|
|
162
167
|
return cachedPath;
|
|
163
168
|
}
|
|
@@ -186,13 +191,17 @@ async function doFetchAndCacheModule(normalizedPath, context, fetchAndCacheModul
|
|
|
186
191
|
}
|
|
187
192
|
const { sourceCode, actualFilePath } = resolved;
|
|
188
193
|
const contentHash = hashString(sourceCode);
|
|
189
|
-
const transformCacheKey =
|
|
194
|
+
const transformCacheKey = contentSourceId
|
|
195
|
+
? getTransformCacheKey(projectId, contentSourceId, normalizedPath, contentHash)
|
|
196
|
+
: null;
|
|
190
197
|
let moduleCode = null;
|
|
191
198
|
let needsDistributedCacheWrite = false;
|
|
192
199
|
// Try distributed cache read with full validation.
|
|
193
200
|
// Returns null only if no distributed backend is configured.
|
|
194
201
|
// Otherwise returns { code, distributedCache } where code may be null (miss).
|
|
195
|
-
const distResult =
|
|
202
|
+
const distResult = transformCacheKey
|
|
203
|
+
? await readDistributedCache(transformCacheKey, projectId, contentSourceId, normalizedPath, projectSlug, projectDir, context.reactVersion, log)
|
|
204
|
+
: null;
|
|
196
205
|
if (distResult?.code) {
|
|
197
206
|
moduleCode = distResult.code;
|
|
198
207
|
}
|
|
@@ -299,8 +308,8 @@ async function doFetchAndCacheModule(normalizedPath, context, fetchAndCacheModul
|
|
|
299
308
|
moduleCode = await processNestedImports(moduleCode, relativeResults, esmCacheDir, context.strictMissingModules ?? true, normalizedPath, projectSlug);
|
|
300
309
|
// Write to distributed cache AFTER nested imports are resolved.
|
|
301
310
|
// This ensures other pods get fully-resolved code without /_vf_modules/ paths.
|
|
302
|
-
if (needsDistributedCacheWrite && distResult?.distributedCache) {
|
|
303
|
-
writeDistributedCache(distResult.distributedCache, transformCacheKey, moduleCode, normalizedPath, log);
|
|
311
|
+
if (needsDistributedCacheWrite && distResult?.distributedCache && transformCacheKey) {
|
|
312
|
+
writeDistributedCache(distResult.distributedCache, transformCacheKey, projectId, contentSourceId, moduleCode, normalizedPath, log);
|
|
304
313
|
}
|
|
305
314
|
log.debug(`${LOG_PREFIX_MDX_LOADER} [fetchAndCacheModule] cacheModule START`, {
|
|
306
315
|
projectSlug,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/src/transforms/mdx/esm-module-loader/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,WAAW,gBAAgB;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACzC,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,UAAU,CAAC,CAAC;IACrD,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtE,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrE,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC,CAAC;IACzD,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC9C;AAaD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,cAAc,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;OAIG;IACH,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;IACtD,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qFAAqF;IACrF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/src/transforms/mdx/esm-module-loader/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,WAAW,gBAAgB;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACzC,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,UAAU,CAAC,CAAC;IACrD,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtE,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrE,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC,CAAC;IACzD,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC9C;AAaD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,cAAc,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;OAIG;IACH,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;IACtD,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qFAAqF;IACrF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const VERSION = "0.1.
|
|
1
|
+
export declare const VERSION = "0.1.96";
|
|
2
2
|
export declare function normalizeVeryfrontVersion(version: string | undefined): string | undefined;
|
|
3
3
|
export declare function resolveRuntimeVersion(options?: {
|
|
4
4
|
veryfrontVersion?: string;
|
package/esm/src/utils/version.js
CHANGED
|
@@ -2,7 +2,7 @@ import denoConfig from "../../deno.js";
|
|
|
2
2
|
import { getEnv } from "../platform/compat/process.js";
|
|
3
3
|
// Keep in sync with deno.json version.
|
|
4
4
|
// scripts/release.ts updates this constant during releases.
|
|
5
|
-
export const VERSION = "0.1.
|
|
5
|
+
export const VERSION = "0.1.96";
|
|
6
6
|
export function normalizeVeryfrontVersion(version) {
|
|
7
7
|
if (!version)
|
|
8
8
|
return undefined;
|
package/package.json
CHANGED
package/src/deno.js
CHANGED
|
@@ -54,6 +54,7 @@ import { preflightLocalImports } from "./preflight-imports.js";
|
|
|
54
54
|
import { resolveVfModuleImports } from "./vf-module-resolver.js";
|
|
55
55
|
import { registerCSSImport } from "../css-import-collector.js";
|
|
56
56
|
import { injectNodePositions } from "../../../transforms/plugins/babel-node-positions.js";
|
|
57
|
+
import { ensureMdxModuleDependencies } from "../../../transforms/mdx/esm-module-loader/module-fetcher/dependency-recovery.js";
|
|
57
58
|
|
|
58
59
|
const logger = rendererLogger.component("ssr-module-loader");
|
|
59
60
|
|
|
@@ -230,6 +231,35 @@ export class SSRModuleLoader {
|
|
|
230
231
|
}
|
|
231
232
|
|
|
232
233
|
if (classifiedError.type === "module-not-found") {
|
|
234
|
+
if (this.options.contentSourceId) {
|
|
235
|
+
try {
|
|
236
|
+
const cachedCode = await this.cache.getFs().readTextFile(cacheEntry.tempPath);
|
|
237
|
+
const recovered = await ensureMdxModuleDependencies(cachedCode, {
|
|
238
|
+
projectId: this.options.projectId,
|
|
239
|
+
contentSourceId: this.options.contentSourceId,
|
|
240
|
+
log: logger,
|
|
241
|
+
});
|
|
242
|
+
if (recovered.missing.length === 0 && recovered.recovered.length > 0) {
|
|
243
|
+
const retryTempPath = cacheEntry.tempPath.replace(/\.mjs$/, "") +
|
|
244
|
+
`-recovered-${cacheEntry.contentHash}.mjs`;
|
|
245
|
+
await this.cache.getFs().writeTextFile(retryTempPath, cachedCode);
|
|
246
|
+
logger.info("Recovered vfmod dependencies for cached SSR module, retrying import", {
|
|
247
|
+
file: filePath.slice(-40),
|
|
248
|
+
recovered: recovered.recovered.slice(0, 5),
|
|
249
|
+
retryTempPath,
|
|
250
|
+
});
|
|
251
|
+
return (await import(
|
|
252
|
+
`file://${retryTempPath}?v=${cacheEntry.contentHash}&retry=1`
|
|
253
|
+
)) as Record<string, unknown>;
|
|
254
|
+
}
|
|
255
|
+
} catch (recoveryError) {
|
|
256
|
+
logger.debug("Failed to recover vfmod dependencies for cached SSR module", {
|
|
257
|
+
file: filePath.slice(-40),
|
|
258
|
+
error: recoveryError instanceof Error ? recoveryError.message : String(recoveryError),
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
233
263
|
logger.error(
|
|
234
264
|
"[SSR-MODULE-LOADER] Cached module has missing dependency, invalidating cache",
|
|
235
265
|
{
|
|
@@ -426,6 +456,10 @@ export class SSRModuleLoader {
|
|
|
426
456
|
mdxCacheDir,
|
|
427
457
|
this.options.projectDir,
|
|
428
458
|
contentHash,
|
|
459
|
+
{
|
|
460
|
+
projectId: this.options.projectId,
|
|
461
|
+
contentSourceId: this.options.contentSourceId,
|
|
462
|
+
},
|
|
429
463
|
);
|
|
430
464
|
|
|
431
465
|
if (mdxCacheResult.status === "hit") {
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
} from "./http-bundle-helpers.js";
|
|
27
27
|
import { buildTempModulePath, buildTmpDirPath, getTmpDirCacheKey } from "./tmp-paths.js";
|
|
28
28
|
import type { ModuleCacheEntry, SSRModuleLoaderOptions } from "./types.js";
|
|
29
|
+
import { ensureMdxModuleDependencies } from "../../../transforms/mdx/esm-module-loader/module-fetcher/dependency-recovery.js";
|
|
29
30
|
|
|
30
31
|
const logger = rendererLogger.component("ssr-module-loader");
|
|
31
32
|
|
|
@@ -169,7 +170,7 @@ export class SSRCacheManager {
|
|
|
169
170
|
try {
|
|
170
171
|
const cachedCode = await this.fs.readTextFile(cachedEntry.tempPath);
|
|
171
172
|
const isValid = await this.validateCachedCode(cachedCode, filePath, "memory-cache", {
|
|
172
|
-
checkLocalPaths:
|
|
173
|
+
checkLocalPaths: true,
|
|
173
174
|
checkInvalidEsmShPath: false,
|
|
174
175
|
});
|
|
175
176
|
if (!isValid) {
|
|
@@ -237,11 +238,14 @@ export class SSRCacheManager {
|
|
|
237
238
|
|
|
238
239
|
private async hasMissingLocalPaths(code: string, filePath: string): Promise<boolean> {
|
|
239
240
|
const allPaths = extractAllFilePaths(code);
|
|
241
|
+
let hasMissingPath = false;
|
|
242
|
+
|
|
240
243
|
for (const path of allPaths) {
|
|
241
244
|
try {
|
|
242
245
|
const stat = await this.fs.stat(path);
|
|
243
246
|
if (!stat.isFile) {
|
|
244
|
-
|
|
247
|
+
hasMissingPath = true;
|
|
248
|
+
break;
|
|
245
249
|
}
|
|
246
250
|
} catch (error) {
|
|
247
251
|
logger.debug("Redis cache has invalid local path, re-transforming", {
|
|
@@ -249,6 +253,34 @@ export class SSRCacheManager {
|
|
|
249
253
|
missingPath: path.slice(-60),
|
|
250
254
|
error,
|
|
251
255
|
});
|
|
256
|
+
hasMissingPath = true;
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (
|
|
262
|
+
hasMissingPath &&
|
|
263
|
+
this.options.projectId &&
|
|
264
|
+
this.options.contentSourceId
|
|
265
|
+
) {
|
|
266
|
+
const recovered = await ensureMdxModuleDependencies(code, {
|
|
267
|
+
projectId: this.options.projectId,
|
|
268
|
+
contentSourceId: this.options.contentSourceId,
|
|
269
|
+
log: logger,
|
|
270
|
+
});
|
|
271
|
+
if (recovered.recovered.length > 0) {
|
|
272
|
+
logger.debug("Recovered missing local vfmod dependencies for SSR cache entry", {
|
|
273
|
+
file: filePath.slice(-40),
|
|
274
|
+
recovered: recovered.recovered.slice(0, 5),
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
for (const path of allPaths) {
|
|
280
|
+
try {
|
|
281
|
+
const stat = await this.fs.stat(path);
|
|
282
|
+
if (!stat.isFile) return true;
|
|
283
|
+
} catch (_) {
|
|
252
284
|
return true;
|
|
253
285
|
}
|
|
254
286
|
}
|
|
@@ -223,7 +223,18 @@ export async function transformModuleWithDeps(
|
|
|
223
223
|
const sourceKey = encodeURIComponent(contentSourceId);
|
|
224
224
|
const mdxCacheDir = join(baseCacheDir, projectKey, sourceKey);
|
|
225
225
|
|
|
226
|
-
const mdxCacheResult = await lookupMdxEsmCache(
|
|
226
|
+
const mdxCacheResult = await lookupMdxEsmCache(
|
|
227
|
+
filePath,
|
|
228
|
+
mdxCacheDir,
|
|
229
|
+
projectDir,
|
|
230
|
+
undefined,
|
|
231
|
+
contentSourceId
|
|
232
|
+
? {
|
|
233
|
+
projectId,
|
|
234
|
+
contentSourceId,
|
|
235
|
+
}
|
|
236
|
+
: undefined,
|
|
237
|
+
);
|
|
227
238
|
if (mdxCacheResult.status === "hit") {
|
|
228
239
|
moduleCache.set(cacheKey, mdxCacheResult.path);
|
|
229
240
|
return mdxCacheResult.path;
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
import { LOG_PREFIX_MDX_LOADER } from "../constants.js";
|
|
22
22
|
import { LRUCache } from "../../../../utils/lru-wrapper.js";
|
|
23
23
|
import { buildMdxEsmPathCacheKey, MDX_ESM_ALL_FILE_URL_PATTERN_SOURCE } from "../cache-format.js";
|
|
24
|
+
import { ensureMdxModuleDependencies } from "../module-fetcher/dependency-recovery.js";
|
|
24
25
|
|
|
25
26
|
export type CacheLookupResult =
|
|
26
27
|
| { status: "hit"; path: string }
|
|
@@ -341,6 +342,7 @@ export async function lookupMdxEsmCache(
|
|
|
341
342
|
cacheDir: string,
|
|
342
343
|
projectDir?: string,
|
|
343
344
|
_contentHash?: string, // Intentionally unused - kept for API compatibility
|
|
345
|
+
recoveryOptions?: { projectId: string; contentSourceId: string },
|
|
344
346
|
): Promise<CacheLookupResult> {
|
|
345
347
|
const cache = await getModulePathCache(cacheDir);
|
|
346
348
|
const cacheKey = toMdxEsmCacheKey(filePath, projectDir);
|
|
@@ -408,7 +410,22 @@ export async function lookupMdxEsmCache(
|
|
|
408
410
|
// CRITICAL: Check that all file:// dependencies actually exist on disk.
|
|
409
411
|
// The distributed cache may contain code referencing file:// paths from other pods
|
|
410
412
|
// that don't exist locally (e.g., HTTP bundles, MDX-ESM modules).
|
|
411
|
-
|
|
413
|
+
let missingDeps = await findMissingFileDependencies(cachedCode);
|
|
414
|
+
if (missingDeps.length > 0 && recoveryOptions) {
|
|
415
|
+
const recovered = await ensureMdxModuleDependencies(cachedCode, {
|
|
416
|
+
...recoveryOptions,
|
|
417
|
+
log: logger,
|
|
418
|
+
});
|
|
419
|
+
if (recovered.recovered.length > 0) {
|
|
420
|
+
logger.debug(`${LOG_PREFIX_MDX_LOADER} Recovered cached MDX-ESM dependencies`, {
|
|
421
|
+
filePath,
|
|
422
|
+
cachedPath,
|
|
423
|
+
recovered: recovered.recovered.slice(0, 5),
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
missingDeps = await findMissingFileDependencies(cachedCode);
|
|
427
|
+
}
|
|
428
|
+
|
|
412
429
|
if (missingDeps.length > 0) {
|
|
413
430
|
logger.warn(
|
|
414
431
|
`${LOG_PREFIX_MDX_LOADER} Cached module has ${missingDeps.length} missing file dependencies, invalidating`,
|
|
@@ -10,10 +10,11 @@ const CACHE_NAMESPACE_SENTINEL = "__vf_cache_namespace__";
|
|
|
10
10
|
function formatMdxEsmTransformCacheKey(
|
|
11
11
|
namespace: string,
|
|
12
12
|
projectId: string,
|
|
13
|
+
contentSourceId: string,
|
|
13
14
|
normalizedPath: string,
|
|
14
15
|
contentHash: string,
|
|
15
16
|
): string {
|
|
16
|
-
return `${namespace}:${projectId}:${normalizedPath}:${contentHash}:ssr`;
|
|
17
|
+
return `${namespace}:${projectId}:${contentSourceId}:${normalizedPath}:${contentHash}:ssr`;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
function formatMdxEsmPathCacheKey(namespace: string, normalizedPath: string): string {
|
|
@@ -24,6 +25,15 @@ function formatMdxEsmModuleFileName(namespace: string, contentHash: string): str
|
|
|
24
25
|
return `vfmod-${namespace}-${contentHash}.mjs`;
|
|
25
26
|
}
|
|
26
27
|
|
|
28
|
+
function formatMdxEsmModuleRecoveryCacheKey(
|
|
29
|
+
namespace: string,
|
|
30
|
+
projectId: string,
|
|
31
|
+
contentSourceId: string,
|
|
32
|
+
fileName: string,
|
|
33
|
+
): string {
|
|
34
|
+
return `${namespace}:${projectId}:${contentSourceId}:${fileName}:vfmod`;
|
|
35
|
+
}
|
|
36
|
+
|
|
27
37
|
function formatMdxJsxCacheFileName(namespace: string, filePath: string): string {
|
|
28
38
|
return `jsx-${namespace}-${hashString(filePath)}.mjs`;
|
|
29
39
|
}
|
|
@@ -42,11 +52,18 @@ function buildMdxEsmCacheSchemaSample() {
|
|
|
42
52
|
transformKey: formatMdxEsmTransformCacheKey(
|
|
43
53
|
CACHE_NAMESPACE_SENTINEL,
|
|
44
54
|
"__vf_project__",
|
|
55
|
+
"preview-main",
|
|
45
56
|
"_vf_modules/pages/index.js",
|
|
46
57
|
"deadbeef",
|
|
47
58
|
),
|
|
48
59
|
pathKey: formatMdxEsmPathCacheKey(CACHE_NAMESPACE_SENTINEL, "_vf_modules/pages/index.js"),
|
|
49
60
|
moduleFile: formatMdxEsmModuleFileName(CACHE_NAMESPACE_SENTINEL, "deadbeef"),
|
|
61
|
+
moduleRecoveryKey: formatMdxEsmModuleRecoveryCacheKey(
|
|
62
|
+
CACHE_NAMESPACE_SENTINEL,
|
|
63
|
+
"__vf_project__",
|
|
64
|
+
"preview-main",
|
|
65
|
+
formatMdxEsmModuleFileName(CACHE_NAMESPACE_SENTINEL, "deadbeef"),
|
|
66
|
+
),
|
|
50
67
|
jsxFile: formatMdxJsxCacheFileName(CACHE_NAMESPACE_SENTINEL, "/tmp/project/Button.tsx"),
|
|
51
68
|
unresolvedVfModulesPattern: UNRESOLVED_VF_MODULES_PATTERN.source,
|
|
52
69
|
allFileUrlPattern: ALL_FILE_URL_PATTERN_SOURCE,
|
|
@@ -84,12 +101,14 @@ export const FRAMEWORK_VF_MODULE_CACHE_NAMESPACE = createCacheNamespace(
|
|
|
84
101
|
|
|
85
102
|
export function buildMdxEsmTransformCacheKey(
|
|
86
103
|
projectId: string,
|
|
104
|
+
contentSourceId: string,
|
|
87
105
|
normalizedPath: string,
|
|
88
106
|
contentHash: string,
|
|
89
107
|
): string {
|
|
90
108
|
return formatMdxEsmTransformCacheKey(
|
|
91
109
|
MDX_ESM_CACHE_NAMESPACE,
|
|
92
110
|
projectId,
|
|
111
|
+
contentSourceId,
|
|
93
112
|
normalizedPath,
|
|
94
113
|
contentHash,
|
|
95
114
|
);
|
|
@@ -103,6 +122,19 @@ export function buildMdxEsmModuleFileName(contentHash: string): string {
|
|
|
103
122
|
return formatMdxEsmModuleFileName(MDX_ESM_CACHE_NAMESPACE, contentHash);
|
|
104
123
|
}
|
|
105
124
|
|
|
125
|
+
export function buildMdxEsmModuleRecoveryCacheKey(
|
|
126
|
+
projectId: string,
|
|
127
|
+
contentSourceId: string,
|
|
128
|
+
fileName: string,
|
|
129
|
+
): string {
|
|
130
|
+
return formatMdxEsmModuleRecoveryCacheKey(
|
|
131
|
+
MDX_ESM_CACHE_NAMESPACE,
|
|
132
|
+
projectId,
|
|
133
|
+
contentSourceId,
|
|
134
|
+
fileName,
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
106
138
|
export function buildMdxJsxCacheFileName(filePath: string): string {
|
|
107
139
|
return formatMdxJsxCacheFileName(MDX_ESM_CACHE_NAMESPACE, filePath);
|
|
108
140
|
}
|
|
@@ -15,10 +15,11 @@ import { buildMdxEsmPathCacheKey, buildMdxEsmTransformCacheKey } from "../cache-
|
|
|
15
15
|
*/
|
|
16
16
|
export function getTransformCacheKey(
|
|
17
17
|
projectId: string,
|
|
18
|
+
contentSourceId: string,
|
|
18
19
|
normalizedPath: string,
|
|
19
20
|
contentHash: string,
|
|
20
21
|
): string {
|
|
21
|
-
return buildMdxEsmTransformCacheKey(projectId, normalizedPath, contentHash);
|
|
22
|
+
return buildMdxEsmTransformCacheKey(projectId, contentSourceId, normalizedPath, contentHash);
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
export function getVersionedPathCacheKey(normalizedPath: string): string {
|