veryfront 0.1.827 → 0.1.829

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.
Files changed (44) hide show
  1. package/esm/deno.js +1 -1
  2. package/esm/src/build/production-build/templates.d.ts.map +1 -1
  3. package/esm/src/build/production-build/templates.js +1 -1
  4. package/esm/src/html/hydration-script-builder/templates/router.d.ts.map +1 -1
  5. package/esm/src/html/hydration-script-builder/templates/router.js +78 -4
  6. package/esm/src/modules/react-loader/ssr-module-loader/import-rewriter.d.ts +2 -2
  7. package/esm/src/modules/react-loader/ssr-module-loader/import-rewriter.d.ts.map +1 -1
  8. package/esm/src/modules/react-loader/ssr-module-loader/import-rewriter.js +14 -22
  9. package/esm/src/modules/react-loader/ssr-module-loader/loader.js +2 -2
  10. package/esm/src/modules/react-loader/ssr-module-loader/ssr-cache-manager.d.ts.map +1 -1
  11. package/esm/src/modules/react-loader/ssr-module-loader/ssr-cache-manager.js +11 -4
  12. package/esm/src/modules/react-loader/ssr-module-loader/vf-module-resolver.d.ts +2 -2
  13. package/esm/src/modules/react-loader/ssr-module-loader/vf-module-resolver.d.ts.map +1 -1
  14. package/esm/src/modules/react-loader/ssr-module-loader/vf-module-resolver.js +22 -15
  15. package/esm/src/release-assets/build-executor.d.ts.map +1 -1
  16. package/esm/src/release-assets/build-executor.js +43 -62
  17. package/esm/src/release-assets/html-consumption.d.ts +2 -1
  18. package/esm/src/release-assets/html-consumption.d.ts.map +1 -1
  19. package/esm/src/release-assets/html-consumption.js +4 -2
  20. package/esm/src/rendering/rsc/component-analyzer.d.ts.map +1 -1
  21. package/esm/src/rendering/rsc/component-analyzer.js +2 -1
  22. package/esm/src/rendering/rsc/export-extractor.d.ts +5 -3
  23. package/esm/src/rendering/rsc/export-extractor.d.ts.map +1 -1
  24. package/esm/src/rendering/rsc/export-extractor.js +59 -36
  25. package/esm/src/routing/client/page-loader.d.ts.map +1 -1
  26. package/esm/src/routing/client/page-loader.js +2 -4
  27. package/esm/src/transforms/mdx/esm-module-loader/cache/index.d.ts.map +1 -1
  28. package/esm/src/transforms/mdx/esm-module-loader/cache/index.js +8 -14
  29. package/esm/src/transforms/mdx/esm-module-loader/import-transformer.d.ts +1 -1
  30. package/esm/src/transforms/mdx/esm-module-loader/import-transformer.d.ts.map +1 -1
  31. package/esm/src/transforms/mdx/esm-module-loader/import-transformer.js +32 -26
  32. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/nested-imports.d.ts.map +1 -1
  33. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/nested-imports.js +7 -5
  34. package/esm/src/transforms/mdx/esm-module-loader/module-writer.d.ts.map +1 -1
  35. package/esm/src/transforms/mdx/esm-module-loader/module-writer.js +8 -8
  36. package/esm/src/transforms/pipeline/stages/ssr-vf-modules/import-finder.d.ts +2 -2
  37. package/esm/src/transforms/pipeline/stages/ssr-vf-modules/import-finder.d.ts.map +1 -1
  38. package/esm/src/transforms/pipeline/stages/ssr-vf-modules/import-finder.js +16 -26
  39. package/esm/src/transforms/pipeline/stages/ssr-vf-modules/index.js +1 -1
  40. package/esm/src/transforms/pipeline/stages/ssr-vf-modules/transform.d.ts.map +1 -1
  41. package/esm/src/transforms/pipeline/stages/ssr-vf-modules/transform.js +8 -5
  42. package/esm/src/utils/version-constant.d.ts +1 -1
  43. package/esm/src/utils/version-constant.js +1 -1
  44. package/package.json +1 -1
@@ -7,24 +7,29 @@ import { join } from "../../../platform/compat/path/index.js";
7
7
  import { hashCodeHex } from "../../../utils/hash-utils.js";
8
8
  import { rendererLogger } from "../../../utils/index.js";
9
9
  import { getMdxEsmCacheDir } from "../../../utils/cache-dir.js";
