@vesk/vesk-cli 0.2.61 → 0.2.63

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/cli.js +319 -38
  2. package/package.json +5 -5
package/dist/cli.js CHANGED
@@ -30533,6 +30533,53 @@ function transformTrackedInit(init, tracked2) {
30533
30533
  if (!expr) return init;
30534
30534
  return transformTracked({ raw: init, ast: expr }, tracked2);
30535
30535
  }
30536
+ function runtimeDeclaredNames(node) {
30537
+ if (!(node instanceof RuntimeStatement)) return [];
30538
+ const stmt = node.ast;
30539
+ if (!stmt || stmt.type !== "VariableDeclaration" || !stmt.declarations) return [];
30540
+ const out = [];
30541
+ for (const d of stmt.declarations) {
30542
+ if (d.id && d.id.type === "Identifier" && typeof d.id.name === "string") out.push(d.id.name);
30543
+ }
30544
+ return out;
30545
+ }
30546
+ function initReadsAnyOf(init, names) {
30547
+ if (!init || names.size === 0) return false;
30548
+ let expr = null;
30549
+ try {
30550
+ const prog = parse4(`(${init})`);
30551
+ expr = prog.body?.[0]?.type === "ExpressionStatement" ? prog.body[0].expression ?? null : null;
30552
+ } catch {
30553
+ return false;
30554
+ }
30555
+ if (!expr) return false;
30556
+ let found = false;
30557
+ const walk9 = (n) => {
30558
+ if (found || !n || typeof n !== "object") return;
30559
+ if (Array.isArray(n)) {
30560
+ for (const c of n) walk9(c);
30561
+ return;
30562
+ }
30563
+ const t = n.type;
30564
+ if (typeof t !== "string") return;
30565
+ if (t === "Identifier") {
30566
+ if (names.has(n.name)) found = true;
30567
+ return;
30568
+ }
30569
+ if (t === "MemberExpression") {
30570
+ const m = n;
30571
+ walk9(m.object);
30572
+ if (m.computed) walk9(m.property);
30573
+ return;
30574
+ }
30575
+ for (const key of Object.keys(n)) {
30576
+ if (key === "loc" || key === "range" || key === "start" || key === "end") continue;
30577
+ walk9(n[key]);
30578
+ }
30579
+ };
30580
+ walk9(expr);
30581
+ return found;
30582
+ }
30536
30583
  function indent2(code, level = 1) {
30537
30584
  const pad = " ".repeat(level);
30538
30585
  return code.split("\n").map((l) => l ? pad + l : "").join("\n");
@@ -31918,8 +31965,19 @@ function generateComponent(comp, importedNames = /* @__PURE__ */ new Set(), hydr
31918
31965
  ctx2.push(indent2(`let __pendingChild = null;`));
31919
31966
  const paramInit = buildParamInit2(comp.paramNames, comp.propsAlias);
31920
31967
  if (paramInit) ctx2.push(indent2(paramInit));
31968
+ const deferredTrackDecls = /* @__PURE__ */ new Set();
31969
+ {
31970
+ const declaredSoFar = /* @__PURE__ */ new Set();
31971
+ for (const node of comp.body) {
31972
+ if (node instanceof TrackDecl) {
31973
+ if (initReadsAnyOf(node.init, declaredSoFar)) deferredTrackDecls.add(node);
31974
+ continue;
31975
+ }
31976
+ for (const name of runtimeDeclaredNames(node)) declaredSoFar.add(name);
31977
+ }
31978
+ }
31921
31979
  for (const node of comp.body) {
31922
- if (node instanceof TrackDecl) {
31980
+ if (node instanceof TrackDecl && !deferredTrackDecls.has(node)) {
31923
31981
  emitNode(ctx2, node, tracked2, null);
31924
31982
  }
31925
31983
  }
@@ -31946,7 +32004,10 @@ function generateComponent(comp, importedNames = /* @__PURE__ */ new Set(), hydr
31946
32004
  }
31947
32005
  }
31948
32006
  for (const node of comp.body) {
31949
- if (node instanceof TrackDecl) continue;
32007
+ if (node instanceof TrackDecl) {
32008
+ if (deferredTrackDecls.has(node)) emitNode(ctx2, node, tracked2, null);
32009
+ continue;
32010
+ }
31950
32011
  const v = emitNode(ctx2, node, tracked2, null, void 0, "__components", topPendingSkip, topBudget || void 0);
31951
32012
  if (v) {
31952
32013
  if (ctx2.hydrate) {
@@ -49861,6 +49922,30 @@ init_vsk_collision();
49861
49922
  init_vsk_imports();
49862
49923
  init_md_inline();
49863
49924
  init_module_imports();
49925
+ import { availableParallelism } from "node:os";
49926
+ async function mapWithConcurrency(items, limit, fn) {
49927
+ const out = new Array(items.length);
49928
+ let next = 0;
49929
+ let firstError = null;
49930
+ const worker = async () => {
49931
+ for (; ; ) {
49932
+ const i = next++;
49933
+ if (i >= items.length) return;
49934
+ if (firstError !== null) return;
49935
+ try {
49936
+ out[i] = await fn(items[i], i);
49937
+ } catch (e) {
49938
+ if (firstError === null) firstError = e;
49939
+ return;
49940
+ }
49941
+ }
49942
+ };
49943
+ const workers = [];
49944
+ for (let i = 0; i < Math.min(limit, items.length); i++) workers.push(worker());
49945
+ await Promise.all(workers);
49946
+ if (firstError !== null) throw firstError;
49947
+ return out;
49948
+ }
49864
49949
  var __dirname3 = dirname8(fileURLToPath2(import.meta.url));
49865
49950
  function fileUnchanged(filePath, cached) {
49866
49951
  try {
@@ -50279,6 +50364,13 @@ function removeCompiledNodes(code, isTarget) {
50279
50364
  }
50280
50365
  return code;
50281
50366
  }
50367
+ var SHARED_CHUNK_NAME = "shared.js";
50368
+ function buildChunkName(appDir, node) {
50369
+ const dir = relative2(appDir, node.sourceDir || "");
50370
+ const parts = dir.split(sep).filter(Boolean);
50371
+ const slug = parts.length > 0 ? parts.join("-") : "index";
50372
+ return slug.replace(/[\[\]]/g, "_");
50373
+ }
50282
50374
  async function generateClientBundle(routeTree, appDir, componentMap, options) {
50283
50375
  const runtimeDir = findRuntimeSrc2(appDir);
50284
50376
  let seen = /* @__PURE__ */ new Set();
@@ -50287,6 +50379,7 @@ async function generateClientBundle(routeTree, appDir, componentMap, options) {
50287
50379
  const runtimeImportNames = /* @__PURE__ */ new Set();
50288
50380
  const cache2 = options?.cache;
50289
50381
  const only = options?.only && options.only.length > 0 ? new Set(options.only) : null;
50382
+ const onlyRoutes = options?.onlyRoutes && options.onlyRoutes.length > 0 ? new Set(options.onlyRoutes) : null;
50290
50383
  const returnEdited = !!options?.returnEditedSources && !!only;
50291
50384
  const editedSources = returnEdited ? /* @__PURE__ */ new Map() : void 0;
50292
50385
  const editedNames = returnEdited ? /* @__PURE__ */ new Map() : void 0;
@@ -50420,12 +50513,6 @@ async function generateClientBundle(routeTree, appDir, componentMap, options) {
50420
50513
  });
50421
50514
  }
50422
50515
  }
50423
- function buildChunkName(node) {
50424
- const dir = relative2(appDir, node.sourceDir || "");
50425
- const parts = dir.split(sep).filter(Boolean);
50426
- const slug = parts.length > 0 ? parts.join("-") : "index";
50427
- return slug.replace(/[\[\]]/g, "_");
50428
- }
50429
50516
  const codeSplit = !!options?.codeSplit;
50430
50517
  const transformPlugins = options?.plugins || [];
50431
50518
  const componentOwners = new VskComponentOwners();
@@ -50475,21 +50562,25 @@ async function generateClientBundle(routeTree, appDir, componentMap, options) {
50475
50562
  compileFile2(loadingPath, node.loading, chunkCode, chunkImports);
50476
50563
  }
50477
50564
  if (chunkCode.length > 0) {
50478
- const chunkName = `page-${buildChunkName(node)}.js`;
50479
- if (!chunkImports.ok) console.error("[vesk] chunk import merge aborted for", chunkName + ":", chunkImports.reason);
50480
- const head = chunkImports.render();
50481
- const code = (head ? head + "\n\n" : "") + chunkCode.join("\n\n");
50482
- chunkEntries.push({ name: chunkName, code, node, importsTable: chunkImports, imports: chunkHasImports(head.length, !chunkImports.ok) });
50565
+ const chunkName = `page-${buildChunkName(appDir, node)}.js`;
50566
+ if (!onlyRoutes || onlyRoutes.has(node.fullPath)) {
50567
+ if (!chunkImports.ok) console.error("[vesk] chunk import merge aborted for", chunkName + ":", chunkImports.reason);
50568
+ const head = chunkImports.render();
50569
+ const code = (head ? head + "\n\n" : "") + chunkCode.join("\n\n");
50570
+ chunkEntries.push({ name: chunkName, code, node, importsTable: chunkImports, imports: chunkHasImports(head.length, !chunkImports.ok) });
50571
+ }
50483
50572
  }
50484
50573
  walkSplit2(node.children || [], [..._chain, node]);
50485
50574
  }
50486
50575
  }, annotate2 = function(nodes) {
50487
50576
  for (const node of nodes) {
50488
- const chunkName = `page-${buildChunkName(node)}.js`;
50577
+ const chunkName = `page-${buildChunkName(appDir, node)}.js`;
50489
50578
  const emitted = chunks.find((c) => c.name === chunkName && c.code.trim());
50490
50579
  if (emitted) {
50491
50580
  const fileName = options?.hmr ? chunkName : hashedName(chunkName, emitted.code);
50492
50581
  node.chunk = `/_vesk/static/${fileName}`;
50582
+ } else if (options?.skipRouteChunks) {
50583
+ node.chunk = `/_vesk/static/${chunkName}`;
50493
50584
  }
50494
50585
  annotate2(node.children || []);
50495
50586
  }
@@ -50508,7 +50599,7 @@ async function generateClientBundle(routeTree, appDir, componentMap, options) {
50508
50599
  if (!sharedImports.ok) console.error("[vesk] chunk import merge aborted for shared.js:", sharedImports.reason);
50509
50600
  const head = sharedImports.render();
50510
50601
  const code = (head ? head + "\n\n" : "") + sharedCode.join("\n\n");
50511
- chunkEntries.push({ name: "shared.js", code, node: null, importsTable: sharedImports, imports: chunkHasImports(head.length, !sharedImports.ok) });
50602
+ chunkEntries.push({ name: SHARED_CHUNK_NAME, code, node: null, importsTable: sharedImports, imports: chunkHasImports(head.length, !sharedImports.ok) });
50512
50603
  }
50513
50604
  const chunkIIFE = (body) => `(()=>{
50514
50605
  const __components = globalThis.__components || (globalThis.__components = {});
@@ -50608,8 +50699,8 @@ ${body}
50608
50699
  });
50609
50700
  }
50610
50701
  } : null;
50611
- for (const entry of chunkEntries) {
50612
- if (!entry.code.trim()) continue;
50702
+ const buildChunkEntry = async (entry) => {
50703
+ if (!entry.code.trim()) return null;
50613
50704
  let finalCode;
50614
50705
  if (entry.imports) {
50615
50706
  const tmpBase = mkdtempSync(join7(resolve10(appDir, ".."), "tmp-vesk-chunk-"));
@@ -50667,7 +50758,13 @@ ${entry.code}
50667
50758
  } else {
50668
50759
  finalCode = chunkIIFE(demoteExports(entry.code));
50669
50760
  }
50670
- chunks.push({ name: entry.name, code: finalCode });
50761
+ return { name: entry.name, code: finalCode };
50762
+ };
50763
+ const effectiveChunkEntries = options?.skipRouteChunks ? chunkEntries.filter((e) => e.name === SHARED_CHUNK_NAME) : chunkEntries;
50764
+ const CHUNK_CONCURRENCY = Math.max(1, Math.min(6, (availableParallelism?.() ?? 4) - 1));
50765
+ const built = await mapWithConcurrency(effectiveChunkEntries, CHUNK_CONCURRENCY, buildChunkEntry);
50766
+ for (const c of built) {
50767
+ if (c !== null) chunks.push(c);
50671
50768
  }
50672
50769
  annotate2(routeTree);
50673
50770
  sharedModuleBundle = sharedBundleCode;
@@ -52738,6 +52835,64 @@ function transformTrackedInit2(init, tracked2) {
52738
52835
  return init;
52739
52836
  return transformTracked2({ raw: init, ast: expr }, tracked2);
52740
52837
  }
52838
+ function runtimeDeclaredNames2(node) {
52839
+ if (!(node instanceof RuntimeStatement))
52840
+ return [];
52841
+ const stmt = node.ast;
52842
+ if (!stmt || stmt.type !== "VariableDeclaration" || !stmt.declarations)
52843
+ return [];
52844
+ const out = [];
52845
+ for (const d of stmt.declarations) {
52846
+ if (d.id && d.id.type === "Identifier" && typeof d.id.name === "string")
52847
+ out.push(d.id.name);
52848
+ }
52849
+ return out;
52850
+ }
52851
+ function initReadsAnyOf2(init, names) {
52852
+ if (!init || names.size === 0)
52853
+ return false;
52854
+ let expr = null;
52855
+ try {
52856
+ const prog = parse4(`(${init})`);
52857
+ expr = prog.body?.[0]?.type === "ExpressionStatement" ? prog.body[0].expression ?? null : null;
52858
+ } catch {
52859
+ return false;
52860
+ }
52861
+ if (!expr)
52862
+ return false;
52863
+ let found = false;
52864
+ const walk9 = (n) => {
52865
+ if (found || !n || typeof n !== "object")
52866
+ return;
52867
+ if (Array.isArray(n)) {
52868
+ for (const c of n)
52869
+ walk9(c);
52870
+ return;
52871
+ }
52872
+ const t = n.type;
52873
+ if (typeof t !== "string")
52874
+ return;
52875
+ if (t === "Identifier") {
52876
+ if (names.has(n.name))
52877
+ found = true;
52878
+ return;
52879
+ }
52880
+ if (t === "MemberExpression") {
52881
+ const m = n;
52882
+ walk9(m.object);
52883
+ if (m.computed)
52884
+ walk9(m.property);
52885
+ return;
52886
+ }
52887
+ for (const key of Object.keys(n)) {
52888
+ if (key === "loc" || key === "range" || key === "start" || key === "end")
52889
+ continue;
52890
+ walk9(n[key]);
52891
+ }
52892
+ };
52893
+ walk9(expr);
52894
+ return found;
52895
+ }
52741
52896
  var NON_BUBBLING_EVENTS2 = /* @__PURE__ */ new Set([
52742
52897
  "focus",
52743
52898
  "blur",
@@ -54415,8 +54570,21 @@ function generateComponent2(comp, importedNames = /* @__PURE__ */ new Set(), hyd
54415
54570
  const paramInit = buildParamInit3(comp.paramNames, comp.propsAlias);
54416
54571
  if (paramInit)
54417
54572
  ctx2.push(indent3(paramInit));
54573
+ const deferredTrackDecls = /* @__PURE__ */ new Set();
54574
+ {
54575
+ const declaredSoFar = /* @__PURE__ */ new Set();
54576
+ for (const node of comp.body) {
54577
+ if (node instanceof TrackDecl) {
54578
+ if (initReadsAnyOf2(node.init, declaredSoFar))
54579
+ deferredTrackDecls.add(node);
54580
+ continue;
54581
+ }
54582
+ for (const name of runtimeDeclaredNames2(node))
54583
+ declaredSoFar.add(name);
54584
+ }
54585
+ }
54418
54586
  for (const node of comp.body) {
54419
- if (node instanceof TrackDecl) {
54587
+ if (node instanceof TrackDecl && !deferredTrackDecls.has(node)) {
54420
54588
  emitNode2(ctx2, node, tracked2, null);
54421
54589
  }
54422
54590
  }
@@ -54439,8 +54607,11 @@ function generateComponent2(comp, importedNames = /* @__PURE__ */ new Set(), hyd
54439
54607
  }
54440
54608
  }
54441
54609
  for (const node of comp.body) {
54442
- if (node instanceof TrackDecl)
54610
+ if (node instanceof TrackDecl) {
54611
+ if (deferredTrackDecls.has(node))
54612
+ emitNode2(ctx2, node, tracked2, null);
54443
54613
  continue;
54614
+ }
54444
54615
  const v = emitNode2(ctx2, node, tracked2, null, void 0, "__components", topPendingSkip, topBudget || void 0);
54445
54616
  if (v) {
54446
54617
  if (ctx2.hydrate) {
@@ -56102,6 +56273,35 @@ init_vsk_collision();
56102
56273
  init_vsk_imports();
56103
56274
  init_md_inline();
56104
56275
  init_module_imports();
56276
+ import { availableParallelism as availableParallelism2 } from "node:os";
56277
+ async function mapWithConcurrency2(items, limit, fn) {
56278
+ const out = new Array(items.length);
56279
+ let next = 0;
56280
+ let firstError = null;
56281
+ const worker = async () => {
56282
+ for (; ; ) {
56283
+ const i = next++;
56284
+ if (i >= items.length)
56285
+ return;
56286
+ if (firstError !== null)
56287
+ return;
56288
+ try {
56289
+ out[i] = await fn(items[i], i);
56290
+ } catch (e) {
56291
+ if (firstError === null)
56292
+ firstError = e;
56293
+ return;
56294
+ }
56295
+ }
56296
+ };
56297
+ const workers = [];
56298
+ for (let i = 0; i < Math.min(limit, items.length); i++)
56299
+ workers.push(worker());
56300
+ await Promise.all(workers);
56301
+ if (firstError !== null)
56302
+ throw firstError;
56303
+ return out;
56304
+ }
56105
56305
  var __dirname7 = dirname18(fileURLToPath6(import.meta.url));
56106
56306
  function fileUnchanged2(filePath, cached) {
56107
56307
  try {
@@ -56570,6 +56770,13 @@ function removeCompiledNodes2(code, isTarget) {
56570
56770
  }
56571
56771
  return code;
56572
56772
  }
56773
+ var SHARED_CHUNK_NAME2 = "shared.js";
56774
+ function buildChunkName2(appDir, node) {
56775
+ const dir = relative6(appDir, node.sourceDir || "");
56776
+ const parts = dir.split(sep3).filter(Boolean);
56777
+ const slug = parts.length > 0 ? parts.join("-") : "index";
56778
+ return slug.replace(/[\[\]]/g, "_");
56779
+ }
56573
56780
  async function generateClientBundle2(routeTree, appDir, componentMap, options) {
56574
56781
  const runtimeDir = findRuntimeSrc3(appDir);
56575
56782
  let seen = /* @__PURE__ */ new Set();
@@ -56578,6 +56785,7 @@ async function generateClientBundle2(routeTree, appDir, componentMap, options) {
56578
56785
  const runtimeImportNames = /* @__PURE__ */ new Set();
56579
56786
  const cache2 = options?.cache;
56580
56787
  const only = options?.only && options.only.length > 0 ? new Set(options.only) : null;
56788
+ const onlyRoutes = options?.onlyRoutes && options.onlyRoutes.length > 0 ? new Set(options.onlyRoutes) : null;
56581
56789
  const returnEdited = !!options?.returnEditedSources && !!only;
56582
56790
  const editedSources = returnEdited ? /* @__PURE__ */ new Map() : void 0;
56583
56791
  const editedNames = returnEdited ? /* @__PURE__ */ new Map() : void 0;
@@ -56721,12 +56929,6 @@ async function generateClientBundle2(routeTree, appDir, componentMap, options) {
56721
56929
  });
56722
56930
  }
56723
56931
  }
56724
- function buildChunkName(node) {
56725
- const dir = relative6(appDir, node.sourceDir || "");
56726
- const parts = dir.split(sep3).filter(Boolean);
56727
- const slug = parts.length > 0 ? parts.join("-") : "index";
56728
- return slug.replace(/[\[\]]/g, "_");
56729
- }
56730
56932
  const codeSplit = !!options?.codeSplit;
56731
56933
  const transformPlugins = options?.plugins || [];
56732
56934
  const componentOwners = new VskComponentOwners();
@@ -56778,22 +56980,26 @@ async function generateClientBundle2(routeTree, appDir, componentMap, options) {
56778
56980
  compileFile2(loadingPath, node.loading, chunkCode, chunkImports);
56779
56981
  }
56780
56982
  if (chunkCode.length > 0) {
56781
- const chunkName = `page-${buildChunkName(node)}.js`;
56782
- if (!chunkImports.ok)
56783
- console.error("[vesk] chunk import merge aborted for", chunkName + ":", chunkImports.reason);
56784
- const head = chunkImports.render();
56785
- const code = (head ? head + "\n\n" : "") + chunkCode.join("\n\n");
56786
- chunkEntries.push({ name: chunkName, code, node, importsTable: chunkImports, imports: chunkHasImports2(head.length, !chunkImports.ok) });
56983
+ const chunkName = `page-${buildChunkName2(appDir, node)}.js`;
56984
+ if (!onlyRoutes || onlyRoutes.has(node.fullPath)) {
56985
+ if (!chunkImports.ok)
56986
+ console.error("[vesk] chunk import merge aborted for", chunkName + ":", chunkImports.reason);
56987
+ const head = chunkImports.render();
56988
+ const code = (head ? head + "\n\n" : "") + chunkCode.join("\n\n");
56989
+ chunkEntries.push({ name: chunkName, code, node, importsTable: chunkImports, imports: chunkHasImports2(head.length, !chunkImports.ok) });
56990
+ }
56787
56991
  }
56788
56992
  walkSplit2(node.children || [], [..._chain, node]);
56789
56993
  }
56790
56994
  }, annotate2 = function(nodes) {
56791
56995
  for (const node of nodes) {
56792
- const chunkName = `page-${buildChunkName(node)}.js`;
56996
+ const chunkName = `page-${buildChunkName2(appDir, node)}.js`;
56793
56997
  const emitted = chunks.find((c) => c.name === chunkName && c.code.trim());
56794
56998
  if (emitted) {
56795
56999
  const fileName = options?.hmr ? chunkName : hashedName(chunkName, emitted.code);
56796
57000
  node.chunk = `/_vesk/static/${fileName}`;
57001
+ } else if (options?.skipRouteChunks) {
57002
+ node.chunk = `/_vesk/static/${chunkName}`;
56797
57003
  }
56798
57004
  annotate2(node.children || []);
56799
57005
  }
@@ -56813,7 +57019,7 @@ async function generateClientBundle2(routeTree, appDir, componentMap, options) {
56813
57019
  console.error("[vesk] chunk import merge aborted for shared.js:", sharedImports.reason);
56814
57020
  const head = sharedImports.render();
56815
57021
  const code = (head ? head + "\n\n" : "") + sharedCode.join("\n\n");
56816
- chunkEntries.push({ name: "shared.js", code, node: null, importsTable: sharedImports, imports: chunkHasImports2(head.length, !sharedImports.ok) });
57022
+ chunkEntries.push({ name: SHARED_CHUNK_NAME2, code, node: null, importsTable: sharedImports, imports: chunkHasImports2(head.length, !sharedImports.ok) });
56817
57023
  }
56818
57024
  const chunkIIFE = (body) => `(()=>{
56819
57025
  const __components = globalThis.__components || (globalThis.__components = {});
@@ -56916,9 +57122,9 @@ ${body}
56916
57122
  });
56917
57123
  }
56918
57124
  } : null;
56919
- for (const entry of chunkEntries) {
57125
+ const buildChunkEntry = async (entry) => {
56920
57126
  if (!entry.code.trim())
56921
- continue;
57127
+ return null;
56922
57128
  let finalCode;
56923
57129
  if (entry.imports) {
56924
57130
  const tmpBase = mkdtempSync2(join20(resolve24(appDir, ".."), "tmp-vesk-chunk-"));
@@ -56976,7 +57182,14 @@ ${entry.code}
56976
57182
  } else {
56977
57183
  finalCode = chunkIIFE(demoteExports2(entry.code));
56978
57184
  }
56979
- chunks.push({ name: entry.name, code: finalCode });
57185
+ return { name: entry.name, code: finalCode };
57186
+ };
57187
+ const effectiveChunkEntries = options?.skipRouteChunks ? chunkEntries.filter((e) => e.name === SHARED_CHUNK_NAME2) : chunkEntries;
57188
+ const CHUNK_CONCURRENCY = Math.max(1, Math.min(6, (availableParallelism2?.() ?? 4) - 1));
57189
+ const built = await mapWithConcurrency2(effectiveChunkEntries, CHUNK_CONCURRENCY, buildChunkEntry);
57190
+ for (const c of built) {
57191
+ if (c !== null)
57192
+ chunks.push(c);
56980
57193
  }
56981
57194
  annotate2(routeTree);
56982
57195
  sharedModuleBundle = sharedBundleCode;
@@ -63981,6 +64194,43 @@ async function startDevServer(port, projectDir, config, host) {
63981
64194
  for (const c of chunks) next.set(`/_vesk/static/${c.name}`, c.code);
63982
64195
  clientChunks = next;
63983
64196
  }
64197
+ const routeChunksBuilt = /* @__PURE__ */ new Set();
64198
+ let clientGeneration = 0;
64199
+ async function ensureRouteChunk(fullPath) {
64200
+ if (routeChunksBuilt.has(fullPath)) return;
64201
+ routeChunksBuilt.add(fullPath);
64202
+ const generation = clientGeneration;
64203
+ const { chunks } = await generateClientBundle2(routeTree, appDirPath, /* @__PURE__ */ new Map(), {
64204
+ importRuntime: true,
64205
+ hmr: true,
64206
+ codeSplit: true,
64207
+ cache: bundleCache,
64208
+ onlyRoutes: [fullPath],
64209
+ ...config.routeDataCache !== void 0 ? { routeDataCache: config.routeDataCache } : {}
64210
+ });
64211
+ if (generation !== clientGeneration) {
64212
+ routeChunksBuilt.delete(fullPath);
64213
+ return;
64214
+ }
64215
+ const next = new Map(clientChunks);
64216
+ for (const c of chunks) next.set(`/_vesk/static/${c.name}`, c.code);
64217
+ clientChunks = next;
64218
+ }
64219
+ function routeFullPathForChunk(chunkName) {
64220
+ let found = null;
64221
+ const walk9 = (nodes) => {
64222
+ for (const node of nodes) {
64223
+ if (found) return;
64224
+ if (`page-${buildChunkName2(appDirPath, node)}.js` === chunkName) {
64225
+ found = node.fullPath;
64226
+ return;
64227
+ }
64228
+ walk9(node.children || []);
64229
+ }
64230
+ };
64231
+ walk9(routeTree);
64232
+ return found;
64233
+ }
63984
64234
  async function buildClientBundle() {
63985
64235
  try {
63986
64236
  const { main, chunks } = await generateClientBundle2(routeTree, appDirPath, /* @__PURE__ */ new Map(), {
@@ -63988,6 +64238,11 @@ async function startDevServer(port, projectDir, config, host) {
63988
64238
  hmr: true,
63989
64239
  codeSplit: true,
63990
64240
  cache: bundleCache,
64241
+ // Startup cost otherwise scales with app size: one self-contained
64242
+ // compile + esbuild pass per route. A dev session visits a handful of
64243
+ // routes, so each route's chunk is built on first request instead
64244
+ // (see ensureRouteChunk).
64245
+ skipRouteChunks: true,
63991
64246
  ...config.routeDataCache !== void 0 ? { routeDataCache: config.routeDataCache } : {}
63992
64247
  });
63993
64248
  clientBundle = main;
@@ -64009,6 +64264,10 @@ async function startDevServer(port, projectDir, config, host) {
64009
64264
  returnEditedSources: true,
64010
64265
  ...config.routeDataCache !== void 0 ? { routeDataCache: config.routeDataCache } : {}
64011
64266
  });
64267
+ const keepShared = (name) => name === SHARED_CHUNK_NAME2;
64268
+ clientChunks = new Map([...clientChunks].filter(([url]) => keepShared(url.slice(url.lastIndexOf("/") + 1))));
64269
+ routeChunksBuilt.clear();
64270
+ clientGeneration++;
64012
64271
  storeChunks(chunks);
64013
64272
  return { err: null, editedSource: editedSources?.get(fullPath) ?? null, actualName: editedNames?.get(fullPath) ?? null };
64014
64273
  } catch (e) {
@@ -64499,7 +64758,19 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
64499
64758
  return;
64500
64759
  }
64501
64760
  if (url.pathname.startsWith("/_vesk/static/") && url.pathname.endsWith(".js")) {
64502
- const code = clientChunks.get(url.pathname);
64761
+ let code = clientChunks.get(url.pathname);
64762
+ if (code === void 0) {
64763
+ const name = url.pathname.slice(url.pathname.lastIndexOf("/") + 1);
64764
+ const fullPath = routeFullPathForChunk(name);
64765
+ if (fullPath) {
64766
+ try {
64767
+ await ensureRouteChunk(fullPath);
64768
+ } catch (e) {
64769
+ LOG.err(`client chunk build failed for ${name}:`, e.message);
64770
+ }
64771
+ code = clientChunks.get(url.pathname);
64772
+ }
64773
+ }
64503
64774
  if (code !== void 0) {
64504
64775
  res.writeHead(200, { "Content-Type": "application/javascript", "Cache-Control": "no-store" });
64505
64776
  res.end(code);
@@ -64707,6 +64978,16 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
64707
64978
  }
64708
64979
  const matched = match;
64709
64980
  const forData = req.headers["x-vesk-data"] === "1";
64981
+ if (!forData && matched && Array.isArray(matched.nodes)) {
64982
+ const leaf2 = matched.nodes.find((n) => n.page);
64983
+ if (leaf2 && typeof leaf2.fullPath === "string") {
64984
+ try {
64985
+ await ensureRouteChunk(leaf2.fullPath);
64986
+ } catch (e) {
64987
+ LOG.err(`client chunk build failed for ${leaf2.fullPath}:`, e.message);
64988
+ }
64989
+ }
64990
+ }
64710
64991
  async function renderSSR() {
64711
64992
  const ssg2 = globalThis;
64712
64993
  ssg2.__vsk_ssr_data = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vesk/vesk-cli",
3
- "version": "0.2.61",
3
+ "version": "0.2.63",
4
4
  "type": "module",
5
5
  "description": "Vesk — compiler-first framework for the post-VDOM web. vesk dev, vesk build.",
6
6
  "bin": {
@@ -8,10 +8,10 @@
8
8
  },
9
9
  "main": "./dist/cli.js",
10
10
  "dependencies": {
11
- "@vesk/adapter": "^0.2.61",
12
- "@vesk/compiler": "^0.2.61",
13
- "@vesk/plugin-tailwind": "^0.2.61",
14
- "@vesk/runtime": "^0.2.61",
11
+ "@vesk/adapter": "^0.2.63",
12
+ "@vesk/compiler": "^0.2.63",
13
+ "@vesk/plugin-tailwind": "^0.2.63",
14
+ "@vesk/runtime": "^0.2.63",
15
15
  "esrap": "^2.3.0",
16
16
  "typescript": "^5.8.0",
17
17
  "ws": "^8.18.0",