@evjs/bundler-utoopack 0.1.10 → 0.2.0
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/adapter/component-page-loader.cjs +22 -0
- package/esm/adapter/create-config.d.ts +5 -5
- package/esm/adapter/create-config.d.ts.map +1 -1
- package/esm/adapter/create-config.js +201 -28
- package/esm/adapter/create-config.js.map +1 -1
- package/esm/adapter/index.d.ts +1 -1
- package/esm/adapter/index.d.ts.map +1 -1
- package/esm/adapter/index.js +106 -87
- package/esm/adapter/index.js.map +1 -1
- package/esm/adapter/output-paths.d.ts +1 -1
- package/esm/adapter/output-paths.d.ts.map +1 -1
- package/esm/adapter/output-paths.js +2 -2
- package/esm/adapter/output-paths.js.map +1 -1
- package/esm/adapter/pages-entry-anchor.js +3 -0
- package/esm/adapter/pages-entry-loader.cjs +57 -0
- package/esm/manifest-generator.d.ts +10 -39
- package/esm/manifest-generator.d.ts.map +1 -1
- package/esm/manifest-generator.js +68 -274
- package/esm/manifest-generator.js.map +1 -1
- package/esm/plugin-helper.d.ts +4 -3
- package/esm/plugin-helper.d.ts.map +1 -1
- package/esm/plugin-helper.js +2 -2
- package/esm/plugin-helper.js.map +1 -1
- package/package.json +4 -5
package/esm/adapter/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapter/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapter/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAW7B,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,yBA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CAAC,EAAE,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;AAC1C,CAAC"}
|
|
@@ -3,5 +3,5 @@ export interface UtoopackOutputPaths {
|
|
|
3
3
|
clientDir: string;
|
|
4
4
|
serverDir: string;
|
|
5
5
|
}
|
|
6
|
-
export declare function getOutputPaths(cwd: string, serverEnabled: boolean): UtoopackOutputPaths;
|
|
6
|
+
export declare function getOutputPaths(cwd: string, serverEnabled: boolean, distDir?: string): UtoopackOutputPaths;
|
|
7
7
|
//# sourceMappingURL=output-paths.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output-paths.d.ts","sourceRoot":"","sources":["../../src/adapter/output-paths.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,EACX,aAAa,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"output-paths.d.ts","sourceRoot":"","sources":["../../src/adapter/output-paths.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,EACX,aAAa,EAAE,OAAO,EACtB,OAAO,SAAS,GACf,mBAAmB,CAUrB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
export function getOutputPaths(cwd, serverEnabled) {
|
|
3
|
-
const rootDir = path.resolve(cwd,
|
|
2
|
+
export function getOutputPaths(cwd, serverEnabled, distDir = "dist") {
|
|
3
|
+
const rootDir = path.resolve(cwd, distDir);
|
|
4
4
|
const clientDir = serverEnabled ? path.join(rootDir, "client") : rootDir;
|
|
5
5
|
const serverDir = path.join(rootDir, "server");
|
|
6
6
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output-paths.js","sourceRoot":"","sources":["../../src/adapter/output-paths.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAQ7B,MAAM,UAAU,cAAc,CAC5B,GAAW,EACX,aAAsB;
|
|
1
|
+
{"version":3,"file":"output-paths.js","sourceRoot":"","sources":["../../src/adapter/output-paths.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAQ7B,MAAM,UAAU,cAAc,CAC5B,GAAW,EACX,aAAsB,EACtB,OAAO,GAAG,MAAM;IAEhB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC3C,MAAM,SAAS,GAAG,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IACzE,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAE/C,OAAO;QACL,OAAO;QACP,SAAS;QACT,SAAS;KACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const path = require("node:path");
|
|
2
|
+
|
|
3
|
+
module.exports = function pagesEntryLoader() {
|
|
4
|
+
this.cacheable?.();
|
|
5
|
+
const options = this.getOptions ? this.getOptions() : {};
|
|
6
|
+
const loaderContext = {
|
|
7
|
+
resourcePath: this.resourcePath,
|
|
8
|
+
rootContext: this.rootContext,
|
|
9
|
+
};
|
|
10
|
+
const routes = Array.isArray(options.routes) ? options.routes : [];
|
|
11
|
+
const mount = options.mount || "#app";
|
|
12
|
+
const rootModule = options.rootModule;
|
|
13
|
+
const imports = [
|
|
14
|
+
`import { createPagesApp } from "@evjs/client/internal";`,
|
|
15
|
+
rootModule
|
|
16
|
+
? `import * as rootModule from ${JSON.stringify(toLoaderRelativeRequest(rootModule, loaderContext))};`
|
|
17
|
+
: "",
|
|
18
|
+
...routes.map(
|
|
19
|
+
(route, index) =>
|
|
20
|
+
`import * as routeModule${index} from ${JSON.stringify(toLoaderRelativeRequest(route.module, loaderContext))};`,
|
|
21
|
+
),
|
|
22
|
+
].filter(Boolean);
|
|
23
|
+
|
|
24
|
+
const routeDefinitions = routes.map((route, index) => {
|
|
25
|
+
const properties = [
|
|
26
|
+
route.id ? `id: ${JSON.stringify(route.id)}` : "",
|
|
27
|
+
`path: ${JSON.stringify(route.path)}`,
|
|
28
|
+
route.parentId ? `parentId: ${JSON.stringify(route.parentId)}` : "",
|
|
29
|
+
route.kind ? `kind: ${JSON.stringify(route.kind)}` : "",
|
|
30
|
+
`module: routeModule${index}`,
|
|
31
|
+
].filter(Boolean);
|
|
32
|
+
return `{ ${properties.join(", ")} }`;
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
return [
|
|
36
|
+
...imports,
|
|
37
|
+
``,
|
|
38
|
+
`const { app } = createPagesApp({`,
|
|
39
|
+
rootModule ? ` rootModule,` : "",
|
|
40
|
+
` routes: [${routeDefinitions.join(", ")}],`,
|
|
41
|
+
`});`,
|
|
42
|
+
`app.render(${JSON.stringify(mount)});`,
|
|
43
|
+
`export { app };`,
|
|
44
|
+
`export default app;`,
|
|
45
|
+
``,
|
|
46
|
+
].join("\n");
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
function toLoaderRelativeRequest(specifier, loaderContext) {
|
|
50
|
+
if (!specifier.startsWith(".")) return specifier;
|
|
51
|
+
const rootContext = loaderContext.rootContext || process.cwd();
|
|
52
|
+
const fromDir = path.dirname(loaderContext.resourcePath);
|
|
53
|
+
const absolute = path.resolve(rootContext, specifier);
|
|
54
|
+
let relative = path.relative(fromDir, absolute).replaceAll("\\", "/");
|
|
55
|
+
if (!relative.startsWith(".")) relative = `./${relative}`;
|
|
56
|
+
return relative;
|
|
57
|
+
}
|
|
@@ -1,49 +1,20 @@
|
|
|
1
|
+
import type { BuildPlan, BundlerBuildFacts } from "@evjs/ev";
|
|
1
2
|
export declare class UtoopackManifestGenerator {
|
|
2
|
-
private collector;
|
|
3
|
-
private cwd;
|
|
4
3
|
private serverEnabled;
|
|
5
4
|
private outputPaths;
|
|
6
|
-
private
|
|
7
|
-
private
|
|
8
|
-
private
|
|
5
|
+
private plan;
|
|
6
|
+
private clientEntryAssets;
|
|
7
|
+
private serverEntryAssets;
|
|
8
|
+
private firstClientEntryAssets;
|
|
9
|
+
private serverEntry;
|
|
9
10
|
private serverAssets;
|
|
10
|
-
private serverFns;
|
|
11
|
-
private currentServerRoutes;
|
|
12
11
|
private serverModules;
|
|
13
|
-
constructor(cwd: string, serverEnabled: boolean);
|
|
14
|
-
/**
|
|
15
|
-
* Load client assets from the client `stats.json` emitted by Utoopack.
|
|
16
|
-
* In development, this file may not exist, which is expected since
|
|
17
|
-
* Utoopack handles HTML client injection natively.
|
|
18
|
-
*
|
|
19
|
-
* In MPA mode (multiple entrypoints), assets are collected per-page
|
|
20
|
-
* via `setPageAssets()`. In SPA mode, a single `setAssets()` call is used.
|
|
21
|
-
*/
|
|
12
|
+
constructor(cwd: string, serverEnabled: boolean, plan: BuildPlan);
|
|
22
13
|
loadClientStats(): Promise<void>;
|
|
23
|
-
/**
|
|
24
|
-
* Load server entry and function registrations from the server `stats.json`.
|
|
25
|
-
*
|
|
26
|
-
* When Utoopack doesn't emit a server stats.json (e.g. older versions),
|
|
27
|
-
* falls back to scanning dist/server/ for a JS entry and creating a
|
|
28
|
-
* synthetic manifest.
|
|
29
|
-
*/
|
|
30
14
|
loadServerStats(): Promise<void>;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
private rebuildServerMetadata;
|
|
35
|
-
/**
|
|
36
|
-
* Emit the client manifest (and server manifest if server is enabled).
|
|
37
|
-
*/
|
|
38
|
-
emit(): Promise<void>;
|
|
39
|
-
/**
|
|
40
|
-
* Run a full post-build manifest generation pass.
|
|
41
|
-
*/
|
|
42
|
-
build(): Promise<void>;
|
|
43
|
-
/**
|
|
44
|
-
* Run manifest generation continually by watching the filesystem in development.
|
|
45
|
-
*/
|
|
46
|
-
watch(onUpdate?: () => void | Promise<void>): Promise<void>;
|
|
15
|
+
collectBuildFacts(): Promise<BundlerBuildFacts>;
|
|
16
|
+
build(): Promise<BundlerBuildFacts>;
|
|
17
|
+
watch(onUpdate?: (result: BundlerBuildFacts) => void | Promise<void>): Promise<void>;
|
|
47
18
|
close(): Promise<void>;
|
|
48
19
|
}
|
|
49
20
|
//# sourceMappingURL=manifest-generator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest-generator.d.ts","sourceRoot":"","sources":["../src/manifest-generator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"manifest-generator.d.ts","sourceRoot":"","sources":["../src/manifest-generator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAGV,SAAS,EACT,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAuHlB,qBAAa,yBAAyB;IACpC,OAAO,CAAC,aAAa,CAAU;IAC/B,OAAO,CAAC,WAAW,CAAsB;IACzC,OAAO,CAAC,IAAI,CAAY;IACxB,OAAO,CAAC,iBAAiB,CAAkC;IAC3D,OAAO,CAAC,iBAAiB,CAAkC;IAC3D,OAAO,CAAC,sBAAsB,CAA4B;IAC1D,OAAO,CAAC,WAAW,CAAqB;IACxC,OAAO,CAAC,YAAY,CAA4B;IAChD,OAAO,CAAC,aAAa,CAAiC;gBAE1C,GAAG,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS;IAM1D,eAAe;IAqBf,eAAe;IAyCf,iBAAiB,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAc/C,KAAK,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAInC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAKpE,KAAK;CACZ"}
|
|
@@ -1,94 +1,17 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { analyzeRoutes, extractServerFunctionExports, hashServerFunction, resolveRoutes, } from "@evjs/build-tools";
|
|
4
|
-
import { ManifestCollector, } from "@evjs/manifest";
|
|
5
3
|
import { getLogger } from "@logtape/logtape";
|
|
6
|
-
import chokidar from "chokidar";
|
|
7
|
-
import fastGlob from "fast-glob";
|
|
8
4
|
import { getOutputPaths, } from "./adapter/output-paths.js";
|
|
9
5
|
const logger = getLogger(["evjs", "bundler-utoopack", "manifest"]);
|
|
10
6
|
const EMPTY_ASSETS = { js: [], css: [] };
|
|
11
7
|
function normalizeAssetName(name) {
|
|
12
8
|
return name?.replace(/^\.\//, "");
|
|
13
9
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
*
|
|
17
|
-
* @returns lists of JS and CSS asset filenames from the main entrypoint (SPA mode).
|
|
18
|
-
*/
|
|
19
|
-
function parseClientStats(stats) {
|
|
20
|
-
const jsFiles = [];
|
|
21
|
-
const cssFiles = [];
|
|
22
|
-
// Use first entrypoint — utoopack may name it by the output file rather than "main"
|
|
23
|
-
const entrypoints = stats.entrypoints;
|
|
24
|
-
const firstEntry = entrypoints ? Object.values(entrypoints)[0] : undefined;
|
|
25
|
-
if (firstEntry && Array.isArray(firstEntry.assets)) {
|
|
26
|
-
for (const asset of firstEntry.assets) {
|
|
27
|
-
const name = normalizeAssetName(asset.name);
|
|
28
|
-
if (name?.endsWith(".js")) {
|
|
29
|
-
jsFiles.push(name);
|
|
30
|
-
}
|
|
31
|
-
else if (name?.endsWith(".css")) {
|
|
32
|
-
cssFiles.push(name);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return { js: jsFiles, css: cssFiles };
|
|
10
|
+
function readStatsAssetName(asset) {
|
|
11
|
+
return typeof asset === "string" ? asset : asset.name;
|
|
37
12
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
*
|
|
41
|
-
* @returns a map of entrypoint name → { js, css } asset lists (MPA mode).
|
|
42
|
-
*/
|
|
43
|
-
function parseClientStatsPerEntrypoint(stats) {
|
|
44
|
-
const result = {};
|
|
45
|
-
const entrypoints = stats.entrypoints;
|
|
46
|
-
if (!entrypoints)
|
|
47
|
-
return result;
|
|
48
|
-
for (const [name, entry] of Object.entries(entrypoints)) {
|
|
49
|
-
const js = [];
|
|
50
|
-
const css = [];
|
|
51
|
-
if (Array.isArray(entry.assets)) {
|
|
52
|
-
for (const asset of entry.assets) {
|
|
53
|
-
const assetName = normalizeAssetName(asset.name);
|
|
54
|
-
if (assetName?.endsWith(".js")) {
|
|
55
|
-
js.push(assetName);
|
|
56
|
-
}
|
|
57
|
-
else if (assetName?.endsWith(".css")) {
|
|
58
|
-
css.push(assetName);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
result[name] = { js, css };
|
|
63
|
-
}
|
|
64
|
-
return result;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Parse a Utoopack server stats.json and extract emitted assets.
|
|
68
|
-
*/
|
|
69
|
-
function parseServerStats(stats) {
|
|
70
|
-
let entry;
|
|
71
|
-
const assets = { js: [], css: [] };
|
|
72
|
-
// Use first entrypoint — utoopack may name it by the output file rather than "main"
|
|
73
|
-
const entrypoints = stats.entrypoints;
|
|
74
|
-
const firstEntry = entrypoints ? Object.values(entrypoints)[0] : undefined;
|
|
75
|
-
if (firstEntry && Array.isArray(firstEntry.assets)) {
|
|
76
|
-
const jsAsset = firstEntry.assets.find((a) => a.name?.endsWith(".js"));
|
|
77
|
-
entry = normalizeAssetName(jsAsset?.name);
|
|
78
|
-
for (const asset of firstEntry.assets) {
|
|
79
|
-
const name = normalizeAssetName(asset.name);
|
|
80
|
-
if (name?.endsWith(".js")) {
|
|
81
|
-
assets.js.push(name);
|
|
82
|
-
}
|
|
83
|
-
else if (name?.endsWith(".css")) {
|
|
84
|
-
assets.css.push(name);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return {
|
|
89
|
-
entry,
|
|
90
|
-
assets,
|
|
91
|
-
};
|
|
13
|
+
function emptyAssets() {
|
|
14
|
+
return { js: [], css: [] };
|
|
92
15
|
}
|
|
93
16
|
function dedupeAssets(assets) {
|
|
94
17
|
return {
|
|
@@ -96,15 +19,6 @@ function dedupeAssets(assets) {
|
|
|
96
19
|
css: [...new Set(assets.css)],
|
|
97
20
|
};
|
|
98
21
|
}
|
|
99
|
-
function mergeAssets(a, b) {
|
|
100
|
-
return dedupeAssets({
|
|
101
|
-
js: [...a.js, ...b.js],
|
|
102
|
-
css: [...a.css, ...b.css],
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
function toPosixPath(value) {
|
|
106
|
-
return value.replaceAll(path.sep, "/").replaceAll("\\", "/");
|
|
107
|
-
}
|
|
108
22
|
function normalizeModuleId(value) {
|
|
109
23
|
if (typeof value !== "string")
|
|
110
24
|
return undefined;
|
|
@@ -113,11 +27,8 @@ function normalizeModuleId(value) {
|
|
|
113
27
|
.replace(/^\.\//, "")
|
|
114
28
|
.replace(/\s+\[(?:server|client)\]\s+\(.+\)$/, "");
|
|
115
29
|
}
|
|
116
|
-
function moduleIdMatchesSource(moduleId, sourceRel) {
|
|
117
|
-
return moduleId === sourceRel || moduleId.endsWith(`/${sourceRel}`);
|
|
118
|
-
}
|
|
119
30
|
function assetsFromChunks(chunks, fallback) {
|
|
120
|
-
const assets =
|
|
31
|
+
const assets = emptyAssets();
|
|
121
32
|
for (const chunk of chunks ?? []) {
|
|
122
33
|
if (typeof chunk !== "string")
|
|
123
34
|
continue;
|
|
@@ -135,6 +46,27 @@ function assetsFromChunks(chunks, fallback) {
|
|
|
135
46
|
}
|
|
136
47
|
return fallback;
|
|
137
48
|
}
|
|
49
|
+
function readEntrypointAssets(stats) {
|
|
50
|
+
const byName = {};
|
|
51
|
+
let first = EMPTY_ASSETS;
|
|
52
|
+
for (const [name, entry] of Object.entries(stats.entrypoints ?? {})) {
|
|
53
|
+
const assets = emptyAssets();
|
|
54
|
+
for (const asset of entry.assets ?? []) {
|
|
55
|
+
const assetName = normalizeAssetName(readStatsAssetName(asset));
|
|
56
|
+
if (assetName?.endsWith(".js")) {
|
|
57
|
+
assets.js.push(assetName);
|
|
58
|
+
}
|
|
59
|
+
else if (assetName?.endsWith(".css")) {
|
|
60
|
+
assets.css.push(assetName);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
byName[name] = dedupeAssets(assets);
|
|
64
|
+
if (first === EMPTY_ASSETS) {
|
|
65
|
+
first = byName[name];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return { byName, first };
|
|
69
|
+
}
|
|
138
70
|
function collectServerModules(modules, fallbackAssets) {
|
|
139
71
|
const result = [];
|
|
140
72
|
for (const mod of modules ?? []) {
|
|
@@ -149,85 +81,59 @@ function collectServerModules(modules, fallbackAssets) {
|
|
|
149
81
|
return result;
|
|
150
82
|
}
|
|
151
83
|
export class UtoopackManifestGenerator {
|
|
152
|
-
collector = new ManifestCollector();
|
|
153
|
-
cwd;
|
|
154
84
|
serverEnabled;
|
|
155
85
|
outputPaths;
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
86
|
+
plan;
|
|
87
|
+
clientEntryAssets = {};
|
|
88
|
+
serverEntryAssets = {};
|
|
89
|
+
firstClientEntryAssets = EMPTY_ASSETS;
|
|
90
|
+
serverEntry;
|
|
159
91
|
serverAssets = EMPTY_ASSETS;
|
|
160
|
-
serverFns = {};
|
|
161
|
-
currentServerRoutes = [];
|
|
162
92
|
serverModules = [];
|
|
163
|
-
constructor(cwd, serverEnabled) {
|
|
164
|
-
this.cwd = cwd;
|
|
93
|
+
constructor(cwd, serverEnabled, plan) {
|
|
165
94
|
this.serverEnabled = serverEnabled;
|
|
166
|
-
this.outputPaths = getOutputPaths(cwd, serverEnabled);
|
|
95
|
+
this.outputPaths = getOutputPaths(cwd, serverEnabled, plan.distDir);
|
|
96
|
+
this.plan = plan;
|
|
167
97
|
}
|
|
168
|
-
/**
|
|
169
|
-
* Load client assets from the client `stats.json` emitted by Utoopack.
|
|
170
|
-
* In development, this file may not exist, which is expected since
|
|
171
|
-
* Utoopack handles HTML client injection natively.
|
|
172
|
-
*
|
|
173
|
-
* In MPA mode (multiple entrypoints), assets are collected per-page
|
|
174
|
-
* via `setPageAssets()`. In SPA mode, a single `setAssets()` call is used.
|
|
175
|
-
*/
|
|
176
98
|
async loadClientStats() {
|
|
177
99
|
const statsPath = path.join(this.outputPaths.clientDir, "stats.json");
|
|
178
100
|
if (!fs.existsSync(statsPath)) {
|
|
179
|
-
this.
|
|
180
|
-
this.
|
|
101
|
+
this.clientEntryAssets = {};
|
|
102
|
+
this.firstClientEntryAssets = EMPTY_ASSETS;
|
|
181
103
|
return;
|
|
182
104
|
}
|
|
183
105
|
try {
|
|
184
106
|
const statsStr = await fs.promises.readFile(statsPath, "utf-8");
|
|
185
107
|
const stats = JSON.parse(statsStr);
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
if (entrypointCount > 1) {
|
|
190
|
-
// MPA mode: per-page assets
|
|
191
|
-
const perPage = parseClientStatsPerEntrypoint(stats);
|
|
192
|
-
this.clientJsAssets = [];
|
|
193
|
-
for (const [name, { js, css }] of Object.entries(perPage)) {
|
|
194
|
-
this.clientJsAssets.push(...js);
|
|
195
|
-
this.collector.setPageAssets(name, js, css);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
// SPA mode: single entrypoint
|
|
200
|
-
const { js, css } = parseClientStats(stats);
|
|
201
|
-
this.clientJsAssets = js;
|
|
202
|
-
this.collector.setAssets(js, css);
|
|
203
|
-
}
|
|
108
|
+
const { byName, first } = readEntrypointAssets(stats);
|
|
109
|
+
this.clientEntryAssets = byName;
|
|
110
|
+
this.firstClientEntryAssets = first;
|
|
204
111
|
}
|
|
205
112
|
catch (err) {
|
|
206
113
|
logger.warn `Failed to parse client stats.json: ${err}`;
|
|
207
|
-
this.
|
|
208
|
-
this.
|
|
114
|
+
this.clientEntryAssets = {};
|
|
115
|
+
this.firstClientEntryAssets = EMPTY_ASSETS;
|
|
209
116
|
}
|
|
210
117
|
}
|
|
211
|
-
/**
|
|
212
|
-
* Load server entry and function registrations from the server `stats.json`.
|
|
213
|
-
*
|
|
214
|
-
* When Utoopack doesn't emit a server stats.json (e.g. older versions),
|
|
215
|
-
* falls back to scanning dist/server/ for a JS entry and creating a
|
|
216
|
-
* synthetic manifest.
|
|
217
|
-
*/
|
|
218
118
|
async loadServerStats() {
|
|
219
119
|
if (!this.serverEnabled)
|
|
220
120
|
return;
|
|
121
|
+
this.serverEntry = undefined;
|
|
122
|
+
this.serverEntryAssets = {};
|
|
221
123
|
this.serverAssets = EMPTY_ASSETS;
|
|
222
|
-
this.
|
|
124
|
+
this.serverModules = [];
|
|
223
125
|
const statsPath = path.join(this.outputPaths.serverDir, "stats.json");
|
|
224
126
|
if (fs.existsSync(statsPath)) {
|
|
225
127
|
try {
|
|
226
128
|
const statsStr = await fs.promises.readFile(statsPath, "utf-8");
|
|
227
129
|
const stats = JSON.parse(statsStr);
|
|
228
|
-
const {
|
|
229
|
-
this.
|
|
230
|
-
|
|
130
|
+
const { byName, first } = readEntrypointAssets(stats);
|
|
131
|
+
this.serverEntryAssets = byName;
|
|
132
|
+
const serverEntryName = this.plan.entries.find((entry) => entry.kind === "server-runtime")
|
|
133
|
+
?.name ?? "server";
|
|
134
|
+
const entryAssets = byName[serverEntryName] ?? first;
|
|
135
|
+
this.serverAssets = entryAssets;
|
|
136
|
+
this.serverEntry = entryAssets.js[0];
|
|
231
137
|
this.serverModules = collectServerModules(stats.modules, this.serverAssets);
|
|
232
138
|
return;
|
|
233
139
|
}
|
|
@@ -235,147 +141,35 @@ export class UtoopackManifestGenerator {
|
|
|
235
141
|
logger.warn `Failed to parse server stats.json: ${err}`;
|
|
236
142
|
}
|
|
237
143
|
}
|
|
238
|
-
// Fallback: scan for JS entry in dist/server/
|
|
239
144
|
const serverDir = this.outputPaths.serverDir;
|
|
240
145
|
if (fs.existsSync(serverDir)) {
|
|
241
146
|
const files = await fs.promises.readdir(serverDir);
|
|
242
|
-
const jsEntry = files.find((
|
|
147
|
+
const jsEntry = files.find((file) => file.endsWith(".js"));
|
|
243
148
|
if (jsEntry) {
|
|
244
|
-
this.
|
|
149
|
+
this.serverEntry = jsEntry;
|
|
245
150
|
this.serverAssets = { js: [jsEntry], css: [] };
|
|
246
|
-
this.serverModules = [];
|
|
247
151
|
}
|
|
248
152
|
}
|
|
249
153
|
}
|
|
250
|
-
|
|
251
|
-
return this.serverModules.find((mod) => moduleIdMatchesSource(mod.moduleId, sourceRel));
|
|
252
|
-
}
|
|
253
|
-
async loadSourceMetadata() {
|
|
254
|
-
const files = await fastGlob("src/**/*.{ts,tsx,js,jsx}", {
|
|
255
|
-
cwd: this.cwd,
|
|
256
|
-
absolute: true,
|
|
257
|
-
});
|
|
258
|
-
const clientRoutes = [];
|
|
259
|
-
const serverRouteMap = new Map();
|
|
260
|
-
const fns = {};
|
|
261
|
-
for (const file of files) {
|
|
262
|
-
const source = await fs.promises.readFile(file, "utf-8");
|
|
263
|
-
const sourceRel = toPosixPath(path.relative(this.cwd, file));
|
|
264
|
-
const analysis = analyzeRoutes(source);
|
|
265
|
-
clientRoutes.push(...analysis.clientRoutes);
|
|
266
|
-
if (!this.serverEnabled)
|
|
267
|
-
continue;
|
|
268
|
-
const serverModule = this.findServerModuleForSource(sourceRel);
|
|
269
|
-
const sourceAssets = serverModule?.assets ?? this.serverAssets;
|
|
270
|
-
for (const route of analysis.serverRoutes) {
|
|
271
|
-
const key = `${route.path}\0${route.methods.join(",")}`;
|
|
272
|
-
const existing = serverRouteMap.get(key);
|
|
273
|
-
serverRouteMap.set(key, {
|
|
274
|
-
path: route.path,
|
|
275
|
-
methods: route.methods,
|
|
276
|
-
assets: existing
|
|
277
|
-
? mergeAssets(existing.assets, sourceAssets)
|
|
278
|
-
: sourceAssets,
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
const exportNames = extractServerFunctionExports(source);
|
|
282
|
-
if (exportNames.length === 0)
|
|
283
|
-
continue;
|
|
284
|
-
for (const exportName of exportNames) {
|
|
285
|
-
const id = hashServerFunction(sourceRel, exportName);
|
|
286
|
-
fns[id] = {
|
|
287
|
-
assets: fns[id]
|
|
288
|
-
? mergeAssets(fns[id].assets, sourceAssets)
|
|
289
|
-
: sourceAssets,
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
this.currentRoutes = resolveRoutes(clientRoutes);
|
|
294
|
-
this.serverFns = fns;
|
|
295
|
-
this.currentServerRoutes = [...serverRouteMap.values()];
|
|
296
|
-
}
|
|
297
|
-
rebuildRoutes() {
|
|
298
|
-
this.collector.routes = [];
|
|
299
|
-
this.collector.addRoutes(this.currentRoutes);
|
|
300
|
-
}
|
|
301
|
-
rebuildServerMetadata() {
|
|
302
|
-
this.collector.fns = {};
|
|
303
|
-
this.collector.setServerAssets(this.serverAssets.js, this.serverAssets.css);
|
|
304
|
-
for (const [id, fn] of Object.entries(this.serverFns)) {
|
|
305
|
-
this.collector.addServerFn(id, fn);
|
|
306
|
-
}
|
|
307
|
-
this.collector.serverRoutes = [];
|
|
308
|
-
this.collector.addServerRoutes(this.currentServerRoutes);
|
|
309
|
-
}
|
|
310
|
-
/**
|
|
311
|
-
* Emit the client manifest (and server manifest if server is enabled).
|
|
312
|
-
*/
|
|
313
|
-
async emit() {
|
|
314
|
-
this.rebuildRoutes();
|
|
315
|
-
if (this.serverEnabled) {
|
|
316
|
-
this.rebuildServerMetadata();
|
|
317
|
-
}
|
|
318
|
-
// Client manifest — matches ClientManifest from @evjs/manifest
|
|
319
|
-
const clientManifest = this.collector.getClientManifest();
|
|
320
|
-
const clientOutPath = path.join(this.outputPaths.clientDir, "manifest.json");
|
|
321
|
-
const clientOutDir = path.dirname(clientOutPath);
|
|
322
|
-
if (!fs.existsSync(clientOutDir)) {
|
|
323
|
-
await fs.promises.mkdir(clientOutDir, { recursive: true });
|
|
324
|
-
}
|
|
325
|
-
await fs.promises.writeFile(clientOutPath, JSON.stringify(clientManifest, null, 2));
|
|
326
|
-
// Server manifest
|
|
327
|
-
if (this.serverEnabled) {
|
|
328
|
-
// Server manifest — matches ServerManifest from @evjs/manifest
|
|
329
|
-
const serverManifest = this.collector.getServerManifest();
|
|
330
|
-
const serverOutDir = this.outputPaths.serverDir;
|
|
331
|
-
if (!fs.existsSync(serverOutDir)) {
|
|
332
|
-
await fs.promises.mkdir(serverOutDir, { recursive: true });
|
|
333
|
-
}
|
|
334
|
-
await fs.promises.writeFile(path.join(serverOutDir, "manifest.json"), JSON.stringify(serverManifest, null, 2));
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* Run a full post-build manifest generation pass.
|
|
339
|
-
*/
|
|
340
|
-
async build() {
|
|
341
|
-
await this.loadClientStats();
|
|
342
|
-
await this.loadServerStats();
|
|
343
|
-
await this.loadSourceMetadata();
|
|
344
|
-
await this.emit();
|
|
345
|
-
}
|
|
346
|
-
/**
|
|
347
|
-
* Run manifest generation continually by watching the filesystem in development.
|
|
348
|
-
*/
|
|
349
|
-
async watch(onUpdate) {
|
|
154
|
+
async collectBuildFacts() {
|
|
350
155
|
await this.loadClientStats();
|
|
351
156
|
await this.loadServerStats();
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
const handleChange = async (filepath) => {
|
|
360
|
-
logger.debug `Route source changed: ${filepath}`;
|
|
361
|
-
await this.loadSourceMetadata();
|
|
362
|
-
await this.emit();
|
|
363
|
-
await onUpdate?.();
|
|
364
|
-
};
|
|
365
|
-
const handleUnlink = async (filepath) => {
|
|
366
|
-
logger.debug `Route source removed: ${filepath}`;
|
|
367
|
-
await this.loadSourceMetadata();
|
|
368
|
-
await this.emit();
|
|
369
|
-
await onUpdate?.();
|
|
157
|
+
return {
|
|
158
|
+
clientEntryAssets: this.clientEntryAssets,
|
|
159
|
+
firstClientEntryAssets: this.firstClientEntryAssets,
|
|
160
|
+
serverEntryAssets: this.serverEntryAssets,
|
|
161
|
+
serverEntry: this.serverEntry,
|
|
162
|
+
serverAssets: this.serverAssets,
|
|
163
|
+
serverModules: this.serverModules,
|
|
370
164
|
};
|
|
371
|
-
this.watcher.on("add", handleChange);
|
|
372
|
-
this.watcher.on("change", handleChange);
|
|
373
|
-
this.watcher.on("unlink", handleUnlink);
|
|
374
165
|
}
|
|
375
|
-
async
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
166
|
+
async build() {
|
|
167
|
+
return this.collectBuildFacts();
|
|
168
|
+
}
|
|
169
|
+
async watch(onUpdate) {
|
|
170
|
+
const output = await this.build();
|
|
171
|
+
await onUpdate?.(output);
|
|
379
172
|
}
|
|
173
|
+
async close() { }
|
|
380
174
|
}
|
|
381
175
|
//# sourceMappingURL=manifest-generator.js.map
|