veryfront 0.1.826 → 0.1.828
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/build/production-build/build/output-generator.d.ts.map +1 -1
- package/esm/src/build/production-build/build/output-generator.js +4 -2
- package/esm/src/html/html-shell-generator.js +2 -2
- package/esm/src/html/hydration-script-builder/index.d.ts +1 -1
- package/esm/src/html/hydration-script-builder/index.d.ts.map +1 -1
- package/esm/src/html/hydration-script-builder/index.js +1 -1
- package/esm/src/html/hydration-script-builder/prod-scripts.d.ts +3 -0
- package/esm/src/html/hydration-script-builder/prod-scripts.d.ts.map +1 -1
- package/esm/src/html/hydration-script-builder/prod-scripts.js +14 -1
- package/esm/src/modules/react-loader/ssr-module-loader/import-rewriter.d.ts +2 -2
- package/esm/src/modules/react-loader/ssr-module-loader/import-rewriter.d.ts.map +1 -1
- package/esm/src/modules/react-loader/ssr-module-loader/import-rewriter.js +14 -22
- package/esm/src/modules/react-loader/ssr-module-loader/loader.js +2 -2
- 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 +11 -4
- package/esm/src/modules/react-loader/ssr-module-loader/vf-module-resolver.d.ts +2 -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 +22 -15
- package/esm/src/release-assets/build-executor.d.ts.map +1 -1
- package/esm/src/release-assets/build-executor.js +43 -62
- package/esm/src/release-assets/html-consumption.d.ts +2 -1
- package/esm/src/release-assets/html-consumption.d.ts.map +1 -1
- package/esm/src/release-assets/html-consumption.js +4 -2
- package/esm/src/rendering/rsc/component-analyzer.d.ts.map +1 -1
- package/esm/src/rendering/rsc/component-analyzer.js +2 -1
- package/esm/src/rendering/rsc/export-extractor.d.ts +5 -3
- package/esm/src/rendering/rsc/export-extractor.d.ts.map +1 -1
- package/esm/src/rendering/rsc/export-extractor.js +59 -36
- package/esm/src/server/handlers/request/prod-hydration-module.handler.d.ts.map +1 -1
- package/esm/src/server/handlers/request/prod-hydration-module.handler.js +10 -3
- package/esm/src/server/handlers/request/static.handler.d.ts.map +1 -1
- package/esm/src/server/handlers/request/static.handler.js +2 -0
- package/esm/src/server/runtime-handler/request-utils.js +1 -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 +8 -14
- package/esm/src/transforms/mdx/esm-module-loader/import-transformer.d.ts +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/import-transformer.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/import-transformer.js +32 -26
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/nested-imports.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/nested-imports.js +7 -5
- package/esm/src/transforms/mdx/esm-module-loader/module-writer.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/module-writer.js +8 -8
- package/esm/src/transforms/pipeline/stages/ssr-vf-modules/import-finder.d.ts +2 -2
- package/esm/src/transforms/pipeline/stages/ssr-vf-modules/import-finder.d.ts.map +1 -1
- package/esm/src/transforms/pipeline/stages/ssr-vf-modules/import-finder.js +16 -26
- package/esm/src/transforms/pipeline/stages/ssr-vf-modules/index.js +1 -1
- package/esm/src/transforms/pipeline/stages/ssr-vf-modules/transform.d.ts.map +1 -1
- package/esm/src/transforms/pipeline/stages/ssr-vf-modules/transform.js +8 -5
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +1 -1
package/esm/deno.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/build/production-build/build/output-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"output-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/build/production-build/build/output-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAe1F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAEvF,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,cAAc,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,KAAK,EAAE,UAAU,CAAC;IAClB,eAAe,EAAE,OAAO,CAAC;IACzB,cAAc,EAAE,OAAO,CAAC;IACxB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,aAAa,EAAE,aAAa,GAAG,IAAI,CAAC;IACpC,MAAM,EAAE,OAAO,CAAC;IAChB,oBAAoB,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAAC;CACpD;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,OAAO,GACd,OAAO,CAAC,IAAI,CAAC,CAwBf;AAED;;GAEG;AACH,wBAAsB,gCAAgC,CACpD,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,IAAI,CAAC,CAgCf;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,OAAO,GACd,OAAO,CAAC,IAAI,CAAC,CAGf;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,cAAc,EACvB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,OAAO,GACd,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAEhD;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmBvF"}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import { serverLogger as logger } from "../../../utils/index.js";
|
|
12
12
|
import { join } from "../../../platform/compat/path/index.js";
|
|
13
13
|
import { generateServiceWorker } from "../../../server/build-service-worker.js";
|
|
14
|
-
import { generateProdHydrationModule } from "../../../html/hydration-script-builder/prod-scripts.js";
|
|
14
|
+
import { generateProdHydrationModule, getProdHydrationModulePath, } from "../../../html/hydration-script-builder/prod-scripts.js";
|
|
15
15
|
import { copyStaticAssets } from "../asset-generation.js";
|
|
16
16
|
import { generateAppModule, generateClientModule, generatePrefetchScript, generateRouterScript, } from "../client-runtime.js";
|
|
17
17
|
import { generateLocalReleaseAssetManifest } from "../local-release-assets.js";
|
|
@@ -27,7 +27,9 @@ export async function generateClientScripts(adapter, outputDir, dryRun) {
|
|
|
27
27
|
await adapter.fs.writeFile(join(outputDir, "_veryfront/client.js"), await generateClientModule());
|
|
28
28
|
await adapter.fs.writeFile(join(outputDir, "_veryfront/router.js"), await generateRouterScript(adapter));
|
|
29
29
|
await adapter.fs.writeFile(join(outputDir, "_veryfront/prefetch.js"), await generatePrefetchScript(adapter));
|
|
30
|
-
|
|
30
|
+
const hydrationRuntime = generateProdHydrationModule();
|
|
31
|
+
await adapter.fs.writeFile(join(outputDir, "_veryfront/hydration-runtime.js"), hydrationRuntime);
|
|
32
|
+
await adapter.fs.writeFile(join(outputDir, getProdHydrationModulePath().slice(1)), hydrationRuntime);
|
|
31
33
|
}
|
|
32
34
|
/**
|
|
33
35
|
* Generate manifest and service worker
|
|
@@ -9,7 +9,7 @@ import { getReadyManifestForRenderAsync } from "../release-assets/manifest-cache
|
|
|
9
9
|
import { resolveManifestModuleUrl, resolveManifestRoutePreloadUrls, } from "../release-assets/html-consumption.js";
|
|
10
10
|
import { routeForPage } from "../release-assets/route-path.js";
|
|
11
11
|
import { buildNonceAttribute, escapeHTML } from "./html-escape.js";
|
|
12
|
-
import { generateHydrationData, getDevScripts,
|
|
12
|
+
import { generateHydrationData, getDevScripts, getProdHydrationModulePath, getProdScripts, } from "./hydration-script-builder/index.js";
|
|
13
13
|
import { getPreviewStylesheetLink, getStudioScripts } from "./dev-scripts.js";
|
|
14
14
|
import { processMetadata } from "./metadata-builder.js";
|
|
15
15
|
import { extractCandidates, getDevStyles as getErrorOverlayStyles, getProjectCSS, } from "./styles-builder/index.js";
|
|
@@ -169,7 +169,7 @@ async function generateHTMLShellPartsImpl(meta, options, params, props, contentF
|
|
|
169
169
|
: "";
|
|
170
170
|
const prodHydrationModulePreload = useDevScripts
|
|
171
171
|
? ""
|
|
172
|
-
: `<link rel="modulepreload" href="${
|
|
172
|
+
: `<link rel="modulepreload" href="${getProdHydrationModulePath()}">`;
|
|
173
173
|
const nonceAttr = buildNonceAttribute(nonce);
|
|
174
174
|
// Expose project slug for runtime error overlay "Fix in Veryfront" button
|
|
175
175
|
const overlaySlug = options.projectId || meta.slug;
|
|
@@ -9,6 +9,6 @@ export { getDevScripts } from "./dev-scripts.js";
|
|
|
9
9
|
export { generateDevErrorLoggerScript } from "./dev-error-logger.js";
|
|
10
10
|
export { generateDevComponentManifestScript } from "./dev-component-manifest.js";
|
|
11
11
|
export { generateDevClientRendererScript } from "./dev-client-renderer.js";
|
|
12
|
-
export { generateProdHydrationModule, getProdScripts, PROD_HYDRATION_MODULE_PATH, } from "./prod-scripts.js";
|
|
12
|
+
export { generateProdHydrationModule, getProdHydrationModulePath, getProdScripts, isVersionedProdHydrationModulePath, PROD_HYDRATION_MODULE_PATH, PROD_HYDRATION_MODULE_VERSIONED_PATH_PATTERN, } from "./prod-scripts.js";
|
|
13
13
|
export { generateProdHydrationScript } from "./prod-hydration.js";
|
|
14
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/html/hydration-script-builder/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,kCAAkC,EAAE,MAAM,6BAA6B,CAAC;AACjF,OAAO,EAAE,+BAA+B,EAAE,MAAM,0BAA0B,CAAC;AAE3E,OAAO,EACL,2BAA2B,EAC3B,cAAc,EACd,0BAA0B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/html/hydration-script-builder/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,kCAAkC,EAAE,MAAM,6BAA6B,CAAC;AACjF,OAAO,EAAE,+BAA+B,EAAE,MAAM,0BAA0B,CAAC;AAE3E,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAC1B,cAAc,EACd,kCAAkC,EAClC,0BAA0B,EAC1B,4CAA4C,GAC7C,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -8,5 +8,5 @@ export { getDevScripts } from "./dev-scripts.js";
|
|
|
8
8
|
export { generateDevErrorLoggerScript } from "./dev-error-logger.js";
|
|
9
9
|
export { generateDevComponentManifestScript } from "./dev-component-manifest.js";
|
|
10
10
|
export { generateDevClientRendererScript } from "./dev-client-renderer.js";
|
|
11
|
-
export { generateProdHydrationModule, getProdScripts, PROD_HYDRATION_MODULE_PATH, } from "./prod-scripts.js";
|
|
11
|
+
export { generateProdHydrationModule, getProdHydrationModulePath, getProdScripts, isVersionedProdHydrationModulePath, PROD_HYDRATION_MODULE_PATH, PROD_HYDRATION_MODULE_VERSIONED_PATH_PATTERN, } from "./prod-scripts.js";
|
|
12
12
|
export { generateProdHydrationScript } from "./prod-hydration.js";
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export declare const PROD_HYDRATION_MODULE_PATH = "/_veryfront/hydration-runtime.js";
|
|
2
|
+
export declare const PROD_HYDRATION_MODULE_VERSIONED_PATH_PATTERN: RegExp;
|
|
2
3
|
export declare function generateProdHydrationModule(): string;
|
|
4
|
+
export declare function getProdHydrationModulePath(): string;
|
|
5
|
+
export declare function isVersionedProdHydrationModulePath(pathname: string): boolean;
|
|
3
6
|
export declare function getProdScripts(_slug: string, _params?: Record<string, string | string[]>, _props?: Record<string, unknown>, nonce?: string): string;
|
|
4
7
|
//# sourceMappingURL=prod-scripts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prod-scripts.d.ts","sourceRoot":"","sources":["../../../../src/src/html/hydration-script-builder/prod-scripts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prod-scripts.d.ts","sourceRoot":"","sources":["../../../../src/src/html/hydration-script-builder/prod-scripts.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,0BAA0B,qCAAqC,CAAC;AAC7E,eAAO,MAAM,4CAA4C,QACH,CAAC;AAIvD,wBAAgB,2BAA2B,IAAI,MAAM,CAUpD;AAED,wBAAgB,0BAA0B,IAAI,MAAM,CAMnD;AAED,wBAAgB,kCAAkC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE5E;AAED,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAC3C,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,KAAK,CAAC,EAAE,MAAM,GACb,MAAM,CAGR"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { getLoaderScript, getRendererScript, getRouterScript } from "./templates/index.js";
|
|
2
2
|
import { buildNonceAttribute } from "../html-escape.js";
|
|
3
|
+
import { fnv1aHash } from "../../utils/hash-utils.js";
|
|
3
4
|
export const PROD_HYDRATION_MODULE_PATH = "/_veryfront/hydration-runtime.js";
|
|
5
|
+
export const PROD_HYDRATION_MODULE_VERSIONED_PATH_PATTERN = /^\/_veryfront\/hydration-runtime\.[0-9a-f]{8}\.js$/;
|
|
6
|
+
let cachedProdHydrationModulePath = null;
|
|
4
7
|
export function generateProdHydrationModule() {
|
|
5
8
|
return [
|
|
6
9
|
`import * as React from 'react';`,
|
|
@@ -12,7 +15,17 @@ export function generateProdHydrationModule() {
|
|
|
12
15
|
getRendererScript().trim(),
|
|
13
16
|
].join("\n\n");
|
|
14
17
|
}
|
|
18
|
+
export function getProdHydrationModulePath() {
|
|
19
|
+
if (cachedProdHydrationModulePath)
|
|
20
|
+
return cachedProdHydrationModulePath;
|
|
21
|
+
const hash = fnv1aHash(generateProdHydrationModule()).padStart(8, "0");
|
|
22
|
+
cachedProdHydrationModulePath = `/_veryfront/hydration-runtime.${hash}.js`;
|
|
23
|
+
return cachedProdHydrationModulePath;
|
|
24
|
+
}
|
|
25
|
+
export function isVersionedProdHydrationModulePath(pathname) {
|
|
26
|
+
return PROD_HYDRATION_MODULE_VERSIONED_PATH_PATTERN.test(pathname);
|
|
27
|
+
}
|
|
15
28
|
export function getProdScripts(_slug, _params, _props, nonce) {
|
|
16
29
|
const nonceAttr = buildNonceAttribute(nonce);
|
|
17
|
-
return `\n <script type="module" src="${
|
|
30
|
+
return `\n <script type="module" src="${getProdHydrationModulePath()}"${nonceAttr}></script>`;
|
|
18
31
|
}
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
/**
|
|
10
10
|
* Rewrite a cross-project import specifier to use a local temp path.
|
|
11
11
|
*/
|
|
12
|
-
export declare function rewriteCrossProjectImport(transformed: string, specifier: string, tempPath: string): string
|
|
12
|
+
export declare function rewriteCrossProjectImport(transformed: string, specifier: string, tempPath: string): Promise<string>;
|
|
13
13
|
/**
|
|
14
14
|
* Rewrite local imports to use hashed temp paths.
|
|
15
15
|
* This ensures each content version uses its own cached module file.
|
|
16
16
|
*/
|
|
17
|
-
export declare function rewriteLocalImports(transformed: string, localImportPaths: Map<string, string>, fromFilePath: string, projectDir: string): string
|
|
17
|
+
export declare function rewriteLocalImports(transformed: string, localImportPaths: Map<string, string>, fromFilePath: string, projectDir: string): Promise<string>;
|
|
18
18
|
//# sourceMappingURL=import-rewriter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-rewriter.d.ts","sourceRoot":"","sources":["../../../../../src/src/modules/react-loader/ssr-module-loader/import-rewriter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"import-rewriter.d.ts","sourceRoot":"","sources":["../../../../../src/src/modules/react-loader/ssr-module-loader/import-rewriter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH;;GAEG;AACH,wBAAsB,yBAAyB,CAC7C,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,CAYjB;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,MAAM,EACnB,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACrC,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC,CA2BjB"}
|
|
@@ -6,27 +6,24 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module module-system/react-loader/ssr-module-loader/import-rewriter
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
const IMPORT_FROM_SUFFIX = "[\"']";
|
|
11
|
-
const REGEX_ESCAPE = /[.*+?^${}()|[\]\\]/g;
|
|
12
|
-
function escapeRegExp(value) {
|
|
13
|
-
return value.replace(REGEX_ESCAPE, "\\$&");
|
|
14
|
-
}
|
|
9
|
+
import { replaceSpecifiers } from "../../../transforms/esm/lexer.js";
|
|
15
10
|
/**
|
|
16
11
|
* Rewrite a cross-project import specifier to use a local temp path.
|
|
17
12
|
*/
|
|
18
|
-
export function rewriteCrossProjectImport(transformed, specifier, tempPath) {
|
|
13
|
+
export async function rewriteCrossProjectImport(transformed, specifier, tempPath) {
|
|
19
14
|
const jsSpecifier = toJsExtension(specifier);
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
const replacement = `file://${tempPath}`;
|
|
16
|
+
const replacements = new Map([
|
|
17
|
+
[specifier, replacement],
|
|
18
|
+
[jsSpecifier, replacement],
|
|
19
|
+
]);
|
|
20
|
+
return await replaceSpecifiers(transformed, (importSpecifier) => replacements.get(importSpecifier) ?? null);
|
|
24
21
|
}
|
|
25
22
|
/**
|
|
26
23
|
* Rewrite local imports to use hashed temp paths.
|
|
27
24
|
* This ensures each content version uses its own cached module file.
|
|
28
25
|
*/
|
|
29
|
-
export function rewriteLocalImports(transformed, localImportPaths, fromFilePath, projectDir) {
|
|
26
|
+
export async function rewriteLocalImports(transformed, localImportPaths, fromFilePath, projectDir) {
|
|
30
27
|
if (localImportPaths.size === 0)
|
|
31
28
|
return transformed;
|
|
32
29
|
const normalizedProjectDir = projectDir.replace(/\/$/, "");
|
|
@@ -34,23 +31,18 @@ export function rewriteLocalImports(transformed, localImportPaths, fromFilePath,
|
|
|
34
31
|
const fromRelativeDir = fromFileDir.startsWith(normalizedProjectDir)
|
|
35
32
|
? fromFileDir.substring(normalizedProjectDir.length + 1)
|
|
36
33
|
: fromFileDir;
|
|
37
|
-
const
|
|
34
|
+
const replacements = new Map();
|
|
38
35
|
for (const [specifierOrPath, tempPath] of localImportPaths) {
|
|
39
36
|
const patterns = buildImportPatterns(specifierOrPath, fromRelativeDir, normalizedProjectDir);
|
|
40
37
|
for (const pattern of patterns) {
|
|
41
|
-
if (!
|
|
42
|
-
|
|
38
|
+
if (!replacements.has(pattern)) {
|
|
39
|
+
replacements.set(pattern, `file://${tempPath}`);
|
|
43
40
|
}
|
|
44
41
|
}
|
|
45
42
|
}
|
|
46
|
-
if (
|
|
43
|
+
if (replacements.size === 0)
|
|
47
44
|
return transformed;
|
|
48
|
-
|
|
49
|
-
const regex = new RegExp(`${IMPORT_FROM_PREFIX}(${importPattern})${IMPORT_FROM_SUFFIX}`, "g");
|
|
50
|
-
return transformed.replace(regex, (match, specifier) => {
|
|
51
|
-
const tempPath = replacementByPattern.get(specifier);
|
|
52
|
-
return tempPath === undefined ? match : `from "file://${tempPath}"`;
|
|
53
|
-
});
|
|
45
|
+
return await replaceSpecifiers(transformed, (importSpecifier) => replacements.get(importSpecifier) ?? null);
|
|
54
46
|
}
|
|
55
47
|
/**
|
|
56
48
|
* Build import patterns for a given specifier to match in transformed code.
|
|
@@ -397,9 +397,9 @@ export class SSRModuleLoader {
|
|
|
397
397
|
};
|
|
398
398
|
let transformed = await withSpan(SpanNames.SSR_TRANSFORM_SINGLE, () => transformToESM(code, filePath, this.options.projectDir, this.options.adapter, transformOpts), { "ssr.file": filePath.split("/").pop() || filePath });
|
|
399
399
|
for (const [specifier, tempPath] of crossProjectPaths.entries()) {
|
|
400
|
-
transformed = rewriteCrossProjectImport(transformed, specifier, tempPath);
|
|
400
|
+
transformed = await rewriteCrossProjectImport(transformed, specifier, tempPath);
|
|
401
401
|
}
|
|
402
|
-
transformed = rewriteLocalImports(transformed, localImportPaths, filePath, this.options.projectDir);
|
|
402
|
+
transformed = await rewriteLocalImports(transformed, localImportPaths, filePath, this.options.projectDir);
|
|
403
403
|
transformed = await resolveVfModuleImports(transformed, {
|
|
404
404
|
filePath,
|
|
405
405
|
projectId: this.options.projectId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssr-cache-manager.d.ts","sourceRoot":"","sources":["../../../../../src/src/modules/react-loader/ssr-module-loader/ssr-cache-manager.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"ssr-cache-manager.d.ts","sourceRoot":"","sources":["../../../../../src/src/modules/react-loader/ssr-module-loader/ssr-cache-manager.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAalE,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAQ3E;;;;;;;GAOG;AACH,qBAAa,eAAe;IAId,OAAO,CAAC,OAAO;IAH3B,OAAO,CAAC,EAAE,CAAsB;IAChC,OAAO,CAAC,gBAAgB,CAAqB;gBAEzB,OAAO,EAAE,sBAAsB;IAEnD,4DAA4D;IAC5D,aAAa,IAAI,MAAM;IAUvB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAkB/B,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAiBlD,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAK1E,yBAAyB,IAAI,OAAO;IAoB9B,kBAAkB,CACtB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,cAAc,GAAG,aAAa,EACtC,OAAO,EAAE;QAAE,eAAe,EAAE,OAAO,CAAC;QAAC,qBAAqB,EAAE,OAAO,CAAA;KAAE,GACpE,OAAO,CAAC,OAAO,CAAC;IAgCb,wBAAwB,CAC5B,WAAW,EAAE,gBAAgB,EAC7B,eAAe,EAAE,MAAM,EACvB,gBAAgB,EAAE,MAAM,EACxB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,OAAO,CAAC;IAuBnB,4BAA4B,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,gBAAgB,GAAG,IAAI;IAOnF,oCAAoC,CAClC,eAAe,EAAE,MAAM,EACvB,gBAAgB,EAAE,MAAM,EACxB,UAAU,CAAC,EAAE,gBAAgB,GAC5B,IAAI;IAQP,wDAAwD;IACxD,KAAK,IAAI,UAAU,CAAC,OAAO,gBAAgB,CAAC;YAI9B,4BAA4B;YAW5B,qBAAqB;YAsBrB,oBAAoB;YAuDpB,YAAY;CA2B3B"}
|
|
@@ -15,6 +15,7 @@ import { createFileSystem } from "../../../platform/compat/fs.js";
|
|
|
15
15
|
import { rendererLogger } from "../../../utils/index.js";
|
|
16
16
|
import { hashCodeHex } from "../../../utils/hash-utils.js";
|
|
17
17
|
import { ensureHttpBundlesExist } from "../../../transforms/esm/http-cache.js";
|
|
18
|
+
import { parseImports } from "../../../transforms/esm/lexer.js";
|
|
18
19
|
import { getHttpBundleCacheDir, getMdxEsmCacheDir } from "../../../utils/cache-dir.js";
|
|
19
20
|
import { globalModuleCache, globalTmpDirs } from "./cache/index.js";
|
|
20
21
|
import { extractAllFilePathsRecursive, extractAllHttpBundlePathsRecursive, verifiedHttpBundlePaths, } from "./http-bundle-helpers.js";
|
|
@@ -23,7 +24,6 @@ import { ensureMdxModuleDependencies } from "../../../transforms/mdx/esm-module-
|
|
|
23
24
|
const logger = rendererLogger.component("ssr-module-loader");
|
|
24
25
|
/** Content length threshold: below this, use fast sync hash; above, use async SHA-256 */
|
|
25
26
|
const SYNC_HASH_THRESHOLD = 10_000;
|
|
26
|
-
const UNRESOLVED_VF_MODULE_IMPORT_PATTERN = /from\s*["']((?:file:\/\/)?\/?\/?_vf_modules\/[^"']+)["']/;
|
|
27
27
|
/**
|
|
28
28
|
* Manages caching concerns for SSR module loading:
|
|
29
29
|
* - Cache key computation and config hashing
|
|
@@ -108,7 +108,7 @@ export class SSRCacheManager {
|
|
|
108
108
|
if (options.checkLocalPaths && await this.hasMissingLocalPaths(code, filePath)) {
|
|
109
109
|
return false;
|
|
110
110
|
}
|
|
111
|
-
if (this.hasUnresolvedVfModuleImports(code)) {
|
|
111
|
+
if (await this.hasUnresolvedVfModuleImports(code)) {
|
|
112
112
|
logger.warn(source === "memory-cache"
|
|
113
113
|
? "[SSR-MODULE-LOADER] Memory cache has unresolved _vf_modules imports, invalidating"
|
|
114
114
|
: "[SSR-MODULE-LOADER] Redis cache has unresolved _vf_modules imports, re-transforming", { file: filePath.slice(-40) });
|
|
@@ -156,8 +156,15 @@ export class SSRCacheManager {
|
|
|
156
156
|
getFs() {
|
|
157
157
|
return this.fs;
|
|
158
158
|
}
|
|
159
|
-
hasUnresolvedVfModuleImports(code) {
|
|
160
|
-
|
|
159
|
+
async hasUnresolvedVfModuleImports(code) {
|
|
160
|
+
const imports = await parseImports(code);
|
|
161
|
+
return imports.some((importSpecifier) => {
|
|
162
|
+
const rawPath = importSpecifier.n;
|
|
163
|
+
if (!rawPath)
|
|
164
|
+
return false;
|
|
165
|
+
const path = rawPath.replace(/^(?:file:\/\/)?\/+/, "");
|
|
166
|
+
return path.startsWith("_vf_modules/");
|
|
167
|
+
});
|
|
161
168
|
}
|
|
162
169
|
async hasMissingHttpBundles(code, filePath, source) {
|
|
163
170
|
const bundlePaths = await extractAllHttpBundlePathsRecursive(code);
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { RuntimeAdapter } from "../../../platform/adapters/base.js";
|
|
7
7
|
interface VfModuleImport {
|
|
8
|
-
|
|
8
|
+
specifier: string;
|
|
9
9
|
path: string;
|
|
10
10
|
}
|
|
11
11
|
interface ResolveVfModuleImportsOptions {
|
|
@@ -20,7 +20,7 @@ interface ResolveVfModuleImportsOptions {
|
|
|
20
20
|
* Find /_vf_modules/ imports in transformed code.
|
|
21
21
|
* Matches both /_vf_modules/... and file:///_vf_modules/... forms.
|
|
22
22
|
*/
|
|
23
|
-
export declare function findVfModuleImports(code: string): VfModuleImport[]
|
|
23
|
+
export declare function findVfModuleImports(code: string): Promise<VfModuleImport[]>;
|
|
24
24
|
/**
|
|
25
25
|
* Resolve /_vf_modules/ imports to local cached modules and rewrite code.
|
|
26
26
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vf-module-resolver.d.ts","sourceRoot":"","sources":["../../../../../src/src/modules/react-loader/ssr-module-loader/vf-module-resolver.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAWzE,UAAU,cAAc;IACtB,
|
|
1
|
+
{"version":3,"file":"vf-module-resolver.d.ts","sourceRoot":"","sources":["../../../../../src/src/modules/react-loader/ssr-module-loader/vf-module-resolver.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAWzE,UAAU,cAAc;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,6BAA6B;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,cAAc,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAoBjF;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC,MAAM,CAAC,CAyDjB"}
|
|
@@ -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
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
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 ({
|
|
57
|
+
const results = await Promise.all(imports.map(async ({ specifier, path }) => {
|
|
53
58
|
try {
|
|
54
59
|
const cachedFilePath = await fetchAndCacheModule(path, fetcherContext);
|
|
55
|
-
return {
|
|
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 {
|
|
68
|
+
return { specifier, path, cachedFilePath: null };
|
|
64
69
|
}
|
|
65
70
|
}));
|
|
66
|
-
|
|
67
|
-
for (const {
|
|
71
|
+
const replacements = new Map();
|
|
72
|
+
for (const { specifier, path, cachedFilePath } of results) {
|
|
68
73
|
if (cachedFilePath) {
|
|
69
|
-
|
|
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
|
-
|
|
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;
|
|
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,iBA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AE,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
|
|
92
|
-
*
|
|
93
|
-
*
|
|
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
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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 =
|
|
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
|
|
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
|
|
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
|
|
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,
|
|
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"}
|