vike-lite 1.17.3 ā 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 +12 -29
- 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
|
@@ -143,8 +143,6 @@ function vikeLite({ pagesDir = "pages", apiPrefix = "/api", prerender = false, s
|
|
|
143
143
|
let hasAnyPrerender;
|
|
144
144
|
let baseUrl;
|
|
145
145
|
let projectDependencies = null;
|
|
146
|
-
const depUsage = /* @__PURE__ */ new Map();
|
|
147
|
-
const processedEnvs = /* @__PURE__ */ new Set();
|
|
148
146
|
const VIRTUAL = {
|
|
149
147
|
routes: "virtual:vike-lite/routes",
|
|
150
148
|
manifest: "virtual:vike-lite/client-manifest",
|
|
@@ -347,8 +345,6 @@ function vikeLite({ pagesDir = "pages", apiPrefix = "/api", prerender = false, s
|
|
|
347
345
|
},
|
|
348
346
|
generateBundle(_options, bundle) {
|
|
349
347
|
if (!printDependencies || !projectDependencies) return;
|
|
350
|
-
const envName = this.environment.name;
|
|
351
|
-
if (envName !== "client" && envName !== "ssr") return;
|
|
352
348
|
const usedDeps = /* @__PURE__ */ new Map();
|
|
353
349
|
for (const chunk of Object.values(bundle)) {
|
|
354
350
|
if (chunk.type !== "chunk") continue;
|
|
@@ -378,38 +374,25 @@ function vikeLite({ pagesDir = "pages", apiPrefix = "/api", prerender = false, s
|
|
|
378
374
|
}
|
|
379
375
|
}
|
|
380
376
|
}
|
|
381
|
-
for (const [name, info] of usedDeps) {
|
|
382
|
-
const global = depUsage.get(name) ?? {
|
|
383
|
-
version: info.version,
|
|
384
|
-
type: info.type,
|
|
385
|
-
isBundled: false,
|
|
386
|
-
isExternal: false,
|
|
387
|
-
externalEnvs: /* @__PURE__ */ new Set()
|
|
388
|
-
};
|
|
389
|
-
global.isBundled ||= info.isBundled;
|
|
390
|
-
global.isExternal ||= info.isExternal;
|
|
391
|
-
if (info.isExternal) global.externalEnvs.add(envName);
|
|
392
|
-
depUsage.set(name, global);
|
|
393
|
-
}
|
|
394
|
-
processedEnvs.add(envName);
|
|
395
377
|
const sorted = [...usedDeps.entries()].sort(([a], [b]) => a.localeCompare(b));
|
|
396
|
-
|
|
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:`);
|
|
397
381
|
if (sorted.length === 0) console.log(" (None)");
|
|
398
382
|
else for (const [name, info] of sorted) {
|
|
399
383
|
const typeTag = info.type ? ` \u{1B}[33m[${info.type}]\u{1B}[0m` : "";
|
|
400
384
|
const usageTag = info.isExternal ? " \x1B[90m(external)\x1B[0m" : " \x1B[90m(bundled)\x1B[0m";
|
|
401
385
|
console.log(` - \u{1B}[36m${name}@${info.version}\u{1B}[0m${typeTag}${usageTag}`);
|
|
402
386
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
}
|
|
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}`);
|
|
413
396
|
}
|
|
414
397
|
},
|
|
415
398
|
closeBundle: {
|