vike-lite 1.17.2 ā 1.17.4
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/README.md +20 -6
- package/dist/vite.mjs +34 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -39,18 +39,32 @@ export default {
|
|
|
39
39
|
|
|
40
40
|
#### printDependencies
|
|
41
41
|
|
|
42
|
-
When set to `true`, at the end of each production build (client and server) the plugin prints the list of `package.json` dependencies (and devDependencies) that were actually bundled or externally imported in that specific build output.
|
|
42
|
+
When set to `true`, at the end of each production build (client and server), the plugin prints the list of `package.json` dependencies (and devDependencies) that were actually bundled or externally imported in that specific build output.
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
More importantly, it cross-references this usage with your `package.json` to provide **smart suggestions** to prevent production crashes and optimize your deployment size.
|
|
45
45
|
|
|
46
|
+
```sh
|
|
46
47
|
š¦ [Client bundle] 1 dependencies used from package.json:
|
|
47
|
-
- solid-js@^1.9.3
|
|
48
|
+
- solid-js@^1.9.3 (bundled)
|
|
49
|
+
|
|
50
|
+
š¦ [Server bundle] 3 dependencies used from package.json:
|
|
51
|
+
- solid-js@^1.9.3 (bundled)
|
|
52
|
+
- hono@^4.12.31 (external)
|
|
53
|
+
- postgres@^3.4.4 [dev] (external)
|
|
48
54
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
-
|
|
55
|
+
Suggestions:
|
|
56
|
+
šØ postgres is externalized in the server bundle but listed as a devDependency. Move it to dependencies or it will break in production.
|
|
57
|
+
š” solid-js is always fully bundled (never externalized). Consider moving it to devDependencies to reduce production node_modules size.
|
|
58
|
+
šļø lodash@4.17.21 is listed in "dependencies" but wasn't found in any bundle ā if it's only needed at build/dev time, move it to devDependencies (or remove it if unused).
|
|
52
59
|
```
|
|
53
60
|
|
|
61
|
+
##### What it catches:
|
|
62
|
+
- šØ **Production Crashes:** Flags devDependencies that are externalized by the server (if left as dev dependencies, your app will crash in production environments that use `npm ci --omit=dev`).
|
|
63
|
+
- š” **Server Bloat:** Flags regular dependencies that are 100% bundled into the build. Moving these to `devDependencies` shrinks your production node_modules size.
|
|
64
|
+
- šļø **Unused Packages**: Highlights dependencies taking up space in your `package.json` that never appeared in the final build graph.
|
|
65
|
+
|
|
66
|
+
It's disabled by default since it adds diagnostic console output and isn't needed for normal usage, but it is highly recommended to run occasionally to audit your packages.
|
|
67
|
+
|
|
54
68
|
It's disabled by default since it only adds diagnostic console output and isn't needed for normal usage.
|
|
55
69
|
|
|
56
70
|
### š„ļø Server Integration
|
package/dist/vite.mjs
CHANGED
|
@@ -345,26 +345,54 @@ function vikeLite({ pagesDir = "pages", apiPrefix = "/api", prerender = false, s
|
|
|
345
345
|
},
|
|
346
346
|
generateBundle(_options, bundle) {
|
|
347
347
|
if (!printDependencies || !projectDependencies) return;
|
|
348
|
-
const envName = this.environment.name;
|
|
349
|
-
if (envName !== "client" && envName !== "ssr") return;
|
|
350
348
|
const usedDeps = /* @__PURE__ */ new Map();
|
|
351
349
|
for (const chunk of Object.values(bundle)) {
|
|
352
350
|
if (chunk.type !== "chunk") continue;
|
|
353
351
|
for (const id of chunk.moduleIds) {
|
|
354
352
|
const pkg = extractPkgName(id);
|
|
355
|
-
if (pkg && !pkg.startsWith("vike-lite") && Object.hasOwn(projectDependencies, pkg))
|
|
353
|
+
if (pkg && !pkg.startsWith("vike-lite") && Object.hasOwn(projectDependencies, pkg)) {
|
|
354
|
+
const entry = usedDeps.get(pkg) ?? {
|
|
355
|
+
...projectDependencies[pkg],
|
|
356
|
+
isBundled: false,
|
|
357
|
+
isExternal: false
|
|
358
|
+
};
|
|
359
|
+
entry.isBundled = true;
|
|
360
|
+
usedDeps.set(pkg, entry);
|
|
361
|
+
}
|
|
356
362
|
}
|
|
357
363
|
for (const imp of [...chunk.imports, ...chunk.dynamicImports]) {
|
|
364
|
+
if (bundle[imp]) continue;
|
|
358
365
|
const pkg = extractPkgName(imp);
|
|
359
|
-
if (pkg && !pkg.startsWith("vike-lite") && Object.hasOwn(projectDependencies, pkg))
|
|
366
|
+
if (pkg && !pkg.startsWith("vike-lite") && Object.hasOwn(projectDependencies, pkg)) {
|
|
367
|
+
const entry = usedDeps.get(pkg) ?? {
|
|
368
|
+
...projectDependencies[pkg],
|
|
369
|
+
isBundled: false,
|
|
370
|
+
isExternal: false
|
|
371
|
+
};
|
|
372
|
+
entry.isExternal = true;
|
|
373
|
+
usedDeps.set(pkg, entry);
|
|
374
|
+
}
|
|
360
375
|
}
|
|
361
376
|
}
|
|
362
377
|
const sorted = [...usedDeps.entries()].sort(([a], [b]) => a.localeCompare(b));
|
|
363
|
-
|
|
378
|
+
const envName = this.environment.name;
|
|
379
|
+
const label = envName === "client" ? "Client" : "Server";
|
|
380
|
+
console.log(`\nš¦ [${label} bundle] ${sorted.length} dependencies used from package.json:`);
|
|
364
381
|
if (sorted.length === 0) console.log(" (None)");
|
|
365
382
|
else for (const [name, info] of sorted) {
|
|
366
383
|
const typeTag = info.type ? ` \u{1B}[33m[${info.type}]\u{1B}[0m` : "";
|
|
367
|
-
|
|
384
|
+
const usageTag = info.isExternal ? " \x1B[90m(external)\x1B[0m" : " \x1B[90m(bundled)\x1B[0m";
|
|
385
|
+
console.log(` - \u{1B}[36m${name}@${info.version}\u{1B}[0m${typeTag}${usageTag}`);
|
|
386
|
+
}
|
|
387
|
+
const suggestions = [];
|
|
388
|
+
for (const [name, info] of sorted) if (envName === "ssr" && info.isExternal && info.type === "dev") suggestions.push(`\u{1B}[31mšØ ${name}\u{1B}[0m is externalized by the server but listed as a \u{1B}[33mdevDependency\u{1B}[0m. Move it to \u{1B}[32mdependencies\u{1B}[0m to prevent production crashes.`);
|
|
389
|
+
else if (info.isBundled && !info.isExternal && info.type === "") {
|
|
390
|
+
const otherEnv = envName === "client" ? "server" : "client";
|
|
391
|
+
suggestions.push(`\u{1B}[34mš” ${name}\u{1B}[0m is fully bundled here. If it's also bundled (or unused) in the ${otherEnv}, consider moving it to \u{1B}[33mdevDependencies\u{1B}[0m.`);
|
|
392
|
+
}
|
|
393
|
+
if (suggestions.length > 0) {
|
|
394
|
+
console.log(`\n \u{1B}[1m${label} Suggestions:\u{1B}[0m`);
|
|
395
|
+
for (const s of suggestions) console.log(` ${s}`);
|
|
368
396
|
}
|
|
369
397
|
},
|
|
370
398
|
closeBundle: {
|