veryfront 0.1.783 → 0.1.785
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/deno.js +1 -1
- package/esm/src/html/html-shell-generator.js +1 -1
- package/esm/src/html/hydration-script-builder/hydration-data-generator.d.ts +6 -1
- package/esm/src/html/hydration-script-builder/hydration-data-generator.d.ts.map +1 -1
- package/esm/src/html/hydration-script-builder/hydration-data-generator.js +11 -0
- package/esm/src/html/hydration-script-builder/templates/loader.d.ts.map +1 -1
- package/esm/src/html/hydration-script-builder/templates/loader.js +36 -0
- package/esm/src/html/hydration-script-builder/templates/renderer.d.ts.map +1 -1
- package/esm/src/html/hydration-script-builder/templates/renderer.js +3 -0
- package/esm/src/html/hydration-script-builder/templates/router.d.ts.map +1 -1
- package/esm/src/html/hydration-script-builder/templates/router.js +4 -0
- package/esm/src/html/hydration-script-builder/templates/spa-renderer.d.ts.map +1 -1
- package/esm/src/html/hydration-script-builder/templates/spa-renderer.js +3 -0
- package/esm/src/html/hydration-script-builder/types.d.ts +2 -0
- package/esm/src/html/hydration-script-builder/types.d.ts.map +1 -1
- package/esm/src/release-assets/build-executor.d.ts.map +1 -1
- package/esm/src/release-assets/build-executor.js +76 -29
- 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
|
@@ -142,7 +142,7 @@ async function generateHTMLShellPartsImpl(meta, options, params, props, contentF
|
|
|
142
142
|
pretty: useDevScripts,
|
|
143
143
|
releaseAssetManifest: releaseManifest,
|
|
144
144
|
});
|
|
145
|
-
const hydrationDataJson = generateHydrationData(meta.slug || "", params ?? {}, props ?? {}, options, { pretty: useDevScripts });
|
|
145
|
+
const hydrationDataJson = generateHydrationData(meta.slug || "", params ?? {}, props ?? {}, { ...options, releaseAssetManifest: releaseManifest }, { pretty: useDevScripts });
|
|
146
146
|
const nonce = options.nonce ?? "";
|
|
147
147
|
const modeScripts = useDevScripts
|
|
148
148
|
? getDevScripts(meta.slug || "", options.config, params, props, nonce, {
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { ComponentProps } from "../../types/index.js";
|
|
2
|
+
import type { ReleaseAssetManifest } from "../../release-assets/manifest-schema.js";
|
|
2
3
|
import type { HTMLGenerationOptions } from "../types.js";
|
|
3
|
-
|
|
4
|
+
type HydrationOptions = HTMLGenerationOptions & {
|
|
5
|
+
releaseAssetManifest?: ReleaseAssetManifest | null;
|
|
6
|
+
};
|
|
7
|
+
export declare function generateHydrationData(slug: string, params: Record<string, string | string[]>, props: ComponentProps, options: HydrationOptions, serializeOptions?: {
|
|
4
8
|
pretty?: boolean;
|
|
5
9
|
}): string;
|
|
10
|
+
export {};
|
|
6
11
|
//# sourceMappingURL=hydration-data-generator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hydration-data-generator.d.ts","sourceRoot":"","sources":["../../../../src/src/html/hydration-script-builder/hydration-data-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"hydration-data-generator.d.ts","sourceRoot":"","sources":["../../../../src/src/html/hydration-script-builder/hydration-data-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAM3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AACpF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AA8BzD,KAAK,gBAAgB,GAAG,qBAAqB,GAAG;IAC9C,oBAAoB,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAAC;CACpD,CAAC;AAcF,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EACzC,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,gBAAgB,EACzB,gBAAgB,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GACtC,MAAM,CAiDR"}
|
|
@@ -2,6 +2,7 @@ import { resolveRelativePath } from "../../modules/react-loader/path-resolver.js
|
|
|
2
2
|
import { getExtensionName } from "../../utils/path-utils.js";
|
|
3
3
|
import { determineClientModuleStrategy } from "../../rendering/rsc/client-module-strategy.js";
|
|
4
4
|
import { jsonForInlineScript } from "../../security/client/html-sanitizer.js";
|
|
5
|
+
import { releaseAssetUrl } from "../../release-assets/constants.js";
|
|
5
6
|
function toProjectRelativePath(absolutePath, projectDir) {
|
|
6
7
|
if (!absolutePath)
|
|
7
8
|
return "";
|
|
@@ -19,6 +20,15 @@ function inferPageType(pagePath) {
|
|
|
19
20
|
return undefined;
|
|
20
21
|
return PAGE_TYPE_EXTENSIONS.has(ext) ? ext : undefined;
|
|
21
22
|
}
|
|
23
|
+
function buildReleaseAssetModules(manifest) {
|
|
24
|
+
if (!manifest)
|
|
25
|
+
return undefined;
|
|
26
|
+
const modules = {};
|
|
27
|
+
for (const [path, entry] of Object.entries(manifest.modules)) {
|
|
28
|
+
modules[path] = releaseAssetUrl(entry.contentHash, "js");
|
|
29
|
+
}
|
|
30
|
+
return Object.keys(modules).length > 0 ? modules : undefined;
|
|
31
|
+
}
|
|
22
32
|
export function generateHydrationData(slug, params, props, options, serializeOptions) {
|
|
23
33
|
const layouts = (options.nestedLayouts ?? [])
|
|
24
34
|
.map((layout) => {
|
|
@@ -51,6 +61,7 @@ export function generateHydrationData(slug, params, props, options, serializeOpt
|
|
|
51
61
|
isLocalProject: options.isLocalProject,
|
|
52
62
|
environment: options.environment,
|
|
53
63
|
}),
|
|
64
|
+
releaseAssetModules: buildReleaseAssetModules(options.releaseAssetManifest),
|
|
54
65
|
frontmatter: options.frontmatter,
|
|
55
66
|
layoutProps: options.layoutProps,
|
|
56
67
|
// In dev mode, client uses createRoot instead of hydrateRoot to avoid
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../../src/src/html/hydration-script-builder/templates/loader.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,QAAO,
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../../src/src/html/hydration-script-builder/templates/loader.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,QAAO,MA8IlC,CAAC"}
|
|
@@ -22,7 +22,41 @@ export const getLoaderScript = () => `
|
|
|
22
22
|
return url + (url.includes('?') ? '&' : '?') + key + '=' + value;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
let __releaseAssetModules = null;
|
|
26
|
+
function setReleaseAssetModules(value) {
|
|
27
|
+
__releaseAssetModules =
|
|
28
|
+
value && typeof value === 'object' && !Array.isArray(value) ? value : null;
|
|
29
|
+
window.__veryfrontReleaseAssetModules = __releaseAssetModules;
|
|
30
|
+
}
|
|
31
|
+
window.__veryfrontSetReleaseAssetModules = setReleaseAssetModules;
|
|
32
|
+
|
|
33
|
+
function normalizeReleaseAssetModulePath(path) {
|
|
34
|
+
return String(path || '')
|
|
35
|
+
.replace(/^\\/?_vf_modules\\//, '')
|
|
36
|
+
.replace(/^\\/+/, '')
|
|
37
|
+
.replace(/[?#].*$/, '');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function resolveReleaseAssetModuleUrl(path) {
|
|
41
|
+
if (!__releaseAssetModules || __studioEmbed || __hmrRefreshTimestamp) return null;
|
|
42
|
+
|
|
43
|
+
const key = normalizeReleaseAssetModulePath(path);
|
|
44
|
+
if (__releaseAssetModules[key]) return __releaseAssetModules[key];
|
|
45
|
+
|
|
46
|
+
const withoutExt = key.replace(/\\.(tsx|ts|jsx|mdx|js|mjs)$/, '');
|
|
47
|
+
const extensions = ['.tsx', '.ts', '.jsx', '.mdx', '.js'];
|
|
48
|
+
for (const ext of extensions) {
|
|
49
|
+
const candidate = withoutExt + ext;
|
|
50
|
+
if (__releaseAssetModules[candidate]) return __releaseAssetModules[candidate];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
|
|
25
56
|
function pathToModuleUrl(path, studioEmbed) {
|
|
57
|
+
const releaseAssetUrl = resolveReleaseAssetModuleUrl(path);
|
|
58
|
+
if (releaseAssetUrl) return releaseAssetUrl;
|
|
59
|
+
|
|
26
60
|
const pattern = /(pages|components|app|lib|layouts|shared|features)\\/(.+)\\.(tsx|ts|jsx|mdx)$/;
|
|
27
61
|
|
|
28
62
|
const match =
|
|
@@ -49,12 +83,14 @@ export const getLoaderScript = () => `
|
|
|
49
83
|
let __studioEmbed = false;
|
|
50
84
|
function setStudioEmbed(value) {
|
|
51
85
|
__studioEmbed = value;
|
|
86
|
+
window.__veryfrontStudioEmbed = value;
|
|
52
87
|
}
|
|
53
88
|
window.__veryfrontSetStudioEmbed = setStudioEmbed;
|
|
54
89
|
|
|
55
90
|
let __hmrRefreshTimestamp = null;
|
|
56
91
|
function setHMRRefreshTimestamp(timestamp) {
|
|
57
92
|
__hmrRefreshTimestamp = timestamp;
|
|
93
|
+
window.__veryfrontHMRRefreshTimestamp = timestamp;
|
|
58
94
|
}
|
|
59
95
|
window.__veryfrontSetHMRRefreshTimestamp = setHMRRefreshTimestamp;
|
|
60
96
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../../../../src/src/html/hydration-script-builder/templates/renderer.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../../../../src/src/html/hydration-script-builder/templates/renderer.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,cAqN7B,CAAC"}
|
|
@@ -33,6 +33,9 @@ export const getRendererScript = () => `
|
|
|
33
33
|
if (data.studioEmbed && window.__veryfrontSetStudioEmbed) {
|
|
34
34
|
window.__veryfrontSetStudioEmbed(true);
|
|
35
35
|
}
|
|
36
|
+
if (data.releaseAssetModules && window.__veryfrontSetReleaseAssetModules) {
|
|
37
|
+
window.__veryfrontSetReleaseAssetModules(data.releaseAssetModules);
|
|
38
|
+
}
|
|
36
39
|
|
|
37
40
|
try {
|
|
38
41
|
let pageModule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../../../src/src/html/hydration-script-builder/templates/router.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../../../src/src/html/hydration-script-builder/templates/router.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,cAmrB3B,CAAC"}
|
|
@@ -401,6 +401,10 @@ export const getRouterScript = () => `
|
|
|
401
401
|
// Render page from page data
|
|
402
402
|
// ============================================
|
|
403
403
|
async function renderPageFromData(pageData, targetPath) {
|
|
404
|
+
if (pageData.releaseAssetModules && window.__veryfrontSetReleaseAssetModules) {
|
|
405
|
+
window.__veryfrontSetReleaseAssetModules(pageData.releaseAssetModules);
|
|
406
|
+
}
|
|
407
|
+
|
|
404
408
|
perfStart('render:loadAll');
|
|
405
409
|
const layoutPaths = (pageData.layouts || []).map((l) => l.path);
|
|
406
410
|
const allPaths = [pageData.pagePath, ...layoutPaths];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spa-renderer.d.ts","sourceRoot":"","sources":["../../../../../src/src/html/hydration-script-builder/templates/spa-renderer.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,QAAO,
|
|
1
|
+
{"version":3,"file":"spa-renderer.d.ts","sourceRoot":"","sources":["../../../../../src/src/html/hydration-script-builder/templates/spa-renderer.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,QAAO,MAmEvC,CAAC;AAEF,eAAO,MAAM,kBAAkB,QAAO,MAoCrC,CAAC"}
|
|
@@ -19,6 +19,9 @@ export const getSpaRendererScript = () => `
|
|
|
19
19
|
if (initialData.studioEmbed && window.__veryfrontSetStudioEmbed) {
|
|
20
20
|
window.__veryfrontSetStudioEmbed(true);
|
|
21
21
|
}
|
|
22
|
+
if (initialData.releaseAssetModules && window.__veryfrontSetReleaseAssetModules) {
|
|
23
|
+
window.__veryfrontSetReleaseAssetModules(initialData.releaseAssetModules);
|
|
24
|
+
}
|
|
22
25
|
|
|
23
26
|
try {
|
|
24
27
|
const pageComponent = await loadComponent(initialData.pagePath);
|
|
@@ -12,6 +12,8 @@ export interface HydrationDataStructure {
|
|
|
12
12
|
pagePath?: string;
|
|
13
13
|
pageType?: "mdx" | "md" | "tsx" | "jsx" | "ts" | "js";
|
|
14
14
|
clientModuleStrategy?: ClientModuleStrategy;
|
|
15
|
+
/** Production release asset URLs keyed by logical source path. */
|
|
16
|
+
releaseAssetModules?: Record<string, string>;
|
|
15
17
|
frontmatter?: Record<string, unknown>;
|
|
16
18
|
layoutProps?: Record<string, Record<string, unknown>>;
|
|
17
19
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/src/html/hydration-script-builder/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+CAA+C,CAAC;AAE1F,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,KAAK,GAAG,KAAK,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;IAC1C,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IAC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AK,GAAG,IAAI,GAAG,IAAI,CAAC;IACtD,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,kEAAkE;IAClE,mBAAmB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACtD;;;;OAIG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC9D,6EAA6E;IAC7E,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB"}
|
|
@@ -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;AAkCH,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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K,EAAE,SAAS,GAAG,QAAQ,EAC3B,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,OAAO,CAAC,CAAC;IACpB;;;;;;;OAOG;IACH,iBAAiB,CAAC,CAChB,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,EACvB,UAAU,EAAE,MAAM,GAAG,SAAS,GAC7B,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC,CAAC;CACrE;AAED,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAkCD,2DAA2D;AAC3D,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM/D;AA2aD;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,sBAAsB,EAC7B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,uBAAuB,CAAC,CA2ClC"}
|
|
@@ -20,6 +20,7 @@ import { createFileSystem } from "../platform/compat/fs.js";
|
|
|
20
20
|
import { dirname, join } from "../platform/compat/path/index.js";
|
|
21
21
|
import { resolveFrameworkSourcePath } from "../platform/compat/framework-source-resolver.js";
|
|
22
22
|
import { transformToESM } from "../transforms/esm-transform.js";
|
|
23
|
+
import { parseImports, replaceSpecifiers } from "../transforms/esm/lexer.js";
|
|
23
24
|
import { PLATFORM_UTILITIES } from "../html/utils.js";
|
|
24
25
|
import { extractCandidatesFromFiles } from "../html/styles-builder/candidate-extractor.js";
|
|
25
26
|
import { sha256HexBytes } from "./hash.js";
|
|
@@ -122,10 +123,10 @@ function resolveStaticImports(source, moduleLogicalPath, knownPaths) {
|
|
|
122
123
|
return results;
|
|
123
124
|
}
|
|
124
125
|
function resolveKnownModulePath(path, knownPaths) {
|
|
125
|
-
const normalized = path
|
|
126
|
+
const normalized = normalizeLogicalPath(path
|
|
126
127
|
.replace(/^\/?_vf_modules\//, "")
|
|
127
128
|
.replace(/^\/+/, "")
|
|
128
|
-
.replace(/[?#].*$/, "");
|
|
129
|
+
.replace(/[?#].*$/, ""));
|
|
129
130
|
if (normalized.startsWith("_veryfront/"))
|
|
130
131
|
return null;
|
|
131
132
|
if (knownPaths.has(normalized))
|
|
@@ -138,29 +139,75 @@ function resolveKnownModulePath(path, knownPaths) {
|
|
|
138
139
|
}
|
|
139
140
|
return null;
|
|
140
141
|
}
|
|
141
|
-
function
|
|
142
|
+
function normalizeLogicalPath(path) {
|
|
143
|
+
const parts = [];
|
|
144
|
+
for (const part of path.split("/")) {
|
|
145
|
+
if (!part || part === ".")
|
|
146
|
+
continue;
|
|
147
|
+
if (part === "..") {
|
|
148
|
+
parts.pop();
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
parts.push(part);
|
|
152
|
+
}
|
|
153
|
+
return parts.join("/");
|
|
154
|
+
}
|
|
155
|
+
function normalizeProjectSpecifier(specifier, logicalPath) {
|
|
156
|
+
if (specifier.startsWith("http://") ||
|
|
157
|
+
specifier.startsWith("https://") ||
|
|
158
|
+
specifier.startsWith("data:") ||
|
|
159
|
+
specifier.startsWith("blob:") ||
|
|
160
|
+
specifier.startsWith("#")) {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
if (specifier.startsWith("/_vf_modules/_veryfront/"))
|
|
164
|
+
return null;
|
|
165
|
+
if (specifier.startsWith("/_vf_modules/"))
|
|
166
|
+
return specifier;
|
|
167
|
+
if (specifier.startsWith("_veryfront/"))
|
|
168
|
+
return null;
|
|
169
|
+
if (specifier.startsWith("./") || specifier.startsWith("../")) {
|
|
170
|
+
const dir = logicalPath.includes("/")
|
|
171
|
+
? logicalPath.slice(0, logicalPath.lastIndexOf("/"))
|
|
172
|
+
: ".";
|
|
173
|
+
return `${dir}/${specifier}`;
|
|
174
|
+
}
|
|
175
|
+
if (specifier.startsWith("/"))
|
|
176
|
+
return specifier;
|
|
177
|
+
if (BROWSER_MODULE_DIRS.some((dir) => specifier.startsWith(dir)))
|
|
178
|
+
return specifier;
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
function resolveProjectModuleSpecifier(specifier, logicalPath, knownPaths) {
|
|
182
|
+
const normalized = normalizeProjectSpecifier(specifier, logicalPath);
|
|
183
|
+
if (!normalized)
|
|
184
|
+
return null;
|
|
185
|
+
return resolveKnownModulePath(normalized, knownPaths);
|
|
186
|
+
}
|
|
187
|
+
async function collectProjectModuleImports(code, logicalPath, knownPaths) {
|
|
142
188
|
const imports = new Map();
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
const specifier =
|
|
147
|
-
const
|
|
148
|
-
if (
|
|
149
|
-
imports.set(specifier,
|
|
189
|
+
for (const imp of await parseImports(code)) {
|
|
190
|
+
if (!imp.n)
|
|
191
|
+
continue;
|
|
192
|
+
const specifier = imp.n;
|
|
193
|
+
const importedPath = resolveProjectModuleSpecifier(specifier, logicalPath, knownPaths);
|
|
194
|
+
if (importedPath)
|
|
195
|
+
imports.set(specifier, importedPath);
|
|
150
196
|
}
|
|
151
197
|
return imports;
|
|
152
198
|
}
|
|
153
|
-
function
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
return
|
|
163
|
-
}
|
|
199
|
+
async function rewriteProjectModuleImports(code, logicalPath, moduleAssets, knownPaths, dependencyUrls) {
|
|
200
|
+
function rewriteSpecifier(specifier) {
|
|
201
|
+
if (specifier.startsWith("/_vf_modules/")) {
|
|
202
|
+
const dependencyUrl = dependencyUrls.get(specifier.replace(/[?#].*$/, ""));
|
|
203
|
+
if (dependencyUrl)
|
|
204
|
+
return dependencyUrl;
|
|
205
|
+
}
|
|
206
|
+
const importedPath = resolveProjectModuleSpecifier(specifier, logicalPath, knownPaths);
|
|
207
|
+
const asset = importedPath ? moduleAssets.get(importedPath) : undefined;
|
|
208
|
+
return asset ? releaseAssetUrl(asset.contentHash, "js") : null;
|
|
209
|
+
}
|
|
210
|
+
return await replaceSpecifiers(code, (specifier) => rewriteSpecifier(specifier));
|
|
164
211
|
}
|
|
165
212
|
function buildDependencyUrlMap(_dependencies) {
|
|
166
213
|
// Framework barrels can contain their own relative import closure. Keep those
|
|
@@ -171,7 +218,7 @@ function buildDependencyUrlMap(_dependencies) {
|
|
|
171
218
|
async function finalizeProjectModules(transformedModules, knownPaths, dependencyUrls, uploadQueue, pendingBytes, gaps) {
|
|
172
219
|
const finalized = new Map();
|
|
173
220
|
const unresolvedCycles = new Set();
|
|
174
|
-
const cyclicModules = collectCyclicProjectModules(transformedModules, knownPaths, gaps);
|
|
221
|
+
const cyclicModules = await collectCyclicProjectModules(transformedModules, knownPaths, gaps);
|
|
175
222
|
const skippedModules = new Set(cyclicModules);
|
|
176
223
|
async function finalize(logicalPath, stack) {
|
|
177
224
|
const existing = finalized.get(logicalPath);
|
|
@@ -192,11 +239,11 @@ async function finalizeProjectModules(transformedModules, knownPaths, dependency
|
|
|
192
239
|
if (!transformed)
|
|
193
240
|
return null;
|
|
194
241
|
const nextStack = [...stack, logicalPath];
|
|
195
|
-
const imports =
|
|
242
|
+
const imports = await collectProjectModuleImports(transformed.code, logicalPath, knownPaths);
|
|
196
243
|
for (const importedPath of imports.values()) {
|
|
197
244
|
await finalize(importedPath, nextStack);
|
|
198
245
|
}
|
|
199
|
-
const rewritten =
|
|
246
|
+
const rewritten = await rewriteProjectModuleImports(transformed.code, logicalPath, finalized, knownPaths, dependencyUrls);
|
|
200
247
|
const entry = await addPreparedJavaScriptAsset(logicalPath, rewritten, uploadQueue, pendingBytes);
|
|
201
248
|
if (!entry)
|
|
202
249
|
return null;
|
|
@@ -216,13 +263,13 @@ async function finalizeProjectModules(transformedModules, knownPaths, dependency
|
|
|
216
263
|
}
|
|
217
264
|
return { modules: Object.fromEntries(finalized), skippedModules };
|
|
218
265
|
}
|
|
219
|
-
function collectCyclicProjectModules(transformedModules, knownPaths, gaps) {
|
|
266
|
+
async function collectCyclicProjectModules(transformedModules, knownPaths, gaps) {
|
|
220
267
|
const cyclic = new Set();
|
|
221
268
|
const visiting = new Set();
|
|
222
269
|
const visited = new Set();
|
|
223
270
|
const stack = [];
|
|
224
271
|
const recordedCycles = new Set();
|
|
225
|
-
function visit(logicalPath) {
|
|
272
|
+
async function visit(logicalPath) {
|
|
226
273
|
if (visited.has(logicalPath))
|
|
227
274
|
return;
|
|
228
275
|
if (visiting.has(logicalPath)) {
|
|
@@ -244,17 +291,17 @@ function collectCyclicProjectModules(transformedModules, knownPaths, gaps) {
|
|
|
244
291
|
return;
|
|
245
292
|
visiting.add(logicalPath);
|
|
246
293
|
stack.push(logicalPath);
|
|
247
|
-
const imports =
|
|
294
|
+
const imports = await collectProjectModuleImports(transformed.code, logicalPath, knownPaths);
|
|
248
295
|
for (const importedPath of imports.values()) {
|
|
249
296
|
if (transformedModules.has(importedPath))
|
|
250
|
-
visit(importedPath);
|
|
297
|
+
await visit(importedPath);
|
|
251
298
|
}
|
|
252
299
|
stack.pop();
|
|
253
300
|
visiting.delete(logicalPath);
|
|
254
301
|
visited.add(logicalPath);
|
|
255
302
|
}
|
|
256
303
|
for (const logicalPath of transformedModules.keys())
|
|
257
|
-
visit(logicalPath);
|
|
304
|
+
await visit(logicalPath);
|
|
258
305
|
return cyclic;
|
|
259
306
|
}
|
|
260
307
|
async function addPreparedJavaScriptAsset(logicalPath, code, uploadQueue, pendingBytes) {
|