veryfront 0.1.736 → 0.1.738

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.1.736",
3
+ "version": "0.1.738",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "minimumDependencyAge": "P2D",
@@ -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;AAO5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAcxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAS9F;;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;AAiRD;;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"}
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;AAcxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAS9F;;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;AA6KD;;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"}
@@ -12,10 +12,6 @@
12
12
  * @module build/transforms/mdx/esm-module-loader/module-fetcher
13
13
  */
14
14
  import { rendererLogger as globalLogger } from "../../../../utils/index.js";
15
- import { transformToESM } from "../../../esm-transform.js";
16
- import { cacheHttpImportsToLocal } from "../../../esm/http-cache.js";
17
- import { loadImportMap } from "../../../../modules/import-map/index.js";
18
- import { getHttpBundleCacheDir } from "../../../../utils/cache-dir.js";
19
15
  import { REACT_DEFAULT_VERSION } from "../../../../utils/constants/cdn.js";
20
16
  import { LOG_PREFIX_MDX_LOADER } from "../constants.js";
21
17
  import { getModulePathCache } from "../cache/index.js";
@@ -23,12 +19,12 @@ import { hashString } from "../utils/hash.js";
23
19
  import { resolveModuleFile } from "../resolution/file-finder.js";
24
20
  import { buildMissingModuleError } from "../missing-module.js";
25
21
  import { getTransformCacheKey, getVersionedPathCacheKey } from "./cache-keys.js";
26
- import { rewriteDntImports, rewriteVeryfrontImports } from "./import-rewriter.js";
27
- import { findNestedImports, processNestedImports } from "./nested-imports.js";
22
+ import { resolveNestedModuleImports } from "./nested-imports.js";
28
23
  import { readDistributedCache, writeDistributedCache } from "./distributed-cache.js";
29
24
  import { fetchModuleViaHTTP } from "./http-fetcher.js";
30
25
  import { cacheModule, normalizePath } from "./module-cache.js";
31
26
  import { readValidCachedModulePath } from "./path-cache-lookup.js";
27
+ import { transformResolvedModuleSource } from "./source-transform.js";
32
28
  // Re-export extracted modules for backward compatibility
33
29
  export { rewriteDntImports } from "./import-rewriter.js";
34
30
  export { endRenderSession, hasRenderSession, startRenderSession } from "./render-sessions.js";
@@ -199,106 +195,30 @@ async function doFetchAndCacheModule(normalizedPath, context, fetchAndCacheModul
199
195
  moduleCode = distResult.code;
200
196
  }
