@vite-hub/bundle 0.4.1 → 0.5.1
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/dist/{cli-ubYJpAL_.d.ts → cli-C5pAfY4x.d.ts} +1 -6
- package/dist/{cli-CJOjJmEo.js → cli-CfA0FvGh.js} +9 -10
- package/dist/cli.d.ts +2 -6
- package/dist/cli.js +2 -2
- package/dist/{compare-87VKOrA3.js → compare-3VnwI84U.js} +135 -87
- package/dist/index.d.ts +3 -12
- package/dist/index.js +2 -3
- package/dist/{object-Da1zyPCR.js → object-CAK6UYR5.js} +1 -2
- package/dist/{operation-definition-nmRu_O3V.d.ts → operation-definition-CqZkx1Rm.d.ts} +8 -6
- package/dist/operations.d.ts +3 -5
- package/dist/operations.js +15 -14
- package/dist/{types-DBa_sXqC.d.ts → types-D4oYDFpA.d.ts} +0 -2
- package/dist/vite.d.ts +3 -8
- package/dist/vite.js +20 -36
- package/package.json +6 -6
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "nostics";
|
|
2
|
-
//#region ../internal/src/host-credentials.d.ts
|
|
3
2
|
interface HostCliRunResult {
|
|
4
3
|
exitCode: number | null;
|
|
5
4
|
stdout: string;
|
|
5
|
+
stderr?: string;
|
|
6
6
|
}
|
|
7
7
|
/** Runs a host CLI with an argument array and no shell, and returns its stdout. */
|
|
8
8
|
type HostCliRun = (command: string, args: readonly string[], options: {
|
|
@@ -10,8 +10,6 @@ type HostCliRun = (command: string, args: readonly string[], options: {
|
|
|
10
10
|
env: NodeJS.ProcessEnv;
|
|
11
11
|
signal?: AbortSignal;
|
|
12
12
|
}) => Promise<HostCliRunResult>;
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region ../internal/src/provision.d.ts
|
|
15
13
|
type ProvisionProvider = "cloudflare" | "vercel";
|
|
16
14
|
interface ProvisionLogger {
|
|
17
15
|
log: (message: string) => void;
|
|
@@ -63,8 +61,6 @@ interface ProvisionStep {
|
|
|
63
61
|
/** Describes the Provision State this step records. Runs without network access, also without credentials. */
|
|
64
62
|
recordedState?: (context: Pick<ProvisionContext, "env">) => ProvisionStateCategory[];
|
|
65
63
|
}
|
|
66
|
-
//#endregion
|
|
67
|
-
//#region ../internal/src/cli.d.ts
|
|
68
64
|
interface ViteHubCliStreams {
|
|
69
65
|
stderr: {
|
|
70
66
|
write: (chunk: string | Uint8Array, encoding?: BufferEncoding | StdoutWriteCallback, callback?: StdoutWriteCallback) => unknown;
|
|
@@ -159,5 +155,4 @@ interface ViteHubCliPluginMetadata {
|
|
|
159
155
|
cli?: ViteHubCliContributor | ViteHubCliContributorFactory;
|
|
160
156
|
}
|
|
161
157
|
type StdoutWriteCallback = (error?: Error | null) => void;
|
|
162
|
-
//#endregion
|
|
163
158
|
export { ViteHubCliPluginMetadata as n, ViteHubCliContributor as t };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { a as explainBundleRoute, f as readBundleReportRoot, i as explainBundle, n as readSavedBundleReport, p as readEnvironmentReports, r as createBundleReport, t as compareBundleReports, u as formatBytes } from "./compare-
|
|
1
|
+
import { a as explainBundleRoute, f as readBundleReportRoot, i as explainBundle, n as readSavedBundleReport, p as readEnvironmentReports, r as createBundleReport, t as compareBundleReports, u as formatBytes } from "./compare-3VnwI84U.js";
|
|
2
2
|
import { statSync } from "node:fs";
|
|
3
3
|
import { basename, dirname, parse, resolve } from "node:path";
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
5
|
import "node:url";
|
|
6
|
-
|
|
6
|
+
// ../internal/src/build/vite.ts
|
|
7
7
|
const projectRootDirectoryMarkers = [
|
|
8
8
|
["server", "agents"],
|
|
9
9
|
["server", "channels"],
|
|
@@ -47,7 +47,7 @@ function hasProjectRootDirectoryMarker(root) {
|
|
|
47
47
|
for (const marker of projectRootDirectoryMarkers) try {
|
|
48
48
|
if (statSync(resolve(root, ...marker)).isDirectory()) return true;
|
|
49
49
|
} catch (error) {
|
|
50
|
-
if (error
|
|
50
|
+
if (!isMissingProjectMarker(error)) throw error;
|
|
51
51
|
}
|
|
52
52
|
return false;
|
|
53
53
|
}
|
|
@@ -61,17 +61,19 @@ function hasProjectRootFileMarker(root, markers) {
|
|
|
61
61
|
try {
|
|
62
62
|
if (statSync(resolve(root, ...path)).isFile()) return true;
|
|
63
63
|
} catch (error) {
|
|
64
|
-
if (error
|
|
64
|
+
if (!isMissingProjectMarker(error)) throw error;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
return false;
|
|
68
68
|
}
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
function isMissingProjectMarker(error) {
|
|
70
|
+
const code = error.code;
|
|
71
|
+
return code === "ENOENT" || code === "ENOTDIR";
|
|
72
|
+
}
|
|
73
|
+
// src/cli.ts
|
|
71
74
|
const reportUsage = "vitehub bundle [--against <report>] [--json]";
|
|
72
75
|
const whyUsage = "vitehub bundle why <package|file|/route> [--json]";
|
|
73
76
|
const missingReport = "No bundle report in .vitehub/bundle/. Set `bundle: true` in vitehub() (vite.config.ts) or in `vitehub` (nuxt.config.ts), then run a production build.\n";
|
|
74
|
-
/** A loaded project supplies its Vite root; runtime dispatch uses the last build's location. */
|
|
75
77
|
function projectRoot(context) {
|
|
76
78
|
const root = resolveViteHubProjectRoot(context.rootDir);
|
|
77
79
|
if (resolve(context.cwd) !== resolve(context.rootDir)) return root;
|
|
@@ -149,11 +151,9 @@ function findingLines(findings) {
|
|
|
149
151
|
lines.push("");
|
|
150
152
|
return lines;
|
|
151
153
|
}
|
|
152
|
-
/** Like `vite-doctor`: an error finding fails the command, a warning does not. */
|
|
153
154
|
function exitCode(findings) {
|
|
154
155
|
return findings.some((finding) => finding.severity === "error") ? 1 : 0;
|
|
155
156
|
}
|
|
156
|
-
/** `+1.2 kB`, `-300 B`, or `0 B`. */
|
|
157
157
|
function formatDelta(bytes) {
|
|
158
158
|
return bytes > 0 ? `+${formatBytes(bytes)}` : bytes < 0 ? `-${formatBytes(-bytes)}` : "0 B";
|
|
159
159
|
}
|
|
@@ -331,5 +331,4 @@ const bundleCliContributor = { namespaces: [{
|
|
|
331
331
|
}],
|
|
332
332
|
name: "bundle"
|
|
333
333
|
}] };
|
|
334
|
-
//#endregion
|
|
335
334
|
export { resolveViteHubProjectRoot as n, bundleCliContributor as t };
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import { t as ViteHubCliContributor } from "./cli-
|
|
2
|
-
//#region src/bytes.d.ts
|
|
1
|
+
import { t as ViteHubCliContributor } from "./cli-C5pAfY4x.js";
|
|
3
2
|
/** `1234567` becomes `1.23 MB`, like Vite's build output. */
|
|
4
3
|
export declare function formatBytes(bytes: number): string;
|
|
5
|
-
//#endregion
|
|
6
|
-
//#region src/cli.d.ts
|
|
7
4
|
/** The `vitehub bundle` commands. They read `.vitehub/bundle/` and need no dev server. */
|
|
8
|
-
export declare const bundleCliContributor: ViteHubCliContributor;
|
|
9
|
-
//#endregion
|
|
5
|
+
export declare const bundleCliContributor: ViteHubCliContributor;
|
package/dist/cli.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { u as formatBytes } from "./compare-
|
|
2
|
-
import { t as bundleCliContributor } from "./cli-
|
|
1
|
+
import { u as formatBytes } from "./compare-3VnwI84U.js";
|
|
2
|
+
import { t as bundleCliContributor } from "./cli-CfA0FvGh.js";
|
|
3
3
|
export { bundleCliContributor, formatBytes };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { t as isRecord } from "./object-
|
|
1
|
+
import { t as isRecord } from "./object-CAK6UYR5.js";
|
|
2
2
|
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { dirname, join, posix, relative, resolve } from "node:path";
|
|
4
4
|
import { createConsoleReporter, defineDiagnostics } from "nostics";
|
|
5
|
-
|
|
6
|
-
//#region src/files.ts
|
|
5
|
+
// src/files.ts
|
|
7
6
|
/** Folder of the environment reports, relative to the project root. */
|
|
8
7
|
const bundleReportDir = ".vitehub/bundle";
|
|
9
8
|
const bundleReportRootFile = ".vitehub/bundle-root.json";
|
|
@@ -53,8 +52,7 @@ function writeEnvironmentReport(root, report) {
|
|
|
53
52
|
for (const old of readEnvironmentReports(root)) if (old.build !== report.build) rmSync(join(dir, `${old.environment}.json`), { force: true });
|
|
54
53
|
writeFileSync(join(dir, `${report.environment}.json`), `${JSON.stringify(report)}\n`);
|
|
55
54
|
}
|
|
56
|
-
|
|
57
|
-
//#region src/bytes.ts
|
|
55
|
+
// src/bytes.ts
|
|
58
56
|
/** Splits file bytes proportionally, carrying rounding between shares so their sum stays exact. */
|
|
59
57
|
function allocateBytes(weights, bytes) {
|
|
60
58
|
const total = weights.reduce((sum, weight) => sum + weight, 0);
|
|
@@ -74,9 +72,7 @@ function formatBytes(bytes) {
|
|
|
74
72
|
if (bytes >= 1e3) return `${(bytes / 1e3).toFixed(1)} kB`;
|
|
75
73
|
return `${bytes} B`;
|
|
76
74
|
}
|
|
77
|
-
|
|
78
|
-
//#region src/diagnostics.ts
|
|
79
|
-
/** The largest Worker that Cloudflare accepts, before compression. */
|
|
75
|
+
// src/diagnostics.ts
|
|
80
76
|
const cloudflareWorkerSizeLimit = 67108864;
|
|
81
77
|
const bundleDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
82
78
|
docsBase: "https://vitehub.dev/docs/bundle/diagnostics",
|
|
@@ -91,8 +87,7 @@ const bundleDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
91
87
|
}
|
|
92
88
|
}
|
|
93
89
|
});
|
|
94
|
-
|
|
95
|
-
//#region src/groups.ts
|
|
90
|
+
// src/groups.ts
|
|
96
91
|
const frameworkPackages = /* @__PURE__ */ new Set([
|
|
97
92
|
"@unhead/vue",
|
|
98
93
|
"nuxt-nightly",
|
|
@@ -112,6 +107,12 @@ const frameworkPackages = /* @__PURE__ */ new Set([
|
|
|
112
107
|
"vue",
|
|
113
108
|
"vue-router"
|
|
114
109
|
]);
|
|
110
|
+
function manifestPackageName(manifestFile) {
|
|
111
|
+
if (!existsSync(manifestFile)) return void 0;
|
|
112
|
+
const manifest = JSON.parse(readFileSync(manifestFile, "utf8").replace(/^\uFEFF/, ""));
|
|
113
|
+
const name = manifest && typeof manifest === "object" ? Reflect.get(manifest, "name") : void 0;
|
|
114
|
+
return typeof name === "string" ? name : void 0;
|
|
115
|
+
}
|
|
115
116
|
/** The root-relative id of a module. Dependencies become `node_modules/<package>/<file>`, wherever pnpm stores them. */
|
|
116
117
|
function moduleId(id, root, packages = /* @__PURE__ */ new Map()) {
|
|
117
118
|
const clean = id.replace(/\\/g, "/").replace(/\?.*$/, "").replace(/^\0/, "");
|
|
@@ -129,14 +130,7 @@ function moduleId(id, root, packages = /* @__PURE__ */ new Map()) {
|
|
|
129
130
|
if (!withinRoot) {
|
|
130
131
|
let dir = posix.dirname(clean);
|
|
131
132
|
while (dir !== ".") {
|
|
132
|
-
if (!packages.has(dir)) {
|
|
133
|
-
let name;
|
|
134
|
-
try {
|
|
135
|
-
const manifest = JSON.parse(readFileSync(`${dir}/package.json`, "utf8"));
|
|
136
|
-
if (manifest && typeof manifest === "object" && typeof Reflect.get(manifest, "name") === "string") name = Reflect.get(manifest, "name");
|
|
137
|
-
} catch {}
|
|
138
|
-
packages.set(dir, name);
|
|
139
|
-
}
|
|
133
|
+
if (!packages.has(dir)) packages.set(dir, manifestPackageName(`${dir}/package.json`));
|
|
140
134
|
const name = packages.get(dir);
|
|
141
135
|
if (name) return `node_modules/${name}/${posix.relative(dir, clean)}`;
|
|
142
136
|
const parent = posix.dirname(dir);
|
|
@@ -206,8 +200,7 @@ function moduleGroup(id) {
|
|
|
206
200
|
kind: "app"
|
|
207
201
|
};
|
|
208
202
|
}
|
|
209
|
-
|
|
210
|
-
//#region src/checks.ts
|
|
203
|
+
// src/checks.ts
|
|
211
204
|
function finding(code, diagnostic, rest) {
|
|
212
205
|
return {
|
|
213
206
|
code,
|
|
@@ -223,13 +216,11 @@ function finding(code, diagnostic, rest) {
|
|
|
223
216
|
function serverChain(explain, target) {
|
|
224
217
|
return explain(target).find((explanation) => explanation.side === "server")?.chain ?? [];
|
|
225
218
|
}
|
|
226
|
-
/** Each rule once, also when several server environments carry it. */
|
|
227
219
|
function uniqueRules(reports) {
|
|
228
220
|
const rules = /* @__PURE__ */ new Map();
|
|
229
221
|
for (const report of reports) for (const rule of report.side === "server" ? report.rules ?? [] : []) rules.set(JSON.stringify(rule), rule);
|
|
230
222
|
return [...rules.values()];
|
|
231
223
|
}
|
|
232
|
-
/** A feature's configuration says nothing about independent consumers of the same packages. */
|
|
233
224
|
function exclusivelyOwned(reports, rule) {
|
|
234
225
|
let ownedImport = false;
|
|
235
226
|
for (const report of reports) {
|
|
@@ -246,7 +237,6 @@ function exclusivelyOwned(reports, rule) {
|
|
|
246
237
|
}
|
|
247
238
|
return ownedImport;
|
|
248
239
|
}
|
|
249
|
-
/** A package that a feature declared as not needed at startup, and that loads at startup. */
|
|
250
240
|
function startupUnused(server, rules, explain) {
|
|
251
241
|
return rules.flatMap((rule) => {
|
|
252
242
|
const packages = server.groups.filter((group) => rule.packages.includes(group.name) && group.startupBytes > 0).map((group) => ({
|
|
@@ -268,7 +258,6 @@ function startupUnused(server, rules, explain) {
|
|
|
268
258
|
})];
|
|
269
259
|
});
|
|
270
260
|
}
|
|
271
|
-
/** Server output over the size that the host accepts. */
|
|
272
261
|
function hostSizeLimit(server, host, explain) {
|
|
273
262
|
if (!host?.startsWith("cloudflare") || server.bytes <= 67108864) return [];
|
|
274
263
|
const largest = server.groups[0];
|
|
@@ -288,79 +277,78 @@ function checkBundle(reports, server, host, explain) {
|
|
|
288
277
|
return [...hostSizeLimit(server, host, explain), ...startupUnused(server, uniqueRules(reports).filter((rule) => exclusivelyOwned(reports, rule)), explain)];
|
|
289
278
|
}
|
|
290
279
|
/**
|
|
291
|
-
* @vue/shared v3.5.
|
|
280
|
+
* @vue/shared v3.5.46
|
|
292
281
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
293
282
|
* @license MIT
|
|
294
283
|
**/
|
|
295
284
|
/**
|
|
296
|
-
* @vue/shared v3.5.
|
|
285
|
+
* @vue/shared v3.5.46
|
|
297
286
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
298
287
|
* @license MIT
|
|
299
288
|
**/
|
|
300
289
|
/**
|
|
301
|
-
* @vue/compiler-core v3.5.
|
|
290
|
+
* @vue/compiler-core v3.5.46
|
|
302
291
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
303
292
|
* @license MIT
|
|
304
293
|
**/
|
|
305
294
|
/**
|
|
306
|
-
* @vue/compiler-core v3.5.
|
|
295
|
+
* @vue/compiler-core v3.5.46
|
|
307
296
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
308
297
|
* @license MIT
|
|
309
298
|
**/
|
|
310
299
|
/**
|
|
311
|
-
* @vue/compiler-dom v3.5.
|
|
300
|
+
* @vue/compiler-dom v3.5.46
|
|
312
301
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
313
302
|
* @license MIT
|
|
314
303
|
**/
|
|
315
304
|
/**
|
|
316
|
-
* @vue/compiler-dom v3.5.
|
|
305
|
+
* @vue/compiler-dom v3.5.46
|
|
317
306
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
318
307
|
* @license MIT
|
|
319
308
|
**/
|
|
320
309
|
/**
|
|
321
|
-
* @vue/reactivity v3.5.
|
|
310
|
+
* @vue/reactivity v3.5.46
|
|
322
311
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
323
312
|
* @license MIT
|
|
324
313
|
**/
|
|
325
314
|
/**
|
|
326
|
-
* @vue/reactivity v3.5.
|
|
315
|
+
* @vue/reactivity v3.5.46
|
|
327
316
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
328
317
|
* @license MIT
|
|
329
318
|
**/
|
|
330
319
|
/**
|
|
331
|
-
* @vue/runtime-core v3.5.
|
|
320
|
+
* @vue/runtime-core v3.5.46
|
|
332
321
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
333
322
|
* @license MIT
|
|
334
323
|
**/
|
|
335
324
|
/**
|
|
336
|
-
* @vue/runtime-core v3.5.
|
|
325
|
+
* @vue/runtime-core v3.5.46
|
|
337
326
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
338
327
|
* @license MIT
|
|
339
328
|
**/
|
|
340
329
|
/**
|
|
341
|
-
* @vue/runtime-dom v3.5.
|
|
330
|
+
* @vue/runtime-dom v3.5.46
|
|
342
331
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
343
332
|
* @license MIT
|
|
344
333
|
**/
|
|
345
334
|
/**
|
|
346
|
-
* @vue/runtime-dom v3.5.
|
|
335
|
+
* @vue/runtime-dom v3.5.46
|
|
347
336
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
348
337
|
* @license MIT
|
|
349
338
|
**/
|
|
350
339
|
/**
|
|
351
|
-
* vue v3.5.
|
|
340
|
+
* vue v3.5.46
|
|
352
341
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
353
342
|
* @license MIT
|
|
354
343
|
**/
|
|
355
344
|
/**
|
|
356
|
-
* vue v3.5.
|
|
345
|
+
* vue v3.5.46
|
|
357
346
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
358
347
|
* @license MIT
|
|
359
348
|
**/
|
|
360
|
-
|
|
361
|
-
//#region ../../node_modules/.pnpm/vue-router@5.4.0_@voidzero-dev+vite-plus-core@0.3.3_@types+node@24.19.1_esbuild@0.28.2__771eab81e2fd06a479763e79bcb19884/node_modules/vue-router/dist/useApi-CUWMwLLw.js
|
|
349
|
+
// ../../node_modules/.pnpm/vue-router@5.5.1_@voidzero-dev+vite-plus-core@8.3.8000_@types+node@24.19.2_@volar+types_99e0e228147a3ec8c7594d93201c6498/node_modules/vue-router/dist/useApi-SF8tY_yo.js
|
|
362
350
|
/*!
|
|
363
|
-
* vue-router v5.
|
|
351
|
+
* vue-router v5.5.1
|
|
364
352
|
* (c) 2026 Eduardo San Martin Morote
|
|
365
353
|
* @license MIT
|
|
366
354
|
*/
|
|
@@ -460,10 +448,34 @@ const diagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
460
448
|
why: (p) => `The optional path param "${p.param}" is being removed with ${p.value}.`,
|
|
461
449
|
fix: "Use null to remove an optional path param."
|
|
462
450
|
},
|
|
451
|
+
VUE_ROUTER_R0124: {
|
|
452
|
+
why: (p) => `The repeatable param "${p.param}" cannot be empty.`,
|
|
453
|
+
fix: "Pass at least one value, or make the param optional."
|
|
454
|
+
},
|
|
455
|
+
VUE_ROUTER_R0123: {
|
|
456
|
+
why: (p) => `The query value of "${p.key}" is ignored because a param already sets this key.`,
|
|
457
|
+
fix: (p) => `Pass the value in \`params\` instead of \`query\`, or omit "${p.key}" from \`query\`.`
|
|
458
|
+
},
|
|
459
|
+
VUE_ROUTER_R0126: {
|
|
460
|
+
why: (p) => `An error was thrown while matching "${p.path}" against the route "${p.name}". The route is skipped.`,
|
|
461
|
+
fix: "Return null from match() to skip a route, or call miss() in a param parser. Fix the thrown error if it is a bug."
|
|
462
|
+
},
|
|
463
|
+
VUE_ROUTER_R0129: {
|
|
464
|
+
why: (p) => `Cannot resolve a relative location without a "name": there is no current location, or the current location has no route. This crashes in production.\nLocation: ${stringifyRoute(p.location)}`,
|
|
465
|
+
fix: "Pass the location it is relative to as the second argument of resolve(), or use a location with a \"name\" or an absolute \"path\"."
|
|
466
|
+
},
|
|
467
|
+
VUE_ROUTER_R0125: {
|
|
468
|
+
why: (p) => `The params, query, or hash do not match the route "${p.name}".`,
|
|
469
|
+
fix: "Pass params, query, and hash values that the route matchers accept."
|
|
470
|
+
},
|
|
463
471
|
VUE_ROUTER_D0001: {
|
|
464
472
|
why: (p) => `Route "${p.name}" uses beforeEnter, which is deprecated in the experimental router.`,
|
|
465
473
|
fix: "Move the condition to the route meta field and check to.meta in router.beforeEach()."
|
|
466
474
|
},
|
|
475
|
+
VUE_ROUTER_R0130: {
|
|
476
|
+
why: (p) => `Cannot resolve a relative location before the initial navigation: there is no current route yet. This crashes in production.\nLocation: ${stringifyRoute(p.location)}`,
|
|
477
|
+
fix: "Use a location with a \"name\" or an absolute \"path\", await router.isReady() before mounting the app, or render the <RouterLink> inside a page component so it only renders after the initial navigation."
|
|
478
|
+
},
|
|
467
479
|
VUE_ROUTER_D0002: {
|
|
468
480
|
why: (p) => `The query value of "${p.key}" is not an array (${p.value}). Non array query values are deprecated in the experimental router.`,
|
|
469
481
|
fix: (p) => `Wrap the value in an array: \`{ ${JSON.stringify(p.key)}: [${p.value}] }\`. Use undefined to remove the key.`
|
|
@@ -651,6 +663,10 @@ const diagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
651
663
|
why: (p) => `Finding ancestor route "${p.ancestor}" failed for "${p.record}"`,
|
|
652
664
|
fix: "Report a reproduction at https://github.com/vuejs/router/issues/new/choose."
|
|
653
665
|
},
|
|
666
|
+
VUE_ROUTER_R0106: {
|
|
667
|
+
why: (p) => `Repeatable param "${p.name}" was provided without an array.`,
|
|
668
|
+
fix: (p) => `Pass it as an array, even when it has one item: { ${JSON.stringify(p.name)}: [value] }. If the param is optional (e.g. ":${p.name}*"), pass an empty array or null to remove it.`
|
|
669
|
+
},
|
|
654
670
|
VUE_ROUTER_R0110: {
|
|
655
671
|
why: `A hash base must end with a "#"`,
|
|
656
672
|
fix: (p) => `Append "#" to the "base" argument passed to "createWebHashHistory()": "${p.base}" should be "${p.suggestion}".`
|
|
@@ -664,6 +680,16 @@ const diagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
664
680
|
fix: "Merge the router's state into your own when calling it manually: `history.replaceState({ ...history.state, ...yourState }, '', url)`.",
|
|
665
681
|
docs: "https://router.vuejs.org/guide/migration.html#Usage-of-history-state"
|
|
666
682
|
},
|
|
683
|
+
VUE_ROUTER_R0127: {
|
|
684
|
+
why: "The page is loaded from a file:// URL. createWebHistory() cannot reliably change the path of file:// URLs.",
|
|
685
|
+
fix: "Use createWebHashHistory() instead.",
|
|
686
|
+
docs: "https://router.vuejs.org/guide/essentials/history-mode.html#hash-mode"
|
|
687
|
+
},
|
|
688
|
+
VUE_ROUTER_R0128: {
|
|
689
|
+
why: "The page is loaded in an about: URL (e.g. an iframe with srcdoc). Browsers do not let the web and hash histories change this URL.",
|
|
690
|
+
fix: "Use createMemoryHistory() instead.",
|
|
691
|
+
docs: "https://router.vuejs.org/guide/essentials/history-mode.html#memory-mode"
|
|
692
|
+
},
|
|
667
693
|
VUE_ROUTER_R1001: {
|
|
668
694
|
why: (p) => `Data loader "${String(p.key)}" has a different parent than the current context. This shouldn't be happening.`,
|
|
669
695
|
fix: "Report a bug with a minimal reproduction at https://github.com/vuejs/router/."
|
|
@@ -714,20 +740,18 @@ Symbol(process.env.NODE_ENV !== "production" ? "router" : "");
|
|
|
714
740
|
Symbol(process.env.NODE_ENV !== "production" ? "route location" : "");
|
|
715
741
|
Symbol(process.env.NODE_ENV !== "production" ? "router view location" : "");
|
|
716
742
|
Symbol(process.env.NODE_ENV !== "production" ? "router view on route rendered" : "");
|
|
717
|
-
|
|
718
|
-
//#region ../../node_modules/.pnpm/vue-router@5.4.0_@voidzero-dev+vite-plus-core@0.3.3_@types+node@24.19.1_esbuild@0.28.2__771eab81e2fd06a479763e79bcb19884/node_modules/vue-router/dist/devtools-CxgSYwGp.js
|
|
743
|
+
// ../../node_modules/.pnpm/vue-router@5.5.1_@voidzero-dev+vite-plus-core@8.3.8000_@types+node@24.19.2_@volar+types_99e0e228147a3ec8c7594d93201c6498/node_modules/vue-router/dist/devtools-RytpElE1.js
|
|
719
744
|
/*!
|
|
720
|
-
* vue-router v5.
|
|
745
|
+
* vue-router v5.5.1
|
|
721
746
|
* (c) 2026 Eduardo San Martin Morote
|
|
722
747
|
* @license MIT
|
|
723
748
|
*/
|
|
724
749
|
function isRouteName(name) {
|
|
725
750
|
return typeof name === "string" || typeof name === "symbol";
|
|
726
751
|
}
|
|
727
|
-
|
|
728
|
-
//#region ../../node_modules/.pnpm/vue-router@5.4.0_@voidzero-dev+vite-plus-core@0.3.3_@types+node@24.19.1_esbuild@0.28.2__771eab81e2fd06a479763e79bcb19884/node_modules/vue-router/dist/vue-router.js
|
|
752
|
+
// ../../node_modules/.pnpm/vue-router@5.5.1_@voidzero-dev+vite-plus-core@8.3.8000_@types+node@24.19.2_@volar+types_99e0e228147a3ec8c7594d93201c6498/node_modules/vue-router/dist/vue-router.js
|
|
729
753
|
/*!
|
|
730
|
-
* vue-router v5.
|
|
754
|
+
* vue-router v5.5.1
|
|
731
755
|
* (c) 2026 Eduardo San Martin Morote
|
|
732
756
|
* @license MIT
|
|
733
757
|
*/
|
|
@@ -831,7 +855,7 @@ const BASE_PATH_PARSER_OPTIONS = {
|
|
|
831
855
|
start: true,
|
|
832
856
|
end: true
|
|
833
857
|
};
|
|
834
|
-
const REGEX_CHARS_RE = /[.+*?^${}()[\]
|
|
858
|
+
const REGEX_CHARS_RE = /[.+*?^${}()[\]/\\|]/g;
|
|
835
859
|
/**
|
|
836
860
|
* Creates a path parser from an array of Segments (a segment is an array of Tokens)
|
|
837
861
|
*
|
|
@@ -844,6 +868,7 @@ function tokensToParser(segments, extraOptions) {
|
|
|
844
868
|
const score = [];
|
|
845
869
|
let pattern = options.start ? "^" : "";
|
|
846
870
|
const keys = [];
|
|
871
|
+
const hasBackreference = segments.some((segment) => segment.some((token) => token.type === 1 && /\\[1-9k]/.test(token.regexp || "")));
|
|
847
872
|
for (const segment of segments) {
|
|
848
873
|
const segmentScores = segment.length ? [] : [90];
|
|
849
874
|
if (options.strict && !segment.length) pattern += "/";
|
|
@@ -870,7 +895,10 @@ function tokensToParser(segments, extraOptions) {
|
|
|
870
895
|
throw new Error(`Invalid custom RegExp for param "${value}" (${re}): ` + err.message);
|
|
871
896
|
}
|
|
872
897
|
}
|
|
873
|
-
let subPattern = repeatable ? `((?:${re})(?:/(?:${re}))*)` : `(${re})`;
|
|
898
|
+
let subPattern = repeatable && re !== ".+" && re !== ".*" ? `((?:${re})(?:/(?:${re}))*)` : `(${re})`;
|
|
899
|
+
const next = segment[tokenIndex + 1];
|
|
900
|
+
const afterNext = segment[tokenIndex + 2];
|
|
901
|
+
if (!hasBackreference && !regexp && !repeatable && afterNext && afterNext.type === 1 && !afterNext.regexp && next.type === 0) subPattern = `([^/](?:(?!${next.value.replace(REGEX_CHARS_RE, "\\$&")})[^/])*)`;
|
|
874
902
|
if (!tokenIndex) subPattern = optional && segment.length < 2 ? `(?:/${subPattern})` : "/" + subPattern;
|
|
875
903
|
if (optional) subPattern += "?";
|
|
876
904
|
pattern += subPattern;
|
|
@@ -1122,6 +1150,7 @@ function createRouterMatcher(routes, globalOptions) {
|
|
|
1122
1150
|
inherited: isInherited ? ` If you are using a catch-all route with a named redirect, pass an empty \`params\` object: \`redirect: { name: '...', params: {} }\`.` : ""
|
|
1123
1151
|
});
|
|
1124
1152
|
}
|
|
1153
|
+
checkParamValues(matcher, location.params);
|
|
1125
1154
|
}
|
|
1126
1155
|
name = matcher.record.name;
|
|
1127
1156
|
params = assign(pickParams(currentLocation.params, matcher.keys.filter((k) => !k.optional).concat(matcher.parent ? matcher.parent.keys.filter((k) => k.optional) : []).map((k) => k.name)), location.params && pickParams(location.params, matcher.keys.map((k) => k.name)));
|
|
@@ -1143,6 +1172,7 @@ function createRouterMatcher(routes, globalOptions) {
|
|
|
1143
1172
|
location,
|
|
1144
1173
|
currentLocation
|
|
1145
1174
|
});
|
|
1175
|
+
if (process.env.NODE_ENV !== "production") checkParamValues(matcher, location.params);
|
|
1146
1176
|
name = matcher.record.name;
|
|
1147
1177
|
params = assign({}, currentLocation.params, location.params);
|
|
1148
1178
|
path = matcher.stringify(params);
|
|
@@ -1281,6 +1311,23 @@ function checkChildMissingNameWithEmptyPath(mainNormalizedRecord, parent) {
|
|
|
1281
1311
|
function checkSameNameAsAncestor(record, parent) {
|
|
1282
1312
|
for (let ancestor = parent; ancestor; ancestor = ancestor.parent) if (ancestor.record.name === record.name) throw new Error(`A route named "${String(record.name)}" has been added as a ${parent === ancestor ? "child" : "descendant"} of a route with the same name. Route names must be unique and a nested route cannot use the same name as an ancestor.`);
|
|
1283
1313
|
}
|
|
1314
|
+
/**
|
|
1315
|
+
* Warns about explicit param values that are probably mistakes.
|
|
1316
|
+
*
|
|
1317
|
+
* @param matcher - matcher of the resolved location
|
|
1318
|
+
* @param params - params explicitly passed in the location
|
|
1319
|
+
*/
|
|
1320
|
+
function checkParamValues(matcher, params) {
|
|
1321
|
+
if (!params) return;
|
|
1322
|
+
for (const key of matcher.keys) {
|
|
1323
|
+
const value = params[key.name];
|
|
1324
|
+
if (key.optional && value === "") diagnostics.VUE_ROUTER_R0122({
|
|
1325
|
+
param: key.name,
|
|
1326
|
+
value: "an empty string"
|
|
1327
|
+
});
|
|
1328
|
+
else if (key.repeatable && value != null && !Array.isArray(value)) diagnostics.VUE_ROUTER_R0106({ name: key.name });
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1284
1331
|
function checkMissingParamsInAbsolutePath(record, parent) {
|
|
1285
1332
|
for (const key of parent.keys) if (!record.keys.find(isSameParam.bind(null, key))) {
|
|
1286
1333
|
diagnostics.VUE_ROUTER_R0104({
|
|
@@ -1332,8 +1379,7 @@ function getInsertionAncestor(matcher) {
|
|
|
1332
1379
|
function isMatchable({ record }) {
|
|
1333
1380
|
return !!(record.name || record.components && Object.keys(record.components).length || record.redirect);
|
|
1334
1381
|
}
|
|
1335
|
-
|
|
1336
|
-
//#region src/routes.ts
|
|
1382
|
+
// src/routes.ts
|
|
1337
1383
|
function joinPath(parent, path) {
|
|
1338
1384
|
if (path.startsWith("/")) return path;
|
|
1339
1385
|
if (!path) return parent;
|
|
@@ -1376,13 +1422,12 @@ function graphOf(report) {
|
|
|
1376
1422
|
const holders = /* @__PURE__ */ new Map();
|
|
1377
1423
|
for (const chunk of report.chunks) for (const module of chunk.modules) holders.set(module.id, [...holders.get(module.id) ?? [], chunk.file]);
|
|
1378
1424
|
return {
|
|
1379
|
-
report,
|
|
1380
1425
|
byFile: new Map(report.chunks.map((chunk) => [chunk.file, chunk])),
|
|
1426
|
+
stylesheets: new Map((report.css ?? []).map((file) => [file.file, file])),
|
|
1381
1427
|
holders,
|
|
1382
1428
|
startup: report.chunks.filter((chunk) => chunk.startup).map((chunk) => chunk.file)
|
|
1383
1429
|
};
|
|
1384
1430
|
}
|
|
1385
|
-
/** The JavaScript files that a first visit loads: the startup files and the component files with their static imports. */
|
|
1386
1431
|
function routeFiles(graph, source) {
|
|
1387
1432
|
const files = new Set(graph.startup);
|
|
1388
1433
|
const pending = source.components.flatMap((id) => graph.holders.get(id) ?? []);
|
|
@@ -1396,7 +1441,6 @@ function routeFiles(graph, source) {
|
|
|
1396
1441
|
}
|
|
1397
1442
|
function routeOf(graph, source) {
|
|
1398
1443
|
const files = [...routeFiles(graph, source)].flatMap((file) => graph.byFile.get(file) ?? []);
|
|
1399
|
-
const cssSizes = new Map((graph.report.css ?? []).map((file) => [file.file, file]));
|
|
1400
1444
|
const css = /* @__PURE__ */ new Map();
|
|
1401
1445
|
for (const chunk of files) for (const file of chunk.css ?? []) css.set(file, (css.get(file) ?? false) || chunk.startup);
|
|
1402
1446
|
const js = files.map((chunk) => ({
|
|
@@ -1406,7 +1450,7 @@ function routeOf(graph, source) {
|
|
|
1406
1450
|
startup: chunk.startup
|
|
1407
1451
|
}));
|
|
1408
1452
|
const styles = [...css].flatMap(([file, startup]) => {
|
|
1409
|
-
const size =
|
|
1453
|
+
const size = graph.stylesheets.get(file);
|
|
1410
1454
|
return size ? [{
|
|
1411
1455
|
...size,
|
|
1412
1456
|
startup
|
|
@@ -1455,8 +1499,7 @@ function explainRoute(report, target) {
|
|
|
1455
1499
|
})) ?? []).sort((left, right) => right.bytes - left.bytes || left.id.localeCompare(right.id))
|
|
1456
1500
|
};
|
|
1457
1501
|
}
|
|
1458
|
-
|
|
1459
|
-
//#region src/report.ts
|
|
1502
|
+
// src/report.ts
|
|
1460
1503
|
/** The reports of the newest build. Reports that an older build left behind are ignored. */
|
|
1461
1504
|
function latestBuild(reports) {
|
|
1462
1505
|
const build = reports.map((report) => report.build).sort().at(-1);
|
|
@@ -1465,17 +1508,13 @@ function latestBuild(reports) {
|
|
|
1465
1508
|
function outputPath(report, file) {
|
|
1466
1509
|
return report.outDir === "." ? file : `${report.outDir}/${file}`;
|
|
1467
1510
|
}
|
|
1468
|
-
/**
|
|
1469
|
-
* A server build that bundles the output of another server build, such as Nitro bundling Nuxt's SSR output, holds that
|
|
1470
|
-
* output as opaque modules. This returns, for each such module, the inner environment and chunk.
|
|
1471
|
-
*/
|
|
1472
1511
|
function innerOutputs(reports) {
|
|
1473
1512
|
const outputs = /* @__PURE__ */ new Map();
|
|
1474
1513
|
for (const report of reports) {
|
|
1475
1514
|
if (report.side !== "server") continue;
|
|
1476
1515
|
for (const chunk of report.chunks) outputs.set(outputPath(report, chunk.file), {
|
|
1477
|
-
report,
|
|
1478
|
-
|
|
1516
|
+
environment: report.environment,
|
|
1517
|
+
chunk
|
|
1479
1518
|
});
|
|
1480
1519
|
}
|
|
1481
1520
|
return outputs;
|
|
@@ -1485,15 +1524,13 @@ function isInner(report, reports) {
|
|
|
1485
1524
|
const files = new Set(report.chunks.map((chunk) => outputPath(report, chunk.file)));
|
|
1486
1525
|
return reports.some((other) => other !== report && other.side === "server" && other.chunks.some((chunk) => chunk.modules.some((module) => files.has(module.id))));
|
|
1487
1526
|
}
|
|
1488
|
-
/** Every module of a side, with SSR output that Nitro bundles replaced by the SSR modules, scaled to Nitro's bytes. */
|
|
1489
1527
|
function placedModules(outer, all) {
|
|
1490
1528
|
const inner = innerOutputs(all.filter((report) => !outer.includes(report)));
|
|
1491
1529
|
const placed = [];
|
|
1492
1530
|
for (const report of outer) for (const chunk of report.chunks) for (const module of chunk.modules) {
|
|
1493
1531
|
const source = inner.get(module.id);
|
|
1494
|
-
const
|
|
1495
|
-
|
|
1496
|
-
if (!source || !sourceChunk || total === 0) {
|
|
1532
|
+
const total = source?.chunk.modules.reduce((sum, part) => sum + part.bytes, 0) ?? 0;
|
|
1533
|
+
if (!source || total === 0) {
|
|
1497
1534
|
placed.push({
|
|
1498
1535
|
...module,
|
|
1499
1536
|
environment: report.environment,
|
|
@@ -1501,11 +1538,11 @@ function placedModules(outer, all) {
|
|
|
1501
1538
|
});
|
|
1502
1539
|
continue;
|
|
1503
1540
|
}
|
|
1504
|
-
const shares = allocateBytes(
|
|
1505
|
-
for (const [index, part] of
|
|
1541
|
+
const shares = allocateBytes(source.chunk.modules.map((part) => part.bytes), module.bytes);
|
|
1542
|
+
for (const [index, part] of source.chunk.modules.entries()) placed.push({
|
|
1506
1543
|
...part,
|
|
1507
1544
|
bytes: shares[index],
|
|
1508
|
-
environment: source.
|
|
1545
|
+
environment: source.environment,
|
|
1509
1546
|
startup: chunk.startup
|
|
1510
1547
|
});
|
|
1511
1548
|
}
|
|
@@ -1576,17 +1613,17 @@ function createBundleReport(reports) {
|
|
|
1576
1613
|
findings
|
|
1577
1614
|
};
|
|
1578
1615
|
}
|
|
1579
|
-
function
|
|
1580
|
-
if (
|
|
1581
|
-
|
|
1582
|
-
|
|
1616
|
+
function moduleMatcher(target, reports) {
|
|
1617
|
+
if (target.startsWith("./") || target.startsWith(".\\")) {
|
|
1618
|
+
const file = reports.some((report) => report.chunks.some((chunk) => chunk.modules.some((module) => module.id === target))) ? target : posix.normalize(target.replaceAll("\\", "/"));
|
|
1619
|
+
return (id) => id === file;
|
|
1583
1620
|
}
|
|
1584
|
-
return
|
|
1621
|
+
return (id) => {
|
|
1622
|
+
if (id === target) return true;
|
|
1623
|
+
if (id.startsWith("node_modules/")) return moduleGroup(id).name === target || id.startsWith(`node_modules/${target}/`);
|
|
1624
|
+
return id.startsWith(`${target}/`) || id.endsWith(`/${target}`);
|
|
1625
|
+
};
|
|
1585
1626
|
}
|
|
1586
|
-
/**
|
|
1587
|
-
* The shortest import chain from an entry of one environment to a module that matches. Static imports come first: a
|
|
1588
|
-
* module that loads at startup gets the chain that loads it, not a lazy one. Without a static chain, `import()` counts.
|
|
1589
|
-
*/
|
|
1590
1627
|
function chainIn(report, found) {
|
|
1591
1628
|
return searchChain(report, found, false) ?? searchChain(report, found, true);
|
|
1592
1629
|
}
|
|
@@ -1624,16 +1661,17 @@ function searchChain(report, found, dynamic) {
|
|
|
1624
1661
|
*/
|
|
1625
1662
|
function explainBundle(reports, target) {
|
|
1626
1663
|
const current = latestBuild(reports);
|
|
1664
|
+
const matches = moduleMatcher(target, current);
|
|
1627
1665
|
const explanations = [];
|
|
1628
1666
|
for (const side of ["client", "server"]) {
|
|
1629
1667
|
const own = current.filter((report) => report.side === side);
|
|
1630
1668
|
const outer = own.filter((report) => !isInner(report, current));
|
|
1631
|
-
const hits = placedModules(outer, current).filter((module) => matches(module.id
|
|
1669
|
+
const hits = placedModules(outer, current).filter((module) => matches(module.id));
|
|
1632
1670
|
if (!hits.length) continue;
|
|
1633
1671
|
const inner = own.filter((report) => !outer.includes(report));
|
|
1634
1672
|
let chain = [];
|
|
1635
1673
|
for (const report of outer) {
|
|
1636
|
-
const direct = chainIn(report,
|
|
1674
|
+
const direct = chainIn(report, matches);
|
|
1637
1675
|
if (direct) {
|
|
1638
1676
|
chain = direct.map((id) => ({
|
|
1639
1677
|
environment: report.environment,
|
|
@@ -1642,7 +1680,7 @@ function explainBundle(reports, target) {
|
|
|
1642
1680
|
break;
|
|
1643
1681
|
}
|
|
1644
1682
|
for (const nested of inner) {
|
|
1645
|
-
const innerChain = chainIn(nested,
|
|
1683
|
+
const innerChain = chainIn(nested, matches);
|
|
1646
1684
|
if (!innerChain) continue;
|
|
1647
1685
|
const entryFiles = new Set(nested.chunks.filter((chunk) => chunk.entry).map((chunk) => outputPath(nested, chunk.file)));
|
|
1648
1686
|
const outerChain = chainIn(report, (id) => entryFiles.has(id));
|
|
@@ -1680,8 +1718,7 @@ function explainBundleRoute(reports, target) {
|
|
|
1680
1718
|
if (explanation) return explanation;
|
|
1681
1719
|
}
|
|
1682
1720
|
}
|
|
1683
|
-
|
|
1684
|
-
//#region src/compare.ts
|
|
1721
|
+
// src/compare.ts
|
|
1685
1722
|
function totals(side) {
|
|
1686
1723
|
return side ? {
|
|
1687
1724
|
bytes: side.bytes,
|
|
@@ -1775,11 +1812,23 @@ function isBundleReport(value) {
|
|
|
1775
1812
|
}
|
|
1776
1813
|
/**
|
|
1777
1814
|
* Reads a report to compare with. `path` is the output of `vitehub bundle --json`, a copy of `.vitehub/bundle/`, or a
|
|
1778
|
-
* project root that has `.vitehub/bundle
|
|
1815
|
+
* project root that has `.vitehub/bundle/` or a `.vitehub/bundle-root.json` that points to it. Returns `undefined` when
|
|
1816
|
+
* `path` holds no report.
|
|
1779
1817
|
*/
|
|
1780
1818
|
function readSavedBundleReport(path) {
|
|
1781
1819
|
if (!existsSync(path)) return void 0;
|
|
1782
|
-
if (statSync(path).isDirectory())
|
|
1820
|
+
if (statSync(path).isDirectory()) {
|
|
1821
|
+
const reportRoot = readBundleReportRoot(path);
|
|
1822
|
+
for (const folder of [
|
|
1823
|
+
...reportRoot ? [join(reportRoot, bundleReportDir)] : [],
|
|
1824
|
+
join(path, bundleReportDir),
|
|
1825
|
+
path
|
|
1826
|
+
]) {
|
|
1827
|
+
const report = createBundleReport(readEnvironmentReportFolder(folder));
|
|
1828
|
+
if (report) return report;
|
|
1829
|
+
}
|
|
1830
|
+
return;
|
|
1831
|
+
}
|
|
1783
1832
|
try {
|
|
1784
1833
|
const value = JSON.parse(readFileSync(path, "utf8"));
|
|
1785
1834
|
return isBundleReport(value) ? value : void 0;
|
|
@@ -1787,5 +1836,4 @@ function readSavedBundleReport(path) {
|
|
|
1787
1836
|
return;
|
|
1788
1837
|
}
|
|
1789
1838
|
}
|
|
1790
|
-
//#endregion
|
|
1791
1839
|
export { explainBundleRoute as a, moduleId as c, bundleReportDir as d, readBundleReportRoot as f, writeEnvironmentReport as h, explainBundle as i, allocateBytes as l, writeBundleReportRoot as m, readSavedBundleReport as n, nuxtPageRoutes as o, readEnvironmentReports as p, createBundleReport as r, moduleGroup as s, compareBundleReports as t, formatBytes as u };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,27 +1,21 @@
|
|
|
1
|
-
import { C as BundleStartupRule, S as BundleSideComparison, _ as BundleRouteFile, a as BundleExplanation, b as BundleRouteSource, c as BundleFindingCode, d as BundleGroupKind, f as BundleGroupSize, g as BundleRouteExplanation, h as BundleRoute, i as BundleEnvironmentReport, l as BundleGroup, m as BundleReport, n as BundleChunk, o as BundleFile, p as BundleModule, r as BundleComparison, s as BundleFinding, t as BundleChainStep, u as BundleGroupChange, v as BundleRouteModule, w as BundleTotals, x as BundleSide, y as BundleRouteOptions } from "./types-
|
|
2
|
-
//#region src/compare.d.ts
|
|
1
|
+
import { C as BundleStartupRule, S as BundleSideComparison, _ as BundleRouteFile, a as BundleExplanation, b as BundleRouteSource, c as BundleFindingCode, d as BundleGroupKind, f as BundleGroupSize, g as BundleRouteExplanation, h as BundleRoute, i as BundleEnvironmentReport, l as BundleGroup, m as BundleReport, n as BundleChunk, o as BundleFile, p as BundleModule, r as BundleComparison, s as BundleFinding, t as BundleChainStep, u as BundleGroupChange, v as BundleRouteModule, w as BundleTotals, x as BundleSide, y as BundleRouteOptions } from "./types-D4oYDFpA.js";
|
|
3
2
|
/** What changed from `before` to `after`: the bytes of each side and of its startup code, and each group that changed. */
|
|
4
3
|
export declare function compareBundleReports(before: BundleReport, after: BundleReport): BundleComparison;
|
|
5
4
|
/**
|
|
6
5
|
* Reads a report to compare with. `path` is the output of `vitehub bundle --json`, a copy of `.vitehub/bundle/`, or a
|
|
7
|
-
* project root that has `.vitehub/bundle
|
|
6
|
+
* project root that has `.vitehub/bundle/` or a `.vitehub/bundle-root.json` that points to it. Returns `undefined` when
|
|
7
|
+
* `path` holds no report.
|
|
8
8
|
*/
|
|
9
9
|
export declare function readSavedBundleReport(path: string): BundleReport | undefined;
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region src/files.d.ts
|
|
12
10
|
/** Folder of the environment reports, relative to the project root. */
|
|
13
11
|
export declare const bundleReportDir = ".vitehub/bundle";
|
|
14
12
|
/** Reads every environment report in `.vitehub/bundle/`. A file that is not a report is skipped. */
|
|
15
13
|
export declare function readEnvironmentReports(root: string): BundleEnvironmentReport[];
|
|
16
|
-
//#endregion
|
|
17
|
-
//#region src/groups.d.ts
|
|
18
14
|
/** Names the group of a root-relative module id. */
|
|
19
15
|
export declare function moduleGroup(id: string): {
|
|
20
16
|
name: string;
|
|
21
17
|
kind: BundleGroupKind;
|
|
22
18
|
};
|
|
23
|
-
//#endregion
|
|
24
|
-
//#region src/report.d.ts
|
|
25
19
|
/** Joins the environment reports of one build into the report of the app. */
|
|
26
20
|
export declare function createBundleReport(reports: readonly BundleEnvironmentReport[]): BundleReport | undefined;
|
|
27
21
|
/**
|
|
@@ -34,13 +28,10 @@ export declare function explainBundle(reports: readonly BundleEnvironmentReport[
|
|
|
34
28
|
* route's layout and pages, and the modules that the route adds. `undefined` when no route of the last build matches.
|
|
35
29
|
*/
|
|
36
30
|
export declare function explainBundleRoute(reports: readonly BundleEnvironmentReport[], target: string): BundleRouteExplanation | undefined;
|
|
37
|
-
//#endregion
|
|
38
|
-
//#region src/index.d.ts
|
|
39
31
|
/** The report of the last build with `bundle` on, or `undefined` when there is none. */
|
|
40
32
|
export declare function readBundleReport(root: string): BundleReport | undefined;
|
|
41
33
|
/** Why `target` (a package, a file, or a group) is in the last build. Empty when the build does not contain it. */
|
|
42
34
|
export declare function explainBundleTarget(root: string, target: string): BundleExplanation[];
|
|
43
35
|
/** What the browser loads on a first visit to the page route that renders `path`, such as `/docs/kv`. */
|
|
44
36
|
export declare function explainBundleRouteTarget(root: string, path: string): BundleRouteExplanation | undefined;
|
|
45
|
-
//#endregion
|
|
46
37
|
export type { BundleChainStep, BundleChunk, BundleComparison, BundleEnvironmentReport, BundleExplanation, BundleFile, BundleFinding, BundleFindingCode, BundleGroup, BundleGroupChange, BundleGroupKind, BundleGroupSize, BundleModule, BundleReport, BundleRoute, BundleRouteExplanation, BundleRouteFile, BundleRouteModule, BundleRouteOptions, BundleRouteSource, BundleSide, BundleSideComparison, BundleStartupRule, BundleTotals };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as explainBundleRoute, d as bundleReportDir, i as explainBundle, n as readSavedBundleReport, p as readEnvironmentReports, r as createBundleReport, s as moduleGroup, t as compareBundleReports } from "./compare-
|
|
2
|
-
|
|
1
|
+
import { a as explainBundleRoute, d as bundleReportDir, i as explainBundle, n as readSavedBundleReport, p as readEnvironmentReports, r as createBundleReport, s as moduleGroup, t as compareBundleReports } from "./compare-3VnwI84U.js";
|
|
2
|
+
// src/index.ts
|
|
3
3
|
/** The report of the last build with `bundle` on, or `undefined` when there is none. */
|
|
4
4
|
function readBundleReport(root) {
|
|
5
5
|
return createBundleReport(readEnvironmentReports(root));
|
|
@@ -12,5 +12,4 @@ function explainBundleTarget(root, target) {
|
|
|
12
12
|
function explainBundleRouteTarget(root, path) {
|
|
13
13
|
return explainBundleRoute(readEnvironmentReports(root), path);
|
|
14
14
|
}
|
|
15
|
-
//#endregion
|
|
16
15
|
export { bundleReportDir, compareBundleReports, createBundleReport, explainBundle, explainBundleRoute, explainBundleRouteTarget, explainBundleTarget, moduleGroup, readBundleReport, readEnvironmentReports, readSavedBundleReport };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// ../internal/src/object.ts
|
|
2
2
|
/** A non-null object that is not an array. Functions do not pass. */
|
|
3
3
|
function isRecord(value) {
|
|
4
4
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -7,5 +7,4 @@ function isRecord(value) {
|
|
|
7
7
|
function isRecordOrFunction(value) {
|
|
8
8
|
return Object(value) === value && !Array.isArray(value);
|
|
9
9
|
}
|
|
10
|
-
//#endregion
|
|
11
10
|
export { isRecordOrFunction as n, isRecord as t };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/@standard-schema+spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.ts
|
|
2
1
|
/** The Standard Typed interface. This is a base type extended by other specs. */
|
|
3
2
|
interface StandardTypedV1<Input = unknown, Output = Input> {
|
|
4
3
|
/** The Standard properties. */
|
|
@@ -74,8 +73,6 @@ declare namespace StandardSchemaV1 {
|
|
|
74
73
|
/** Infers the output type of a Standard. */
|
|
75
74
|
type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
|
|
76
75
|
}
|
|
77
|
-
//#endregion
|
|
78
|
-
//#region ../internal/src/operation-definition.d.ts
|
|
79
76
|
/** `read` never changes state. `write` changes state. `destructive` deletes or publishes. */
|
|
80
77
|
type OperationKind = "read" | "write" | "destructive";
|
|
81
78
|
/** The signed-in user of a call. */
|
|
@@ -104,6 +101,11 @@ interface OperationAccess {
|
|
|
104
101
|
*/
|
|
105
102
|
readonly sections: "all" | readonly string[];
|
|
106
103
|
readonly user?: OperationUser;
|
|
104
|
+
/**
|
|
105
|
+
* Who signed the call: `"console"` when the ViteHub Console signed it for a person, whose `user` is then a Console
|
|
106
|
+
* account and not an app user, or `"cli"` for a key. Not set for other calls.
|
|
107
|
+
*/
|
|
108
|
+
readonly via?: "console" | "cli";
|
|
107
109
|
}
|
|
108
110
|
interface OperationContext {
|
|
109
111
|
/** The checked Console access of the call. */
|
|
@@ -166,7 +168,8 @@ interface OperationDefinition<Input, Output> {
|
|
|
166
168
|
/** Standard Schema (valibot in this repo). Its Standard JSON Schema builds CLI flags and the MCP input schema. */
|
|
167
169
|
input: StandardSchemaV1<unknown, Input>;
|
|
168
170
|
output?: StandardSchemaV1<unknown, Output>;
|
|
169
|
-
|
|
171
|
+
/** `false`: no `vitehub` command. The Console and MCP still call the operation. */
|
|
172
|
+
cli?: false | {
|
|
170
173
|
/** Defaults: namespace = section, command = verb. */
|
|
171
174
|
namespace?: string;
|
|
172
175
|
/** A space groups commands: `jobs list` and `jobs show` run as `vitehub <namespace> jobs list` and `jobs show`. */
|
|
@@ -207,7 +210,7 @@ interface OperationDefinition<Input, Output> {
|
|
|
207
210
|
/** An operation of any input and output, as a registry holds it. */
|
|
208
211
|
interface AnyOperation extends Omit<OperationDefinition<unknown, unknown>, "cli" | "input" | "mcp" | "output" | "readOnlyWhen" | "run" | "scope" | "section"> {
|
|
209
212
|
readOnlyWhen?: (input: never) => boolean;
|
|
210
|
-
cli?: {
|
|
213
|
+
cli?: false | {
|
|
211
214
|
namespace?: string;
|
|
212
215
|
command?: string;
|
|
213
216
|
default?: boolean;
|
|
@@ -235,5 +238,4 @@ interface OperationContributionEntry {
|
|
|
235
238
|
/** `false`: the app already has these operations at runtime. Only tools such as the CLI and `vitehub inspect` read the entry. */
|
|
236
239
|
runtime?: false;
|
|
237
240
|
}
|
|
238
|
-
//#endregion
|
|
239
241
|
export { OperationContributionEntry as n, AnyOperation as t };
|
package/dist/operations.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
//#region src/operations.d.ts
|
|
1
|
+
import { t as AnyOperation } from "./operation-definition-CqZkx1Rm.js";
|
|
2
|
+
import { a as BundleExplanation, g as BundleRouteExplanation } from "./types-D4oYDFpA.js";
|
|
4
3
|
/** What `bundle.why` returns. `vitehub bundle why --json` prints the same object. */
|
|
5
4
|
export type BundleWhyResult = BundleRouteExplanation | {
|
|
6
5
|
target: string;
|
|
@@ -10,5 +9,4 @@ export type BundleWhyResult = BundleRouteExplanation | {
|
|
|
10
9
|
explanations: BundleExplanation[];
|
|
11
10
|
};
|
|
12
11
|
/** The `bundle.*` operations. The Console and the ViteHub MCP call them on a dev server. `vitehub bundle` reads the same files. */
|
|
13
|
-
export declare const bundleOperations: readonly AnyOperation[];
|
|
14
|
-
//#endregion
|
|
12
|
+
export declare const bundleOperations: readonly AnyOperation[];
|
package/dist/operations.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { n as isRecordOrFunction } from "./object-
|
|
1
|
+
import { n as isRecordOrFunction } from "./object-CAK6UYR5.js";
|
|
2
2
|
import { defineDiagnostics } from "nostics";
|
|
3
3
|
import { toJsonSchema } from "@valibot/to-json-schema";
|
|
4
4
|
import * as v from "valibot";
|
|
5
|
-
|
|
5
|
+
// ../internal/src/error-diagnostics.ts
|
|
6
6
|
const dynamicError = { why: ({ message }) => message === void 0 ? "" : String(message) };
|
|
7
7
|
const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
8
8
|
docsBase: "https://vitehub.dev/docs/development/diagnostics",
|
|
@@ -28,7 +28,7 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
28
28
|
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
29
29
|
},
|
|
30
30
|
INTERNAL_R0022: {
|
|
31
|
-
fix: "Send input that matches the schema of the operation. `vitehub <namespace> <command> --help` shows the fields.",
|
|
31
|
+
fix: "Send input that matches the schema of the operation. `vitehub <namespace> <command> --help` shows the fields, and the list_operations tool of the ViteHub MCP gives the input schema of each operation.",
|
|
32
32
|
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
33
33
|
},
|
|
34
34
|
INTERNAL_R0024: {
|
|
@@ -247,6 +247,10 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
247
247
|
why: ({ owner }) => `[vitehub] ${owner} extends tuple requires [preset, options] with an options object.`,
|
|
248
248
|
fix: "Set `extends` to a preset, or to a two-item tuple `[preset, { ...options }]` whose second item is a plain object."
|
|
249
249
|
},
|
|
250
|
+
INTERNAL_RUNTIME_PACKAGE_VERSION_CONFLICT: {
|
|
251
|
+
why: ({ first, name, second }) => `[vitehub] One server function needs ${name} from two installations: ${first} and ${second}.`,
|
|
252
|
+
fix: "Install one version of the package that the message names, for example with `pnpm dedupe` or an `overrides` entry in `package.json`, then build again."
|
|
253
|
+
},
|
|
250
254
|
INTERNAL_SECRET_PURPOSE_MISSING: {
|
|
251
255
|
why: "[vitehub] A derived secret requires a purpose.",
|
|
252
256
|
fix: "Pass a non-empty purpose to `deriveSecret()`, such as `deriveSecret(\"my-module:session\")`."
|
|
@@ -255,6 +259,10 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
255
259
|
why: ({ minimum }) => `[vitehub] VITEHUB_SECRET must be at least ${minimum} characters. Generate one with \`openssl rand -base64 32\`.`,
|
|
256
260
|
fix: "Set `VITEHUB_SECRET` to the output of `openssl rand -base64 32`, which has 44 characters."
|
|
257
261
|
},
|
|
262
|
+
INTERNAL_SITE_TOKEN_TOO_LONG: {
|
|
263
|
+
why: ({ length, maximum }) => `The Site access token is ${length} characters, and an app accepts ${maximum}.`,
|
|
264
|
+
fix: "Open the app with a shorter path, or give the person and the project shorter names, so that the Site access token fits."
|
|
265
|
+
},
|
|
258
266
|
INTERNAL_SQLITE_ARGUMENT_INVALID: {
|
|
259
267
|
why: ({ value }) => value === "undefined" ? "undefined cannot be passed as argument to the database" : "Only finite numbers (not Infinity or NaN) can be passed as arguments",
|
|
260
268
|
fix: "Pass query arguments as finite numbers, strings, booleans, bigints, dates, byte arrays, or null. Replace undefined with null, and check numbers with `Number.isFinite()` before the query."
|
|
@@ -269,8 +277,7 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
269
277
|
}
|
|
270
278
|
}
|
|
271
279
|
});
|
|
272
|
-
|
|
273
|
-
//#region ../internal/src/standard-schema.ts
|
|
280
|
+
// ../internal/src/standard-schema.ts
|
|
274
281
|
function readOwn(value, key) {
|
|
275
282
|
if (value === null || Object(value) !== value) return;
|
|
276
283
|
try {
|
|
@@ -299,8 +306,7 @@ function standardJsonSchema(schema, direction, target = "draft-2020-12", library
|
|
|
299
306
|
return;
|
|
300
307
|
}
|
|
301
308
|
}
|
|
302
|
-
|
|
303
|
-
//#region ../internal/src/valibot.ts
|
|
309
|
+
// ../internal/src/valibot.ts
|
|
304
310
|
const valibotTargets = /* @__PURE__ */ new Set([
|
|
305
311
|
"draft-07",
|
|
306
312
|
"draft-2020-12",
|
|
@@ -341,8 +347,7 @@ function withValibotJsonSchema(schema, options = {}) {
|
|
|
341
347
|
}
|
|
342
348
|
};
|
|
343
349
|
}
|
|
344
|
-
|
|
345
|
-
//#region ../internal/src/operation-definition.ts
|
|
350
|
+
// ../internal/src/operation-definition.ts
|
|
346
351
|
const nameFormat = /^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$/;
|
|
347
352
|
const kinds = /* @__PURE__ */ new Set([
|
|
348
353
|
"read",
|
|
@@ -402,9 +407,7 @@ function isSectionId(section) {
|
|
|
402
407
|
function operationInputJsonSchema(operation) {
|
|
403
408
|
return standardJsonSchema(operation.input, "input") ?? { type: "object" };
|
|
404
409
|
}
|
|
405
|
-
|
|
406
|
-
//#region src/operations.ts
|
|
407
|
-
/** Why `bundle.report` and `bundle.why` cannot answer. The checks of a report are in `bundleDiagnostics`. */
|
|
410
|
+
// src/operations.ts
|
|
408
411
|
const bundleOperationDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
409
412
|
docsBase: "https://vitehub.dev/docs/bundle/diagnostics",
|
|
410
413
|
codes: {
|
|
@@ -419,7 +422,6 @@ const bundleOperationDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
419
422
|
}
|
|
420
423
|
});
|
|
421
424
|
const reader = () => import("./index.js");
|
|
422
|
-
/** The environment reports of the project that the dev server runs. A deployed server has no project files. */
|
|
423
425
|
async function reportsOf(context) {
|
|
424
426
|
if (context.development !== true || !context.projectRoot) throw Object.assign(bundleOperationDiagnostics.BUNDLE_DEV_SERVER_REQUIRED(), { status: 409 });
|
|
425
427
|
const reports = (await reader()).readEnvironmentReports(context.projectRoot);
|
|
@@ -472,5 +474,4 @@ const bundleOperations = [defineBundleOperation({
|
|
|
472
474
|
};
|
|
473
475
|
}
|
|
474
476
|
})];
|
|
475
|
-
//#endregion
|
|
476
477
|
export { bundleOperations };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/types.d.ts
|
|
2
1
|
/** What put a module in the output. */
|
|
3
2
|
type BundleGroupKind = "app" | "dependency" | "framework" | "generated" | "vitehub";
|
|
4
3
|
/** One source module in one output chunk. */
|
|
@@ -235,5 +234,4 @@ interface BundleComparison {
|
|
|
235
234
|
client?: BundleSideComparison;
|
|
236
235
|
server?: BundleSideComparison;
|
|
237
236
|
}
|
|
238
|
-
//#endregion
|
|
239
237
|
export { BundleStartupRule as C, BundleSideComparison as S, BundleRouteFile as _, BundleExplanation as a, BundleRouteSource as b, BundleFindingCode as c, BundleGroupKind as d, BundleGroupSize as f, BundleRouteExplanation as g, BundleRoute as h, BundleEnvironmentReport as i, BundleGroup as l, BundleReport as m, BundleChunk as n, BundleFile as o, BundleModule as p, BundleComparison as r, BundleFinding as s, BundleChainStep as t, BundleGroupChange as u, BundleRouteModule as v, BundleTotals as w, BundleSide as x, BundleRouteOptions as y };
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { n as ViteHubCliPluginMetadata } from "./cli-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { n as ViteHubCliPluginMetadata } from "./cli-C5pAfY4x.js";
|
|
2
|
+
import { n as OperationContributionEntry } from "./operation-definition-CqZkx1Rm.js";
|
|
3
|
+
import { C as BundleStartupRule, y as BundleRouteOptions } from "./types-D4oYDFpA.js";
|
|
4
4
|
import { Plugin } from "vite";
|
|
5
|
-
//#region src/routes.d.ts
|
|
6
5
|
/** A page route with the absolute files of the components that render it, outermost first. */
|
|
7
6
|
interface PageRoute {
|
|
8
7
|
path: string;
|
|
@@ -37,12 +36,9 @@ interface NuxtPageLike {
|
|
|
37
36
|
export declare function nuxtPageRoutes(pages: readonly NuxtPageLike[], layouts?: Readonly<Record<string, {
|
|
38
37
|
file: string;
|
|
39
38
|
}>>, layoutComponent?: string): PageRoute[];
|
|
40
|
-
//#endregion
|
|
41
|
-
//#region src/vite.d.ts
|
|
42
39
|
interface BundlerConfig {
|
|
43
40
|
plugins?: unknown;
|
|
44
41
|
}
|
|
45
|
-
/** The parts of a Nitro 3 instance that the server report reads. */
|
|
46
42
|
interface NitroLike {
|
|
47
43
|
hooks: {
|
|
48
44
|
hook: (name: "build:config", callback: (nitro: unknown, config: {
|
|
@@ -83,5 +79,4 @@ export interface BundleViteOptions {
|
|
|
83
79
|
* report for the app. Builds without the plugin write nothing.
|
|
84
80
|
*/
|
|
85
81
|
export declare function hubBundle(options?: BundleViteOptions): BundleVitePlugin;
|
|
86
|
-
//#endregion
|
|
87
82
|
export type { NuxtPageLike, PageRoute };
|
package/dist/vite.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { n as resolveViteHubProjectRoot, t as bundleCliContributor } from "./cli-CfA0FvGh.js";
|
|
2
|
+
import { c as moduleId, h as writeEnvironmentReport, l as allocateBytes, m as writeBundleReportRoot, o as nuxtPageRoutes } from "./compare-3VnwI84U.js";
|
|
3
3
|
import { existsSync } from "node:fs";
|
|
4
4
|
import { dirname, resolve } from "node:path";
|
|
5
5
|
import { defineDiagnostics } from "nostics";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { randomUUID } from "node:crypto";
|
|
8
8
|
import { gzipSync } from "node:zlib";
|
|
9
|
-
|
|
9
|
+
// ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
|
|
10
10
|
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
11
11
|
function normalizeWindowsPath(input = "") {
|
|
12
12
|
if (!input) return input;
|
|
@@ -90,8 +90,7 @@ const dirname$1 = function(p) {
|
|
|
90
90
|
if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) segments[0] += "/";
|
|
91
91
|
return segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
|
92
92
|
};
|
|
93
|
-
|
|
94
|
-
//#region ../internal/src/invariant.ts
|
|
93
|
+
// ../internal/src/invariant.ts
|
|
95
94
|
const invariantDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
96
95
|
docsBase: "https://vitehub.dev/docs/development/diagnostics",
|
|
97
96
|
codes: { INTERNAL_INVARIANT_FAILED: {
|
|
@@ -110,8 +109,7 @@ function invariantError(what) {
|
|
|
110
109
|
function invariant(condition, what) {
|
|
111
110
|
if (!condition) throw invariantError(what);
|
|
112
111
|
}
|
|
113
|
-
|
|
114
|
-
//#region ../internal/src/build/paths.ts
|
|
112
|
+
// ../internal/src/build/paths.ts
|
|
115
113
|
function resolveRuntimeModule(packageDir, modulePath) {
|
|
116
114
|
const distFile = resolve$1(packageDir, "dist", `${modulePath}.js`);
|
|
117
115
|
return existsSync(distFile) ? distFile : resolve$1(packageDir, "src", `${modulePath}.ts`);
|
|
@@ -138,8 +136,7 @@ function findPackageDir(file) {
|
|
|
138
136
|
function ownModule(importMetaUrl, modulePath) {
|
|
139
137
|
return resolveRuntimeModule(findPackageDir(fileURLToPath(importMetaUrl)), modulePath);
|
|
140
138
|
}
|
|
141
|
-
|
|
142
|
-
//#region src/collect.ts
|
|
139
|
+
// src/collect.ts
|
|
143
140
|
function isChunk(output) {
|
|
144
141
|
return typeof output === "object" && output !== null && Reflect.get(output, "type") === "chunk";
|
|
145
142
|
}
|
|
@@ -161,11 +158,6 @@ function relativeTo(root, path) {
|
|
|
161
158
|
const normalized = path.replace(/\\/g, "/");
|
|
162
159
|
return normalized === base ? "." : normalized.startsWith(`${base}/`) ? normalized.slice(base.length + 1) : normalized;
|
|
163
160
|
}
|
|
164
|
-
/**
|
|
165
|
-
* Reads the imports of a module as report ids. The bundler drops modules that leave no code, such as a package index
|
|
166
|
-
* that only re-exports, so an import of such a module continues to the modules that it imports. An edge is dynamic
|
|
167
|
-
* when one step on the way is `import()`.
|
|
168
|
-
*/
|
|
169
161
|
function createEdgeReader(ids, getModuleInfo) {
|
|
170
162
|
const through = /* @__PURE__ */ new Map();
|
|
171
163
|
const visit = (raw, visiting) => {
|
|
@@ -198,18 +190,21 @@ function createEdgeReader(ids, getModuleInfo) {
|
|
|
198
190
|
};
|
|
199
191
|
return (raw) => visit(raw, /* @__PURE__ */ new Set());
|
|
200
192
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
const chunks = Object.values(bundle).filter(isChunk);
|
|
204
|
-
const byFile = new Map(chunks.map((chunk) => [chunk.fileName, chunk]));
|
|
205
|
-
const startup = /* @__PURE__ */ new Set();
|
|
206
|
-
const pending = chunks.filter((chunk) => chunk.isEntry).map((chunk) => chunk.fileName);
|
|
193
|
+
function staticChunkFiles(byFile, pending) {
|
|
194
|
+
const loaded = /* @__PURE__ */ new Set();
|
|
207
195
|
while (pending.length) {
|
|
208
196
|
const file = pending.pop();
|
|
209
|
-
if (
|
|
210
|
-
|
|
197
|
+
if (loaded.has(file)) continue;
|
|
198
|
+
loaded.add(file);
|
|
211
199
|
pending.push(...byFile.get(file)?.imports ?? []);
|
|
212
200
|
}
|
|
201
|
+
return loaded;
|
|
202
|
+
}
|
|
203
|
+
/** Reads one build's output: the bytes of each chunk, the share of each module, and the startup files. */
|
|
204
|
+
function collectEnvironmentReport(bundle, options) {
|
|
205
|
+
const chunks = Object.values(bundle).filter(isChunk);
|
|
206
|
+
const byFile = new Map(chunks.map((chunk) => [chunk.fileName, chunk]));
|
|
207
|
+
const startup = staticChunkFiles(byFile, chunks.filter((chunk) => chunk.isEntry).map((chunk) => chunk.fileName));
|
|
213
208
|
const ids = /* @__PURE__ */ new Map();
|
|
214
209
|
const packages = /* @__PURE__ */ new Map();
|
|
215
210
|
const isEntry = (id, chunk) => options.getModuleInfo(id)?.isEntry ?? chunk.facadeModuleId === id;
|
|
@@ -266,14 +261,8 @@ function collectEnvironmentReport(bundle, options) {
|
|
|
266
261
|
const layout = route.layout;
|
|
267
262
|
if (layout) {
|
|
268
263
|
const pages = new Set(files.filter((file) => file !== layout.file).map((file) => moduleId(file, options.root, packages)));
|
|
269
|
-
const
|
|
270
|
-
const
|
|
271
|
-
while (pending.length) {
|
|
272
|
-
const chunk = pending.pop();
|
|
273
|
-
if (loaded.has(chunk.file)) continue;
|
|
274
|
-
loaded.add(chunk.file);
|
|
275
|
-
pending.push(...rows.filter((candidate) => chunk.imports?.includes(candidate.file)));
|
|
276
|
-
}
|
|
264
|
+
const roots = rows.filter((chunk) => chunk.startup || chunk.modules.some((module) => pages.has(module.id)));
|
|
265
|
+
const loaded = staticChunkFiles(byFile, roots.map((chunk) => chunk.file));
|
|
277
266
|
const renderer = moduleId(layout.component, options.root, packages);
|
|
278
267
|
if (!rows.some((chunk) => loaded.has(chunk.file) && chunk.modules.some((module) => module.id === renderer))) files = files.filter((file) => file !== layout.file);
|
|
279
268
|
}
|
|
@@ -294,10 +283,8 @@ function collectEnvironmentReport(bundle, options) {
|
|
|
294
283
|
...client && routeOptions ? { routeOptions } : {}
|
|
295
284
|
};
|
|
296
285
|
}
|
|
297
|
-
|
|
298
|
-
//#region src/vite.ts
|
|
286
|
+
// src/vite.ts
|
|
299
287
|
const outputsKey = Symbol.for("vitehub.bundle.outputs");
|
|
300
|
-
/** Vite and Nitro can observe the same output; only that output object is deduplicated. */
|
|
301
288
|
function writtenOutputs() {
|
|
302
289
|
const outputs = Reflect.get(globalThis, outputsKey) ?? /* @__PURE__ */ new WeakMap();
|
|
303
290
|
Reflect.set(globalThis, outputsKey, outputs);
|
|
@@ -306,7 +293,6 @@ function writtenOutputs() {
|
|
|
306
293
|
function newBuildId() {
|
|
307
294
|
return `${(/* @__PURE__ */ new Date()).toISOString()}-${randomUUID()}`;
|
|
308
295
|
}
|
|
309
|
-
/** Asks the features of the build for their rules. Each feature adds them to `rules` in its `vitehub:bundle:rules` hook. */
|
|
310
296
|
async function serverFacts(nitro) {
|
|
311
297
|
const rules = [];
|
|
312
298
|
if (!nitro) return { rules };
|
|
@@ -343,7 +329,6 @@ function writeReport(context, bundle, options, facts) {
|
|
|
343
329
|
written.add(key);
|
|
344
330
|
outputs.set(bundle, written);
|
|
345
331
|
}
|
|
346
|
-
/** Adds a Rolldown plugin to a Nitro build that bundles on its own, such as the server build of Nuxt 5. */
|
|
347
332
|
function bundleNitroModule(buildId, onSetup) {
|
|
348
333
|
return {
|
|
349
334
|
name: "@vite-hub/bundle/nitro",
|
|
@@ -433,5 +418,4 @@ function hubBundle(options = {}) {
|
|
|
433
418
|
}
|
|
434
419
|
};
|
|
435
420
|
}
|
|
436
|
-
//#endregion
|
|
437
421
|
export { hubBundle, nuxtPageRoutes };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vite-hub/bundle",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Bundle reports for ViteHub apps: client and server size, startup cost, and why each package is in the output.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bundle",
|
|
@@ -49,16 +49,16 @@
|
|
|
49
49
|
"@valibot/to-json-schema": "^1.8.0",
|
|
50
50
|
"nostics": "1.4.0",
|
|
51
51
|
"valibot": "^1.5.0",
|
|
52
|
-
"vue-router": "^5.
|
|
52
|
+
"vue-router": "^5.5.1"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@types/node": "^24.19.
|
|
55
|
+
"@types/node": "^24.19.2",
|
|
56
56
|
"@vite-hub/internal": "0.0.1",
|
|
57
57
|
"publint": "^0.3.25",
|
|
58
58
|
"typescript": "^6.0.3",
|
|
59
|
-
"vite": "^8.
|
|
60
|
-
"vite-plus": "^
|
|
61
|
-
"vitest": "
|
|
59
|
+
"vite": "^8.3.8",
|
|
60
|
+
"vite-plus": "^1.7.0",
|
|
61
|
+
"vitest": "5.1.0"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"vite": ">=8.0.0"
|