vike-lite 1.18.1 → 1.18.2

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.
Files changed (2) hide show
  1. package/dist/vite.mjs +16 -7
  2. package/package.json +1 -1
package/dist/vite.mjs CHANGED
@@ -144,6 +144,7 @@ function vikeLite({ pagesDir = "pages", apiPrefix = "/api", prerender = false, s
144
144
  let hasAnyPrerender;
145
145
  let baseUrl;
146
146
  let projectDependencies = null;
147
+ const bundleReports = {};
147
148
  const VIRTUAL = {
148
149
  routes: "virtual:vike-lite/routes",
149
150
  manifest: "virtual:vike-lite/client-manifest",
@@ -370,10 +371,10 @@ function vikeLite({ pagesDir = "pages", apiPrefix = "/api", prerender = false, s
370
371
  for (const id of chunk.moduleIds) recordUsage(extractPkgName(id), { isBundled: true });
371
372
  }
372
373
  for (const id of this.getModuleIds()) if (this.getModuleInfo(id)?.code === null) recordUsage(extractPkgName(id), { isExternal: true });
373
- const sorted = [...usedDeps.entries()].sort(([a], [b]) => a.localeCompare(b));
374
374
  const envName = this.environment.name;
375
- const label = envName === "client" ? "Client" : "Server";
376
- console.log(`\nšŸ“¦ [${label} bundle] ${sorted.length} dependencies used from package.json:`);
375
+ bundleReports[envName] = usedDeps;
376
+ const sorted = [...usedDeps.entries()].sort(([a], [b]) => a.localeCompare(b));
377
+ console.log(`\nšŸ“¦ [${envName === "client" ? "Client" : "Server"} bundle] ${sorted.length} dependencies used from package.json:`);
377
378
  if (sorted.length === 0) console.log(" (None)");
378
379
  else for (const [name, info] of sorted) {
379
380
  const typeTag = info.type ? ` \u{1B}[33m[${info.type}]\u{1B}[0m` : "";
@@ -382,12 +383,20 @@ function vikeLite({ pagesDir = "pages", apiPrefix = "/api", prerender = false, s
382
383
  }
383
384
  const suggestions = [];
384
385
  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.`);
385
- else if (info.isBundled && !info.isExternal && info.type === "") {
386
- const otherEnv = envName === "client" ? "server" : "client";
387
- 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.`);
386
+ if (envName === "ssr") {
387
+ const clientDeps = bundleReports.client;
388
+ const allNames = /* @__PURE__ */ new Set([...clientDeps?.keys() ?? [], ...usedDeps.keys()]);
389
+ for (const name of allNames) {
390
+ const meta = deps[name];
391
+ if (!meta || meta.type !== "") continue;
392
+ const c = clientDeps?.get(name);
393
+ const s = usedDeps.get(name);
394
+ const externalAnywhere = c?.isExternal || s?.isExternal;
395
+ if ((c || s) && !externalAnywhere) suggestions.push(`\u{1B}[34mšŸ’” ${name}\u{1B}[0m is fully bundled (or unused) in both client and server — never externalized. Safe to move to \u{1B}[33mdevDependencies\u{1B}[0m.`);
396
+ }
388
397
  }
389
398
  if (suggestions.length > 0) {
390
- console.log(`\n \u{1B}[1m${label} Suggestions:\u{1B}[0m`);
399
+ console.log(`\n \u{1B}[1mSuggestions:\u{1B}[0m`);
391
400
  for (const s of suggestions) console.log(` ${s}`);
392
401
  }
393
402
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike-lite",
3
- "version": "1.18.1",
3
+ "version": "1.18.2",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",