201
197
  if (!moduleCode) {
202
- log.debug(`${LOG_PREFIX_MDX_LOADER} [fetchAndCacheModule] transformToESM START`, {
203
- projectSlug,
204
- normalizedPath,
198
+ moduleCode = await transformResolvedModuleSource({
199
+ sourceCode,
205
200
  actualFilePath,
206
- sourceLength: sourceCode.length,
207
- });
208
- // Rewrite veryfront/* imports to /_vf_modules/ paths BEFORE transform
209
- // so that ssrVfModulesPlugin can resolve them to file:// paths.
210
- // Cached files don't have access to import maps, so we need to do this mapping here.
211
- const preprocessedSource = rewriteVeryfrontImports(sourceCode);
212
- const transformStart = performance.now();
213
- try {
214
- moduleCode = await transformToESM(preprocessedSource, actualFilePath, projectDir, adapter, {
215
- projectId,
216
- dev: true,
217
- ssr: true,
218
- reactVersion: context.reactVersion,
219
- });
220
- }
221
- catch (transformError) {
222
- log.error(`${LOG_PREFIX_MDX_LOADER} Transform failed for module`, {
223
- normalizedPath,
224
- actualFilePath,
225
- sourceLength: sourceCode.length,
226
- sourcePreview: sourceCode.slice(0, 200),
227
- error: transformError instanceof Error ? transformError.message : String(transformError),
228
- });
229
- throw transformError;
230
- }
231
- log.debug(`${LOG_PREFIX_MDX_LOADER} [fetchAndCacheModule] transformToESM DONE`, {
232
- projectSlug,
201
+ projectDir,
202
+ projectId,
233
203
  normalizedPath,
234
- transformMs: (performance.now() - transformStart).toFixed(1),
235
- outputLength: moduleCode.length,
204
+ projectSlug,
205
+ reactVersion: context.reactVersion,
206
+ adapter,
207
+ log,
236
208
  });
237
- // Rewrite _dnt.polyfills.js / _dnt.shims.js relative imports to absolute file:// paths
238
- moduleCode = await rewriteDntImports(moduleCode, actualFilePath);
239
- // Cache HTTP imports (esm.sh URLs) to local file:// paths.
240
- // This ensures the same cache works for both compiled and non-compiled Deno.
241
- // Compiled binaries cannot do dynamic HTTP imports, but non-compiled Deno
242
- // also works fine with file:// paths, so we always cache for consistency.
243
- {
244
- log.debug(`${LOG_PREFIX_MDX_LOADER} Caching HTTP imports to local files`, {
245
- normalizedPath,
246
- });
247
- const importMap = await loadImportMap(projectDir);
248
- const cacheResult = await cacheHttpImportsToLocal(moduleCode, {
249
- cacheDir: getHttpBundleCacheDir(),
250
- importMap,
251
- reactVersion: context.reactVersion,
252
- });
253
- moduleCode = cacheResult.code;
254
- }
255
209
  // Mark for distributed cache write AFTER nested imports are resolved.
256
210
  // This ensures we don't cache code with unresolved /_vf_modules/ paths.
257
211
  needsDistributedCacheWrite = true;
258
212
  }
259
- const { vfModules, relative } = findNestedImports(moduleCode);
260
- log.debug(`${LOG_PREFIX_MDX_LOADER} [fetchAndCacheModule] found nested imports`, {
261
- projectSlug,
213
+ moduleCode = await resolveNestedModuleImports({
214
+ moduleCode,
215
+ esmCacheDir,
262
216
  normalizedPath,
263
- vfModulesCount: vfModules.length,
264
- relativeCount: relative.length,
265
- vfModulePaths: vfModules.map((m) => m.path).slice(0, 5),
266
- relativePaths: relative.map((m) => m.path).slice(0, 5),
267
- });
268
- log.debug(`${LOG_PREFIX_MDX_LOADER} [fetchAndCacheModule] processing vfModules START`, {
217
+ strictMissingModules: context.strictMissingModules ?? true,
269
218
  projectSlug,
270
- normalizedPath,
271
- count: vfModules.length,
272
- });
273
- const vfStart = performance.now();
274
- const nestedResults = await Promise.all(vfModules.map(async ({ original, path }) => ({
275
- original,
276
- nestedFilePath: await fetchAndCacheModuleFn(path, normalizedPath),
277
- nestedPath: path,
278
- })));
279
- log.debug(`${LOG_PREFIX_MDX_LOADER} [fetchAndCacheModule] processing vfModules DONE`, {
280
- projectSlug,
281
- normalizedPath,
282
- vfMs: (performance.now() - vfStart).toFixed(1),
283
- });
284
- moduleCode = await processNestedImports(moduleCode, nestedResults, esmCacheDir, context.strictMissingModules ?? true, normalizedPath, projectSlug);
285
- log.debug(`${LOG_PREFIX_MDX_LOADER} [fetchAndCacheModule] processing relative imports START`, {
286
- projectSlug,
287
- normalizedPath,
288
- count: relative.length,
289
- });
290
- const relStart = performance.now();
291
- const relativeResults = await Promise.all(relative.map(async ({ original, path }) => ({
292
- original,
293
- nestedFilePath: await fetchAndCacheModuleFn(path, normalizedPath),
294
- relativePath: path,
295
- })));
296
- log.debug(`${LOG_PREFIX_MDX_LOADER} [fetchAndCacheModule] processing relative imports DONE`, {
297
- projectSlug,
298
- normalizedPath,
299
- relMs: (performance.now() - relStart).toFixed(1),
219
+ fetchAndCacheModule: fetchAndCacheModuleFn,
220
+ log,
300
221
  });
301
- moduleCode = await processNestedImports(moduleCode, relativeResults, esmCacheDir, context.strictMissingModules ?? true, normalizedPath, projectSlug);
302
222
  // Write to distributed cache AFTER nested imports are resolved.
303
223
  // This ensures other pods get fully-resolved code without /_vf_modules/ paths.
304
224
  if (needsDistributedCacheWrite && distResult?.distributedCache && transformCacheKey) {
@@ -4,6 +4,7 @@
4
4
  * @module transforms/mdx/esm-module-loader/module-fetcher/nested-imports
5
5
  */
6
6
  import type { NestedImportResult } from "../types.js";
7
+ import type { Logger } from "../../../../utils/logger/logger.js";
7
8
  /**
8
9
  * Find nested module imports in code.
9
10
  * Matches both /_vf_modules/... and file:///_vf_modules/... patterns.
@@ -29,4 +30,17 @@ export declare function hasUnresolvedImports(moduleCode: string): {
29
30
  * Process nested imports by replacing them with file:// paths or stub modules.
30
31
  */
31
32
  export declare function processNestedImports(moduleCode: string, results: NestedImportResult[], esmCacheDir: string, strictMissingModules: boolean, parentModulePath?: string, projectSlug?: string): Promise<string>;
33
+ export interface ResolveNestedModuleImportsInput {
34
+ moduleCode: string;
35
+ esmCacheDir: string;
36
+ normalizedPath: string;
37
+ projectSlug: string;
38
+ strictMissingModules: boolean;
39
+ fetchAndCacheModule: (path: string, parent?: string) => Promise<string | null>;
40
+ log?: Logger;
41
+ }
42
+ /**
43
+ * Resolve nested /_vf_modules and relative imports into local file:// cache paths.
44
+ */
45
+ export declare function resolveNestedModuleImports(input: ResolveNestedModuleImportsInput): Promise<string>;
32
46
  //# sourceMappingURL=nested-imports.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"nested-imports.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/mdx/esm-module-loader/module-fetcher/nested-imports.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAItD;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,GACjB;IACD,SAAS,EAAE,KAAK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACrD,QAAQ,EAAE,KAAK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACrD,CAqBA;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAO3F;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,kBAAkB,EAAE,EAC7B,WAAW,EAAE,MAAM,EACnB,oBAAoB,EAAE,OAAO,EAC7B,gBAAgB,CAAC,EAAE,MAAM,EACzB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,MAAM,CAAC,CAyBjB"}
1
+ {"version":3,"file":"nested-imports.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/mdx/esm-module-loader/module-fetcher/nested-imports.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAEjE;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,GACjB;IACD,SAAS,EAAE,KAAK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACrD,QAAQ,EAAE,KAAK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACrD,CAqBA;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAO3F;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,kBAAkB,EAAE,EAC7B,WAAW,EAAE,MAAM,EACnB,oBAAoB,EAAE,OAAO,EAC7B,gBAAgB,CAAC,EAAE,MAAM,EACzB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,MAAM,CAAC,CAyBjB;AAED,MAAM,WAAW,+BAA+B;IAC9C,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,mBAAmB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC/E,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,wBAAsB,0BAA0B,CAC9C,KAAK,EAAE,+BAA+B,GACrC,OAAO,CAAC,MAAM,CAAC,CAwEjB"}
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @module transforms/mdx/esm-module-loader/module-fetcher/nested-imports
5
5
  */
6
- import { RELATIVE_IMPORT_PATTERN, UNRESOLVED_VF_MODULES_PATTERN, VF_MODULE_IMPORT_PATTERN, } from "../constants.js";
6
+ import { LOG_PREFIX_MDX_LOADER, RELATIVE_IMPORT_PATTERN, UNRESOLVED_VF_MODULES_PATTERN, VF_MODULE_IMPORT_PATTERN, } from "../constants.js";
7
7
  import { createStubModule } from "../utils/stub-module.js";
8
8
  import { buildMissingModuleError } from "../missing-module.js";
9
9
  /**
@@ -67,3 +67,52 @@ export async function processNestedImports(moduleCode, results, esmCacheDir, str
67
67
  }
68
68
  return result;
69
69
  }
70
+ /**
71
+ * Resolve nested /_vf_modules and relative imports into local file:// cache paths.
72
+ */
73
+ export async function resolveNestedModuleImports(input) {
74
+ let moduleCode = input.moduleCode;
75
+ const { vfModules, relative } = findNestedImports(moduleCode);
76
+ input.log?.debug(`${LOG_PREFIX_MDX_LOADER} [fetchAndCacheModule] found nested imports`, {
77
+ projectSlug: input.projectSlug,
78
+ normalizedPath: input.normalizedPath,
79
+ vfModulesCount: vfModules.length,
80
+ relativeCount: relative.length,
81
+ vfModulePaths: vfModules.map((module) => module.path).slice(0, 5),
82
+ relativePaths: relative.map((module) => module.path).slice(0, 5),
83
+ });
84
+ input.log?.debug(`${LOG_PREFIX_MDX_LOADER} [fetchAndCacheModule] processing vfModules START`, {
85
+ projectSlug: input.projectSlug,
86
+ normalizedPath: input.normalizedPath,
87
+ count: vfModules.length,
88
+ });
89
+ const vfStart = performance.now();
90
+ const nestedResults = await Promise.all(vfModules.map(async ({ original, path }) => ({
91
+ original,
92
+ nestedFilePath: await input.fetchAndCacheModule(path, input.normalizedPath),
93
+ nestedPath: path,
94
+ })));
95
+ input.log?.debug(`${LOG_PREFIX_MDX_LOADER} [fetchAndCacheModule] processing vfModules DONE`, {
96
+ projectSlug: input.projectSlug,
97
+ normalizedPath: input.normalizedPath,
98
+ vfMs: (performance.now() - vfStart).toFixed(1),
99
+ });
100
+ moduleCode = await processNestedImports(moduleCode, nestedResults, input.esmCacheDir, input.strictMissingModules, input.normalizedPath, input.projectSlug);
101
+ input.log?.debug(`${LOG_PREFIX_MDX_LOADER} [fetchAndCacheModule] processing relative imports START`, {
102
+ projectSlug: input.projectSlug,
103
+ normalizedPath: input.normalizedPath,
104
+ count: relative.length,
105
+ });
106
+ const relStart = performance.now();
107
+ const relativeResults = await Promise.all(relative.map(async ({ original, path }) => ({
108
+ original,
109
+ nestedFilePath: await input.fetchAndCacheModule(path, input.normalizedPath),
110
+ relativePath: path,
111
+ })));
112
+ input.log?.debug(`${LOG_PREFIX_MDX_LOADER} [fetchAndCacheModule] processing relative imports DONE`, {
113
+ projectSlug: input.projectSlug,
114
+ normalizedPath: input.normalizedPath,
115
+ relMs: (performance.now() - relStart).toFixed(1),
116
+ });
117
+ return await processNestedImports(moduleCode, relativeResults, input.esmCacheDir, input.strictMissingModules, input.normalizedPath, input.projectSlug);
118
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Source-file transform phase for the MDX ESM module fetcher.
3
+ *
4
+ * @module transforms/mdx/esm-module-loader/module-fetcher/source-transform
5
+ */
6
+ import { cacheHttpImportsToLocal } from "../../../esm/http-cache.js";
7
+ import { loadImportMap } from "../../../../modules/import-map/index.js";
8
+ import type { RuntimeAdapter } from "../../../../platform/adapters/base.js";
9
+ import { transformToESM } from "../../../esm-transform.js";
10
+ import type { Logger } from "../../../../utils/logger/logger.js";
11
+ type TransformToEsmFn = typeof transformToESM;
12
+ type LoadImportMapFn = typeof loadImportMap;
13
+ type CacheHttpImportsToLocalFn = typeof cacheHttpImportsToLocal;
14
+ type SourceTransformLogger = Pick<Logger, "debug" | "error">;
15
+ export interface TransformResolvedModuleSourceInput {
16
+ sourceCode: string;
17
+ actualFilePath: string;
18
+ projectDir: string;
19
+ projectId: string;
20
+ normalizedPath: string;
21
+ projectSlug: string;
22
+ reactVersion?: string;
23
+ adapter: RuntimeAdapter;
24
+ log: SourceTransformLogger;
25
+ transformToEsm?: TransformToEsmFn;
26
+ loadImportMap?: LoadImportMapFn;
27
+ cacheHttpImportsToLocal?: CacheHttpImportsToLocalFn;
28
+ }
29
+ /**
30
+ * Transform a resolved source file into cache-safe ESM module code.
31
+ */
32
+ export declare function transformResolvedModuleSource(input: TransformResolvedModuleSourceInput): Promise<string>;
33
+ export {};
34
+ //# sourceMappingURL=source-transform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-transform.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/mdx/esm-module-loader/module-fetcher/source-transform.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAIjE,KAAK,gBAAgB,GAAG,OAAO,cAAc,CAAC;AAC9C,KAAK,eAAe,GAAG,OAAO,aAAa,CAAC;AAC5C,KAAK,yBAAyB,GAAG,OAAO,uBAAuB,CAAC;AAChE,KAAK,qBAAqB,GAAG,IAAI,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC;AAE7D,MAAM,WAAW,kCAAkC;IACjD,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,cAAc,CAAC;IACxB,GAAG,EAAE,qBAAqB,CAAC;IAC3B,cAAc,CAAC,EAAE,gBAAgB,CAAC;IAClC,aAAa,CAAC,EAAE,eAAe,CAAC;IAChC,uBAAuB,CAAC,EAAE,yBAAyB,CAAC;CACrD;AAED;;GAEG;AACH,wBAAsB,6BAA6B,CACjD,KAAK,EAAE,kCAAkC,GACxC,OAAO,CAAC,MAAM,CAAC,CA0DjB"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Source-file transform phase for the MDX ESM module fetcher.
3
+ *
4
+ * @module transforms/mdx/esm-module-loader/module-fetcher/source-transform
5
+ */
6
+ import { cacheHttpImportsToLocal } from "../../../esm/http-cache.js";
7
+ import { loadImportMap } from "../../../../modules/import-map/index.js";
8
+ import { transformToESM } from "../../../esm-transform.js";
9
+ import { getHttpBundleCacheDir } from "../../../../utils/cache-dir.js";
10
+ import { LOG_PREFIX_MDX_LOADER } from "../constants.js";
11
+ import { rewriteDntImports, rewriteVeryfrontImports } from "./import-rewriter.js";
12
+ /**
13
+ * Transform a resolved source file into cache-safe ESM module code.
14
+ */
15
+ export async function transformResolvedModuleSource(input) {
16
+ input.log.debug(`${LOG_PREFIX_MDX_LOADER} [fetchAndCacheModule] transformToESM START`, {
17
+ projectSlug: input.projectSlug,
18
+ normalizedPath: input.normalizedPath,
19
+ actualFilePath: input.actualFilePath,
20
+ sourceLength: input.sourceCode.length,
21
+ });
22
+ const preprocessedSource = rewriteVeryfrontImports(input.sourceCode);
23
+ const transform = input.transformToEsm ?? transformToESM;
24
+ const transformStart = performance.now();
25
+ let moduleCode;
26
+ try {
27
+ moduleCode = await transform(preprocessedSource, input.actualFilePath, input.projectDir, input.adapter, {
28
+ projectId: input.projectId,
29
+ dev: true,
30
+ ssr: true,
31
+ reactVersion: input.reactVersion,
32
+ });
33
+ }
34
+ catch (transformError) {
35
+ input.log.error(`${LOG_PREFIX_MDX_LOADER} Transform failed for module`, {
36
+ normalizedPath: input.normalizedPath,
37
+ actualFilePath: input.actualFilePath,
38
+ sourceLength: input.sourceCode.length,
39
+ sourcePreview: input.sourceCode.slice(0, 200),
40
+ error: transformError instanceof Error ? transformError.message : String(transformError),
41
+ });
42
+ throw transformError;
43
+ }
44
+ input.log.debug(`${LOG_PREFIX_MDX_LOADER} [fetchAndCacheModule] transformToESM DONE`, {
45
+ projectSlug: input.projectSlug,
46
+ normalizedPath: input.normalizedPath,
47
+ transformMs: (performance.now() - transformStart).toFixed(1),
48
+ outputLength: moduleCode.length,
49
+ });
50
+ moduleCode = await rewriteDntImports(moduleCode, input.actualFilePath);
51
+ input.log.debug(`${LOG_PREFIX_MDX_LOADER} Caching HTTP imports to local files`, {
52
+ normalizedPath: input.normalizedPath,
53
+ });
54
+ const readImportMap = input.loadImportMap ?? loadImportMap;
55
+ const cacheHttpImports = input.cacheHttpImportsToLocal ?? cacheHttpImportsToLocal;
56
+ const importMap = await readImportMap(input.projectDir);
57
+ const cacheResult = await cacheHttpImports(moduleCode, {
58
+ cacheDir: getHttpBundleCacheDir(),
59
+ importMap,
60
+ reactVersion: input.reactVersion,
61
+ });
62
+ return cacheResult.code;
63
+ }
@@ -1,3 +1,3 @@
1
1
  /** Shared version value. */
2
- export declare const VERSION = "0.1.736";
2
+ export declare const VERSION = "0.1.738";
3
3
  //# sourceMappingURL=version-constant.d.ts.map
@@ -1,4 +1,4 @@
1
1
  // Keep in sync with deno.json version.
2
2
  // scripts/release.ts updates this constant during releases.
3
3
  /** Shared version value. */
4
- export const VERSION = "0.1.736";
4
+ export const VERSION = "0.1.738";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veryfront",
3
- "version": "0.1.736",
3
+ "version": "0.1.738",
4
4
  "description": "The simplest way to build AI-powered apps",
5
5
  "keywords": [
6
6
  "react",