10
+ import { parseImports, replaceSpecifiers } from "../../../transforms/esm/lexer.js";
10
11
  import { createModuleFetcherContext, fetchAndCacheModule, } from "../../../transforms/mdx/esm-module-loader/module-fetcher/index.js";
11
- import { VF_MODULE_IMPORT_PATTERN } from "../../../transforms/mdx/esm-module-loader/constants.js";
12
12
  const logger = rendererLogger.component("ssr-module-loader");
13
13
  /**
14
14
  * Find /_vf_modules/ imports in transformed code.
15
15
  * Matches both /_vf_modules/... and file:///_vf_modules/... forms.
16
16
  */
17
- export function findVfModuleImports(code) {
17
+ export async function findVfModuleImports(code) {
18
18
  const imports = [];
19
- const pattern = new RegExp(VF_MODULE_IMPORT_PATTERN.source, "g");
20
- let match;
21
- while ((match = pattern.exec(code)) !== null) {
22
- const rawPath = match[1];
19
+ const parsedImports = await parseImports(code);
20
+ for (const importSpecifier of parsedImports) {
21
+ const rawPath = importSpecifier.n;
23
22
  if (!rawPath)
24
23
  continue;
25
24
  // Normalize "file:///_vf_modules/..." and "/_vf_modules/..." to "_vf_modules/..."
26
25
  const path = rawPath.replace(/^(?:file:\/\/)?\/+/, "");
27
- imports.push({ original: match[0], path });
26
+ if (!path.startsWith("_vf_modules/"))
27
+ continue;
28
+ const queryStart = path.indexOf("?");
29
+ imports.push({
30
+ specifier: rawPath,
31
+ path: queryStart === -1 ? path : path.slice(0, queryStart),
32
+ });
28
33
  }
29
34
  return imports;
30
35
  }
@@ -32,7 +37,7 @@ export function findVfModuleImports(code) {
32
37
  * Resolve /_vf_modules/ imports to local cached modules and rewrite code.
33
38
  */
34
39
  export async function resolveVfModuleImports(code, options) {
35
- const imports = findVfModuleImports(code);
40
+ const imports = await findVfModuleImports(code);
36
41
  if (imports.length === 0)
37
42
  return code;
38
43
  logger.debug("Processing _vf_modules imports", {
@@ -49,10 +54,10 @@ export async function resolveVfModuleImports(code, options) {
49
54
  projectSlug: options.projectId,
50
55
  strictMissingModules: false,
51
56
  });
52
- const results = await Promise.all(imports.map(async ({ original, path }) => {
57
+ const results = await Promise.all(imports.map(async ({ specifier, path }) => {
53
58
  try {
54
59
  const cachedFilePath = await fetchAndCacheModule(path, fetcherContext);
55
- return { original, path, cachedFilePath };
60
+ return { specifier, path, cachedFilePath };
56
61
  }
57
62
  catch (error) {
58
63
  logger.warn("Failed to fetch _vf_modules import", {
@@ -60,13 +65,13 @@ export async function resolveVfModuleImports(code, options) {
60
65
  path,
61
66
  error: error instanceof Error ? error.message : String(error),
62
67
  });
63
- return { original, path, cachedFilePath: null };
68
+ return { specifier, path, cachedFilePath: null };
64
69
  }
65
70
  }));
66
- let transformed = code;
67
- for (const { original, path, cachedFilePath } of results) {
71
+ const replacements = new Map();
72
+ for (const { specifier, path, cachedFilePath } of results) {
68
73
  if (cachedFilePath) {
69
- transformed = transformed.replace(original, `from "file://${cachedFilePath}"`);
74
+ replacements.set(specifier, `file://${cachedFilePath}`);
70
75
  }
71
76
  else {
72
77
  logger.warn("Failed to resolve _vf_modules import", {
@@ -75,5 +80,7 @@ export async function resolveVfModuleImports(code, options) {
75
80
  });
76
81
  }
77
82
  }
78
- return transformed;
83
+ if (replacements.size === 0)
84
+ return code;
85
+ return await replaceSpecifiers(code, (specifier) => replacements.get(specifier) ?? null);
79
86
  }
@@ -1 +1 @@
1
- {"version":3,"file":"build-executor.d.ts","sourceRoot":"","sources":["../../../src/src/release-assets/build-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AA+BH,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AA0B/C,MAAM,WAAW,sBAAsB;IACrC,yDAAyD;IACzD,gBAAgB,EAAE,MAAM,CAAC;IACzB,oBAAoB;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,oBAAoB;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACjC,cAAc,EAAE,MAAM,CAAC;IACvB,yDAAyD;IACzD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oCAAoC;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gDAAgD;IAChD,MAAM,EAAE,uBAAuB,CAAC;IAChC,sDAAsD;IAEtD,OAAO,EAAE,GAAG,CAAC;IACb;;;;OAIG;IACH,SAAS,CAAC,EAAE,qBAAqB,CAAC;IAClC;;;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AE,oBAAoB,EAAE,CAAC;IAC/B,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CAAC,CAqCD;AAkDD;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,sBAAsB,EAC7B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,uBAAuB,CAAC,CA2ClC"}
1
+ {"version":3,"file":"build-executor.d.ts","sourceRoot":"","sources":["../../../src/src/release-assets/build-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAiCH,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AA0B/C,MAAM,WAAW,sBAAsB;IACrC,yDAAyD;IACzD,gBAAgB,EAAE,MAAM,CAAC;IACzB,oBAAoB;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,oBAAoB;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACjC,cAAc,EAAE,MAAM,CAAC;IACvB,yDAAyD;IACzD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oCAAoC;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gDAAgD;IAChD,MAAM,EAAE,uBAAuB,CAAC;IAChC,sDAAsD;IAEtD,OAAO,EAAE,GAAG,CAAC;IACb;;;;OAIG;IACH,SAAS,CAAC,EAAE,qBAAqB,CAAC;IAClC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,gCAAgC,CAAC;CACtD;AAED,MAAM,MAAM,qBAAqB,GAAG,CAClC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAElB,OAAO,EAAE,GAAG,EACZ,OAAO,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,OAAO,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,KAC9E,OAAO,CAA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AC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,gCAAgC,CAAC;CACtD,GAAG,OAAO,CAAC;IACV,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC5C,MAAM,EAAE,oBAAoB,EAAE,CAAC;IAC/B,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CAAC,CAkCD;AAsDD,wBAAsB,+BAA+B,CAAC,OAAO,EAAE;IAC7D,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAAC;IACV,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC5C,MAAM,EAAE,oBAAoB,EAAE,CAAC;IAC/B,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CAAC,CAkCD;AAwZD,wBAAsB,8BAA8B,CAAC,OAAO,EAAE;IAC5D,OAAO,EAAE,MAAM,CAAC;IAEhB,OAAO,EAAE,GAAG,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,qBAAqB,CAAC;IAClC,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC,GAAG,OAAO,CAAC;IACV,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC5C,MAAM,EAAE,oBAAoB,EAAE,CAAC;IAC/B,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CAAC,CAqCD;AAkDD;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,sBAAsB,EAC7B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,uBAAuB,CAAC,CA2ClC"}
@@ -16,6 +16,7 @@
16
16
  */
17
17
  import { serverLogger } from "../utils/index.js";
18
18
  import { VERSION } from "../utils/version.js";
19
+ import { resolve } from "../extensions/contracts.js";
19
20
  import { createFileSystem } from "../platform/compat/fs.js";
20
21
  import { getHostEnv } from "../platform/compat/process.js";
21
22
  import { dirname, join, normalize } from "../platform/compat/path/index.js";
@@ -88,66 +89,44 @@ function isBrowserModule(path) {
88
89
  return BROWSER_MODULE_DIRS.some((dir) => path.startsWith(dir));
89
90
  }
90
91
  /**
91
- * Statically resolve relative imports in a source file to logical paths.
92
- *
93
- * Parses `import/export ... from "..."` and bare `import "..."` statements.
94
- * Only relative specifiers (`./` or `../`) are resolved; package imports and
95
- * absolute URLs are skipped. Extension-less specifiers try each browser module
96
- * extension in order.
92
+ * Statically resolve runtime imports in a TS/JSX source file to logical paths.
93
+ * Uses the CodeParser AST contract so type-only imports do not enter route
94
+ * preload closure.
97
95
  */
98
- function resolveStaticImports(source, moduleLogicalPath, knownPaths) {
99
- const importRe = /(?:^|;|\n)\s*(?:import|export)\s+(?:[^'"]+\s+from\s+)?['"]([^'"]+)['"]/gm;
100
- const results = [];
101
- let m;
102
- while ((m = importRe.exec(source)) !== null) {
103
- const specifier = m[1];
104
- const isAlias = specifier.startsWith("@/");
105
- if (!isAlias && !specifier.startsWith("./") && !specifier.startsWith("../"))
106
- continue;
107
- const dir = moduleLogicalPath.includes("/")
108
- ? moduleLogicalPath.slice(0, moduleLogicalPath.lastIndexOf("/"))
109
- : ".";
110
- // `@/x` is a project-root alias (mirrors transforms/esm/path-resolver.ts).
111
- // Resolve the path segments manually (no path library needed for simple cases).
112
- const segments = (isAlias ? specifier.substring(2) : `${dir}/${specifier}`)
113
- .split("/").filter((s) => s !== "");
114
- const resolved = [];
115
- for (const seg of segments) {
116
- if (seg === "..") {
117
- resolved.pop();
118
- }
119
- else if (seg !== ".") {
120
- resolved.push(seg);
121
- }
122
- }
123
- const candidate = resolved.join("/");
124
- // If the specifier already has a known extension and exists, use it.
125
- if (knownPaths.has(candidate)) {
126
- results.push(candidate);
127
- continue;
128
- }
129
- // Try appending each browser module extension.
130
- let found = false;
131
- for (const ext of BROWSER_MODULE_EXTENSIONS) {
132
- const withExt = `${candidate}${ext}`;
133
- if (knownPaths.has(withExt)) {
134
- results.push(withExt);
135
- found = true;
136
- break;
137
- }
138
- }
139
- // Also try /index variants for directory imports.
140
- if (!found) {
141
- for (const ext of BROWSER_MODULE_EXTENSIONS) {
142
- const indexPath = `${candidate}/index${ext}`;
143
- if (knownPaths.has(indexPath)) {
144
- results.push(indexPath);
145
- break;
146
- }
147
- }
148
- }
149
- }
150
- return results;
96
+ async function collectStaticProjectModuleImports(source, moduleLogicalPath, knownPaths) {
97
+ return await collectAstStaticProjectModuleImports(source, moduleLogicalPath, knownPaths);
98
+ }
99
+ function readModuleSource(node) {
100
+ return typeof node.source?.value === "string" ? node.source.value : null;
101
+ }
102
+ function isTypeOnlyModuleDeclaration(node) {
103
+ if (node.importKind === "type" || node.exportKind === "type")
104
+ return true;
105
+ if (!node.specifiers?.length)
106
+ return false;
107
+ return node.specifiers.every((specifier) => specifier.importKind === "type" || specifier.exportKind === "type");
108
+ }
109
+ async function collectAstStaticProjectModuleImports(source, moduleLogicalPath, knownPaths) {
110
+ const parser = resolve("CodeParser");
111
+ const ast = await parser.parse({ code: source, filePath: moduleLogicalPath });
112
+ const results = new Set();
113
+ const visit = (path) => {
114
+ const node = path.node;
115
+ if (isTypeOnlyModuleDeclaration(node))
116
+ return;
117
+ const specifier = readModuleSource(node);
118
+ if (!specifier)
119
+ return;
120
+ const importedPath = resolveProjectModuleSpecifier(specifier, moduleLogicalPath, knownPaths);
121
+ if (importedPath)
122
+ results.add(importedPath);
123
+ };
124
+ parser.traverse(ast, {
125
+ ImportDeclaration: visit,
126
+ ExportNamedDeclaration: visit,
127
+ ExportAllDeclaration: visit,
128
+ });
129
+ return [...results];
151
130
  }
152
131
  function resolveKnownModulePath(path, knownPaths) {
153
132
  const normalized = normalizeLogicalPath(path
@@ -193,6 +172,8 @@ function normalizeProjectSpecifier(specifier, logicalPath) {
193
172
  return specifier;
194
173
  if (specifier.startsWith("_veryfront/"))
195
174
  return null;
175
+ if (specifier.startsWith("@/"))
176
+ return specifier.slice(2);
196
177
  if (specifier.startsWith("./") || specifier.startsWith("../")) {
197
178
  const dir = logicalPath.includes("/")
198
179
  ? logicalPath.slice(0, logicalPath.lastIndexOf("/"))
@@ -949,7 +930,7 @@ function addFrameworkDependencyUrlAliases(urls, dependencies) {
949
930
  * Returns all reachable logical paths (entries included).
950
931
  * Modules not in `sourceByPath` are recorded as closure gaps.
951
932
  */
952
- function collectClosure(entrypoints, sourceByPath, knownPaths) {
933
+ async function collectClosure(entrypoints, sourceByPath, knownPaths) {
953
934
  const visited = new Set();
954
935
  const queue = [...entrypoints];
955
936
  const gaps = [];
@@ -964,7 +945,7 @@ function collectClosure(entrypoints, sourceByPath, knownPaths) {
964
945
  gaps.push(`closure-missing:${current}`);
965
946
  continue;
966
947
  }
967
- const imports = resolveStaticImports(source, current, knownPaths);
948
+ const imports = await collectStaticProjectModuleImports(source, current, knownPaths);
968
949
  for (const imp of imports) {
969
950
  if (!visited.has(imp))
970
951
  queue.push(imp);
@@ -1261,7 +1242,7 @@ async function runBuildInner(input, tempDir, client, transform) {
1261
1242
  const route = routeForPage(logicalPath);
1262
1243
  if (!route)
1263
1244
  continue;
1264
- const { modules: closureModules, gaps: closureGaps } = collectClosure([logicalPath], sourceByPath, knownPaths);
1245
+ const { modules: closureModules, gaps: closureGaps } = await collectClosure([logicalPath], sourceByPath, knownPaths);
1265
1246
  // Include only modules we actually have in the manifest (transformed +
1266
1247
  // within size limit). Framework lib/* modules are excluded per contract
1267
1248
  // (they are embedded by the runtime, not shipped as release assets).
@@ -15,7 +15,8 @@ import type { ReleaseAssetManifest } from "./manifest-schema.js";
15
15
  * The HTML shell works with relative source paths like `pages/index.tsx` and
16
16
  * `/_vf_modules/pages/index.js` URLs. Manifest module keys use the logical
17
17
  * source path (e.g. `pages/index.tsx`). This strips a leading `/_vf_modules/`
18
- * and any `.js` URL extension so both forms resolve.
18
+ * prefix and URL query/hash data before the resolver compares source
19
+ * extensions.
19
20
  */
20
21
  export declare function normalizeManifestModuleKey(path: string): string;
21
22
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"html-consumption.d.ts","sourceRoot":"","sources":["../../../src/src/release-assets/html-consumption.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAIjE;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAI/D;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,oBAAoB,EAC9B,WAAW,EAAE,MAAM,GAClB,MAAM,GAAG,IAAI,CAcf;AAED,iFAAiF;AACjF,wBAAgB,+BAA+B,CAC7C,QAAQ,EAAE,oBAAoB,EAC9B,KAAK,EAAE,MAAM,GACZ,MAAM,EAAE,CAcV"}
1
+ {"version":3,"file":"html-consumption.d.ts","sourceRoot":"","sources":["../../../src/src/release-assets/html-consumption.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAIjE;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAK/D;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,oBAAoB,EAC9B,WAAW,EAAE,MAAM,GAClB,MAAM,GAAG,IAAI,CAcf;AAED,iFAAiF;AACjF,wBAAgB,+BAA+B,CAC7C,QAAQ,EAAE,oBAAoB,EAC9B,KAAK,EAAE,MAAM,GACZ,MAAM,EAAE,CAcV"}
@@ -17,11 +17,13 @@ const logger = serverLogger.component("release-asset-consume");
17
17
  * The HTML shell works with relative source paths like `pages/index.tsx` and
18
18
  * `/_vf_modules/pages/index.js` URLs. Manifest module keys use the logical
19
19
  * source path (e.g. `pages/index.tsx`). This strips a leading `/_vf_modules/`
20
- * and any `.js` URL extension so both forms resolve.
20
+ * prefix and URL query/hash data before the resolver compares source
21
+ * extensions.
21
22
  */
22
23
  export function normalizeManifestModuleKey(path) {
23
- let key = path.replace(/^\/?_vf_modules\//, "");
24
+ let key = String(path || "").replace(/^\/?_vf_modules\//, "");
24
25
  key = key.replace(/^\/+/, "");
26
+ key = key.replace(/[?#].*$/, "");
25
27
  return key;
26
28
  }
27
29
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"component-analyzer.d.ts","sourceRoot":"","sources":["../../../../src/src/rendering/rsc/component-analyzer.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAiB,MAAM,YAAY,CAAC;AACxF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAIzE,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,iBAAiB,GACpB,OAAO,CAAC,iBAAiB,CAAC,CAiB5B;AAuBD,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,MAAM,EAClB,MAAM,GAAE,MAAc,EACtB,EAAE,CAAC,EAAE,iBAAiB,GACrB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAiC3C"}
1
+ {"version":3,"file":"component-analyzer.d.ts","sourceRoot":"","sources":["../../../../src/src/rendering/rsc/component-analyzer.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAiB,MAAM,YAAY,CAAC;AACxF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAIzE,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,iBAAiB,GACpB,OAAO,CAAC,iBAAiB,CAAC,CAkB5B;AAuBD,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,MAAM,EAClB,MAAM,GAAE,MAAc,EACtB,EAAE,CAAC,EAAE,iBAAiB,GACrB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAiC3C"}
@@ -12,10 +12,11 @@ export async function analyzeComponent(filePath, fs) {
12
12
  const hasUseServer = detectDirective(content, "use server");
13
13
  // Determine component type: directive takes precedence over file naming convention
14
14
  const type = hasUseClient || filePath.includes(".client.") ? "client" : "server";
15
+ const exports = await extractExportNames(content, filePath);
15
16
  return {
16
17
  type,
17
18
  filePath,
18
- exports: extractExportNames(content),
19
+ exports,
19
20
  id: generateComponentId(filePath),
20
21
  hasUseClient,
21
22
  hasUseServer,
@@ -1,6 +1,8 @@
1
1
  /**
2
- * Extract all export names from source code.
3
- * Handles export function/class/const, named exports, and default exports.
2
+ * Extract runtime export names from source code.
3
+ *
4
+ * Uses the CodeParser AST contract so export-looking strings, comments, and
5
+ * type-only exports do not enter RSC manifests.
4
6
  */
5
- export declare function extractExportNames(source: string): string[];
7
+ export declare function extractExportNames(source: string, filePath?: string): Promise<string[]>;
6
8
  //# sourceMappingURL=export-extractor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"export-extractor.d.ts","sourceRoot":"","sources":["../../../../src/src/rendering/rsc/export-extractor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAuC3D"}
1
+ {"version":3,"file":"export-extractor.d.ts","sourceRoot":"","sources":["../../../../src/src/rendering/rsc/export-extractor.ts"],"names":[],"mappings":"AAiEA;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,MAAM,EACd,QAAQ,SAAkB,GACzB,OAAO,CAAC,MAAM,EAAE,CAAC,CAwBnB"}
@@ -1,42 +1,65 @@
1
+ import { resolve } from "../../extensions/contracts.js";
2
+ function readName(node) {
3
+ if (typeof node?.name === "string")
4
+ return node.name;
5
+ if (typeof node?.value === "string")
6
+ return node.value;
7
+ return null;
8
+ }
9
+ function isTypeOnlyDeclaration(declaration) {
10
+ if (!declaration)
11
+ return false;
12
+ if (declaration.declare === true)
13
+ return true;
14
+ return declaration.type === "TSInterfaceDeclaration" ||
15
+ declaration.type === "TSTypeAliasDeclaration";
16
+ }
17
+ function addDeclarationNames(names, declaration) {
18
+ if (!declaration || isTypeOnlyDeclaration(declaration))
19
+ return;
20
+ if (declaration.type === "FunctionDeclaration" ||
21
+ declaration.type === "ClassDeclaration" ||
22
+ declaration.type === "TSEnumDeclaration") {
23
+ const name = readName(declaration.id);
24
+ if (name)
25
+ names.add(name);
26
+ return;
27
+ }
28
+ if (declaration.type !== "VariableDeclaration")
29
+ return;
30
+ for (const declarator of declaration.declarations ?? []) {
31
+ const name = readName(declarator.id);
32
+ if (name)
33
+ names.add(name);
34
+ }
35
+ }
1
36
  /**
2
- * Extract all export names from source code.
3
- * Handles export function/class/const, named exports, and default exports.
37
+ * Extract runtime export names from source code.
38
+ *
39
+ * Uses the CodeParser AST contract so export-looking strings, comments, and
40
+ * type-only exports do not enter RSC manifests.
4
41
  */
5
- export function extractExportNames(source) {
42
+ export async function extractExportNames(source, filePath = "component.tsx") {
43
+ const parser = resolve("CodeParser");
44
+ const ast = await parser.parse({ code: source, filePath });
6
45
  const names = new Set();
7
- if (/export\s+default\s+/m.test(source)) {
8
- names.add("default");
9
- }
10
- for (const match of source.matchAll(/export\s+function\s+([A-Za-z0-9_]+)/g)) {
11
- if (match[1])
12
- names.add(match[1]);
13
- }
14
- for (const match of source.matchAll(/export\s+class\s+([A-Za-z0-9_]+)/g)) {
15
- if (match[1])
16
- names.add(match[1]);
17
- }
18
- for (const match of source.matchAll(/export\s+(?:const|let|var)\s+([A-Za-z0-9_]+)/g)) {
19
- if (match[1])
20
- names.add(match[1]);
21
- }
22
- for (const match of source.matchAll(/export\s*\{([^}]+)\}/g)) {
23
- const innerRaw = match[1];
24
- if (!innerRaw)
25
- continue;
26
- const inner = innerRaw.split(",");
27
- for (const seg of inner) {
28
- const part = seg.trim();
29
- if (!part)
30
- continue;
31
- const asMatch = part.match(/([A-Za-z0-9_]+)\s+as\s+([A-Za-z0-9_]+)/i);
32
- if (asMatch?.[2]) {
33
- names.add(asMatch[2]);
34
- continue;
46
+ parser.traverse(ast, {
47
+ ExportDefaultDeclaration() {
48
+ names.add("default");
49
+ },
50
+ ExportNamedDeclaration(path) {
51
+ const node = path.node;
52
+ if (node.exportKind === "type")
53
+ return;
54
+ addDeclarationNames(names, node.declaration);
55
+ for (const specifier of node.specifiers ?? []) {
56
+ if (specifier.exportKind === "type")
57
+ continue;
58
+ const name = readName(specifier.exported) ?? readName(specifier.local);
59
+ if (name)
60
+ names.add(name);
35
61
  }
36
- const plain = part.match(/^([A-Za-z0-9_]+)/);
37
- if (plain?.[1])
38
- names.add(plain[1]);
39
- }
40
- }
62
+ },
63
+ });
41
64
  return [...names];
42
65
  }
@@ -1 +1 @@
1
- {"version":3,"file":"page-loader.d.ts","sourceRoot":"","sources":["../../../../src/src/routing/client/page-loader.ts"],"names":[],"mappings":"AAIA,YAAY,EACV,YAAY,EACZ,eAAe,EACf,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAMzD,qBAAa,UAAU;IACrB,OAAO,CAAC,KAAK,CAAgC;IAC7C,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,eAAe,CAAyC;IAChE,OAAO,CAAC,kBAAkB,CAA2C;IAErE,OAAO,CAAC,WAAW;IAOnB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAI9C,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI/B,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI;IAK7C,UAAU,IAAI,IAAI;IAOlB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAInD,eAAe,CAAC,IA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,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAInD,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAItC,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI;IAK5C,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;YAIvC,YAAY;YAcZ,iBAAiB;IAmB/B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAsBpC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAerC,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAqB1D,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAsB7C,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAetD,OAAO,CAAC,oBAAoB;CAgB7B"}
@@ -96,8 +96,7 @@ export class PageLoader {
96
96
  return;
97
97
  logger.debug(`Prefetching ${path}`);
98
98
  try {
99
- const data = await this.fetchPageData(path);
100
- this.setCache(path, data);
99
+ await this.loadPage(path);
101
100
  }
102
101
  catch (error) {
103
102
  logger.warn(`[Veryfront] Failed to prefetch ${path}`, error instanceof Error ? error : new Error(String(error)));
@@ -142,8 +141,7 @@ export class PageLoader {
142
141
  return;
143
142
  logger.debug(`Prefetching SPA page data for ${path}`);
144
143
  try {
145
- const data = await this.fetchSpaPageData(path);
146
- this.setSpaCache(path, data);
144
+ await this.loadSpaPageData(path);
147
145
  }
148
146
  catch (error) {
149
147
  logger.warn(`[Veryfront] Failed to prefetch SPA data for ${path}`, error instanceof Error ? error : new Error(String(error)));
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/mdx/esm-module-loader/cache/index.ts"],"names":[],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,EAAE,GAAG,IAAI,CA0ElE;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,EACnB,YAAY,SAAwB,GACnC,IAAI,CAgBN;AAOD,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAevD;AAED,wBAAsB,yBAAyB,CAC7C,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,IAAI,CAAC,CAwCf;AAED,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAc1D;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAIzD;AAmBD,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,EACnB,YAAY,CAAC,EAAE,MAAM,EAAE,oDAAoD;AAC3E,eAAe,CAAC,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAA;CAAE,EAChE,YAAY,SAAwB,GACnC,OAAO,CAAC,iBAAiB,CAAC,CA+J5B"}
@@ -15,6 +15,7 @@ import { LRUCache } from "../../../../utils/lru-wrapper.js";
15
15
  import { registerCache } from "../../../../utils/memory/index.js";
16
16
  import { buildMdxEsmPathCacheKey, MDX_ESM_ALL_FILE_URL_PATTERN_SOURCE } from "../cache-format.js";
17
17
  import { ensureMdxModuleDependencies } from "../module-fetcher/dependency-recovery.js";
18
+ import { findStaticImportFromSpans } from "../utils/source-spans.js";
18
19
  export { getLocalFs } from "./local-fs.js";
19
20
  import { getLocalFs } from "./local-fs.js";
20
21
  const MAX_VERIFIED_MODULE_DEPS = 2_000;
@@ -105,27 +106,20 @@ async function findMissingFileDependencies(code) {
105
106
  }
106
107
  return missing;
107
108
  }
108
- /**
109
- * Pattern to match unresolved /_vf_modules/ imports that weren't converted to proper file:// paths.
110
- * Matches both:
111
- * - `from "/_vf_modules/..."` or `from "_vf_modules/..."` (unresolved)
112
- * - `from "file:///_vf_modules/..."` (malformed - points to non-existent root /_vf_modules/)
113
- * Note: Uses \s* instead of \s+ because minified code may have no space after `from`.
114
- * These imports will fail at runtime because they can't be resolved by Deno's dynamic import.
115
- */
116
- const UNRESOLVED_VF_MODULES_PATTERN = /from\s*["']((?:file:\/\/)?\/?\/?_vf_modules\/[^"']+)["']/g;
109
+ function matchUnresolvedVfModuleSpecifier(specifier) {
110
+ return specifier.match(/^((?:file:\/\/)?\/?\/?_vf_modules\/[^?]+)(?:\?.*)?$/)?.[1] ?? null;
111
+ }
117
112
  /**
118
113
  * Check if cached code has unresolved or malformed /_vf_modules/ imports.
119
114
  * These should have been resolved to proper file:// paths (e.g., file:///Users/.cache/...).
120
115
  * Returns true if any unresolved or malformed imports are found.
121
116
  */
122
117
  function hasUnresolvedVfModules(code) {
123
- const pattern = new RegExp(UNRESOLVED_VF_MODULES_PATTERN.source, "g");
124
- let match;
125
- while ((match = pattern.exec(code)) !== null) {
126
- const importPath = match[1];
118
+ const matches = findStaticImportFromSpans(code, matchUnresolvedVfModuleSpecifier);
119
+ const first = matches[0];
120
+ if (first) {
127
121
  logger.debug(`${LOG_PREFIX_MDX_LOADER} Cached module has unresolved _vf_modules import`, {
128
- importPath,
122
+ importPath: first.path,
129
123
  });
130
124
  return true;
131
125
  }
@@ -11,7 +11,7 @@ import type { ESMLoaderContext } from "./types.js";
11
11
  /**
12
12
  * Rewrite @/ aliased imports to /_vf_modules/ paths.
13
13
  */
14
- export declare function rewriteProjectAliasImports(code: string): string;
14
+ export declare function rewriteProjectAliasImports(code: string): Promise<string>;
15
15
  /**
16
16
  * Transform bare React specifiers to local file:// paths for Bun/Node.
17
17
  * This ensures the same React instance as react-dom-server.
@@ -1 +1 @@
1
- {"version":3,"file":"import-transformer.d.ts","sourceRoot":"","sources":["../../../../../src/src/transforms/mdx/esm-module-loader/import-transformer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAe5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAK/D;AAED;;;;GAIG;AACH,wBAAsB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAK9E;AAyBD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,GAAG,MAAM,CAIjF;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,gBAAgB,CAAC,SAAS,CAAC,EACpC,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,CA6HjB"}
1
+ {"version":3,"file":"import-transformer.d.ts","sourceRoot":"","sources":["../../../../../src/src/transforms/mdx/esm-module-loader/import-transformer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAa5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD;;GAEG;AACH,wBAAsB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAO9E;AAED;;;;GAIG;AACH,wBAAsB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAK9E;AAyBD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,GAAG,MAAM,CAIjF;AAOD;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,gBAAgB,CAAC,SAAS,CAAC,EACpC,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,CAwHjB"}