@vesk/vesk-cli 0.2.62 → 0.2.64
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.js +254 -39
- package/package.json +5 -5
package/dist/cli.js
CHANGED
|
@@ -47726,7 +47726,7 @@ __export(migrate_exports, {
|
|
|
47726
47726
|
detectInstalledVersion: () => detectInstalledVersion,
|
|
47727
47727
|
runMigrate: () => runMigrate
|
|
47728
47728
|
});
|
|
47729
|
-
import { readFileSync as readFileSync41, writeFileSync as
|
|
47729
|
+
import { readFileSync as readFileSync41, writeFileSync as writeFileSync22, existsSync as existsSync44, statSync as statSync23, readdirSync as readdirSync15 } from "node:fs";
|
|
47730
47730
|
import { join as join29, relative as relative9, extname as extname9 } from "node:path";
|
|
47731
47731
|
function detectInstalledVersion(projectDir, cliVersion) {
|
|
47732
47732
|
for (const pkg of ["@vesk/vesk-cli", "@vesk/adapter", "@vesk/compiler"]) {
|
|
@@ -47815,7 +47815,7 @@ function runMigrate(options) {
|
|
|
47815
47815
|
}
|
|
47816
47816
|
if (!changed) continue;
|
|
47817
47817
|
report.filesChanged.push(relPath);
|
|
47818
|
-
if (!options.dryRun)
|
|
47818
|
+
if (!options.dryRun) writeFileSync22(abs, current2, "utf-8");
|
|
47819
47819
|
}
|
|
47820
47820
|
return report;
|
|
47821
47821
|
}
|
|
@@ -47830,7 +47830,7 @@ var init_migrate = __esm({
|
|
|
47830
47830
|
});
|
|
47831
47831
|
|
|
47832
47832
|
// src/index.ts
|
|
47833
|
-
import { readFileSync as readFileSync42, writeFileSync as
|
|
47833
|
+
import { readFileSync as readFileSync42, writeFileSync as writeFileSync23, mkdirSync as mkdirSync20, existsSync as existsSync45 } from "fs";
|
|
47834
47834
|
import { resolve as resolve40, join as join30 } from "path";
|
|
47835
47835
|
import { fileURLToPath as fileURLToPath9 } from "url";
|
|
47836
47836
|
|
|
@@ -49922,6 +49922,30 @@ init_vsk_collision();
|
|
|
49922
49922
|
init_vsk_imports();
|
|
49923
49923
|
init_md_inline();
|
|
49924
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
|
+
}
|
|
49925
49949
|
var __dirname3 = dirname8(fileURLToPath2(import.meta.url));
|
|
49926
49950
|
function fileUnchanged(filePath, cached) {
|
|
49927
49951
|
try {
|
|
@@ -50340,6 +50364,13 @@ function removeCompiledNodes(code, isTarget) {
|
|
|
50340
50364
|
}
|
|
50341
50365
|
return code;
|
|
50342
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
|
+
}
|
|
50343
50374
|
async function generateClientBundle(routeTree, appDir, componentMap, options) {
|
|
50344
50375
|
const runtimeDir = findRuntimeSrc2(appDir);
|
|
50345
50376
|
let seen = /* @__PURE__ */ new Set();
|
|
@@ -50348,6 +50379,7 @@ async function generateClientBundle(routeTree, appDir, componentMap, options) {
|
|
|
50348
50379
|
const runtimeImportNames = /* @__PURE__ */ new Set();
|
|
50349
50380
|
const cache2 = options?.cache;
|
|
50350
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;
|
|
50351
50383
|
const returnEdited = !!options?.returnEditedSources && !!only;
|
|
50352
50384
|
const editedSources = returnEdited ? /* @__PURE__ */ new Map() : void 0;
|
|
50353
50385
|
const editedNames = returnEdited ? /* @__PURE__ */ new Map() : void 0;
|
|
@@ -50481,12 +50513,6 @@ async function generateClientBundle(routeTree, appDir, componentMap, options) {
|
|
|
50481
50513
|
});
|
|
50482
50514
|
}
|
|
50483
50515
|
}
|
|
50484
|
-
function buildChunkName(node) {
|
|
50485
|
-
const dir = relative2(appDir, node.sourceDir || "");
|
|
50486
|
-
const parts = dir.split(sep).filter(Boolean);
|
|
50487
|
-
const slug = parts.length > 0 ? parts.join("-") : "index";
|
|
50488
|
-
return slug.replace(/[\[\]]/g, "_");
|
|
50489
|
-
}
|
|
50490
50516
|
const codeSplit = !!options?.codeSplit;
|
|
50491
50517
|
const transformPlugins = options?.plugins || [];
|
|
50492
50518
|
const componentOwners = new VskComponentOwners();
|
|
@@ -50536,21 +50562,25 @@ async function generateClientBundle(routeTree, appDir, componentMap, options) {
|
|
|
50536
50562
|
compileFile2(loadingPath, node.loading, chunkCode, chunkImports);
|
|
50537
50563
|
}
|
|
50538
50564
|
if (chunkCode.length > 0) {
|
|
50539
|
-
const chunkName = `page-${buildChunkName(node)}.js`;
|
|
50540
|
-
if (!
|
|
50541
|
-
|
|
50542
|
-
|
|
50543
|
-
|
|
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
|
+
}
|
|
50544
50572
|
}
|
|
50545
50573
|
walkSplit2(node.children || [], [..._chain, node]);
|
|
50546
50574
|
}
|
|
50547
50575
|
}, annotate2 = function(nodes) {
|
|
50548
50576
|
for (const node of nodes) {
|
|
50549
|
-
const chunkName = `page-${buildChunkName(node)}.js`;
|
|
50577
|
+
const chunkName = `page-${buildChunkName(appDir, node)}.js`;
|
|
50550
50578
|
const emitted = chunks.find((c) => c.name === chunkName && c.code.trim());
|
|
50551
50579
|
if (emitted) {
|
|
50552
50580
|
const fileName = options?.hmr ? chunkName : hashedName(chunkName, emitted.code);
|
|
50553
50581
|
node.chunk = `/_vesk/static/${fileName}`;
|
|
50582
|
+
} else if (options?.skipRouteChunks) {
|
|
50583
|
+
node.chunk = `/_vesk/static/${chunkName}`;
|
|
50554
50584
|
}
|
|
50555
50585
|
annotate2(node.children || []);
|
|
50556
50586
|
}
|
|
@@ -50569,7 +50599,7 @@ async function generateClientBundle(routeTree, appDir, componentMap, options) {
|
|
|
50569
50599
|
if (!sharedImports.ok) console.error("[vesk] chunk import merge aborted for shared.js:", sharedImports.reason);
|
|
50570
50600
|
const head = sharedImports.render();
|
|
50571
50601
|
const code = (head ? head + "\n\n" : "") + sharedCode.join("\n\n");
|
|
50572
|
-
chunkEntries.push({ name:
|
|
50602
|
+
chunkEntries.push({ name: SHARED_CHUNK_NAME, code, node: null, importsTable: sharedImports, imports: chunkHasImports(head.length, !sharedImports.ok) });
|
|
50573
50603
|
}
|
|
50574
50604
|
const chunkIIFE = (body) => `(()=>{
|
|
50575
50605
|
const __components = globalThis.__components || (globalThis.__components = {});
|
|
@@ -50669,8 +50699,8 @@ ${body}
|
|
|
50669
50699
|
});
|
|
50670
50700
|
}
|
|
50671
50701
|
} : null;
|
|
50672
|
-
|
|
50673
|
-
if (!entry.code.trim())
|
|
50702
|
+
const buildChunkEntry = async (entry) => {
|
|
50703
|
+
if (!entry.code.trim()) return null;
|
|
50674
50704
|
let finalCode;
|
|
50675
50705
|
if (entry.imports) {
|
|
50676
50706
|
const tmpBase = mkdtempSync(join7(resolve10(appDir, ".."), "tmp-vesk-chunk-"));
|
|
@@ -50728,7 +50758,13 @@ ${entry.code}
|
|
|
50728
50758
|
} else {
|
|
50729
50759
|
finalCode = chunkIIFE(demoteExports(entry.code));
|
|
50730
50760
|
}
|
|
50731
|
-
|
|
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);
|
|
50732
50768
|
}
|
|
50733
50769
|
annotate2(routeTree);
|
|
50734
50770
|
sharedModuleBundle = sharedBundleCode;
|
|
@@ -52148,7 +52184,8 @@ vesk build: done (${outDir})`);
|
|
|
52148
52184
|
init_seo_audit();
|
|
52149
52185
|
|
|
52150
52186
|
// src/dev-server.ts
|
|
52151
|
-
import { readFileSync as readFileSync38, watch, statSync as statSync21, existsSync as existsSync42, readdirSync as readdirSync13 } from "node:fs";
|
|
52187
|
+
import { readFileSync as readFileSync38, watch, statSync as statSync21, existsSync as existsSync42, mkdirSync as mkdirSync19, readdirSync as readdirSync13, writeFileSync as writeFileSync21, renameSync as renameSync2 } from "node:fs";
|
|
52188
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
52152
52189
|
import { resolve as resolve38, extname as extname8, join as join26, dirname as dirname26 } from "node:path";
|
|
52153
52190
|
import { createServer as createServer2 } from "node:http";
|
|
52154
52191
|
import { WebSocketServer as WebSocketServer2 } from "ws";
|
|
@@ -56237,6 +56274,35 @@ init_vsk_collision();
|
|
|
56237
56274
|
init_vsk_imports();
|
|
56238
56275
|
init_md_inline();
|
|
56239
56276
|
init_module_imports();
|
|
56277
|
+
import { availableParallelism as availableParallelism2 } from "node:os";
|
|
56278
|
+
async function mapWithConcurrency2(items, limit, fn) {
|
|
56279
|
+
const out = new Array(items.length);
|
|
56280
|
+
let next = 0;
|
|
56281
|
+
let firstError = null;
|
|
56282
|
+
const worker = async () => {
|
|
56283
|
+
for (; ; ) {
|
|
56284
|
+
const i = next++;
|
|
56285
|
+
if (i >= items.length)
|
|
56286
|
+
return;
|
|
56287
|
+
if (firstError !== null)
|
|
56288
|
+
return;
|
|
56289
|
+
try {
|
|
56290
|
+
out[i] = await fn(items[i], i);
|
|
56291
|
+
} catch (e) {
|
|
56292
|
+
if (firstError === null)
|
|
56293
|
+
firstError = e;
|
|
56294
|
+
return;
|
|
56295
|
+
}
|
|
56296
|
+
}
|
|
56297
|
+
};
|
|
56298
|
+
const workers = [];
|
|
56299
|
+
for (let i = 0; i < Math.min(limit, items.length); i++)
|
|
56300
|
+
workers.push(worker());
|
|
56301
|
+
await Promise.all(workers);
|
|
56302
|
+
if (firstError !== null)
|
|
56303
|
+
throw firstError;
|
|
56304
|
+
return out;
|
|
56305
|
+
}
|
|
56240
56306
|
var __dirname7 = dirname18(fileURLToPath6(import.meta.url));
|
|
56241
56307
|
function fileUnchanged2(filePath, cached) {
|
|
56242
56308
|
try {
|
|
@@ -56705,6 +56771,13 @@ function removeCompiledNodes2(code, isTarget) {
|
|
|
56705
56771
|
}
|
|
56706
56772
|
return code;
|
|
56707
56773
|
}
|
|
56774
|
+
var SHARED_CHUNK_NAME2 = "shared.js";
|
|
56775
|
+
function buildChunkName2(appDir, node) {
|
|
56776
|
+
const dir = relative6(appDir, node.sourceDir || "");
|
|
56777
|
+
const parts = dir.split(sep3).filter(Boolean);
|
|
56778
|
+
const slug = parts.length > 0 ? parts.join("-") : "index";
|
|
56779
|
+
return slug.replace(/[\[\]]/g, "_");
|
|
56780
|
+
}
|
|
56708
56781
|
async function generateClientBundle2(routeTree, appDir, componentMap, options) {
|
|
56709
56782
|
const runtimeDir = findRuntimeSrc3(appDir);
|
|
56710
56783
|
let seen = /* @__PURE__ */ new Set();
|
|
@@ -56713,6 +56786,7 @@ async function generateClientBundle2(routeTree, appDir, componentMap, options) {
|
|
|
56713
56786
|
const runtimeImportNames = /* @__PURE__ */ new Set();
|
|
56714
56787
|
const cache2 = options?.cache;
|
|
56715
56788
|
const only = options?.only && options.only.length > 0 ? new Set(options.only) : null;
|
|
56789
|
+
const onlyRoutes = options?.onlyRoutes && options.onlyRoutes.length > 0 ? new Set(options.onlyRoutes) : null;
|
|
56716
56790
|
const returnEdited = !!options?.returnEditedSources && !!only;
|
|
56717
56791
|
const editedSources = returnEdited ? /* @__PURE__ */ new Map() : void 0;
|
|
56718
56792
|
const editedNames = returnEdited ? /* @__PURE__ */ new Map() : void 0;
|
|
@@ -56856,12 +56930,6 @@ async function generateClientBundle2(routeTree, appDir, componentMap, options) {
|
|
|
56856
56930
|
});
|
|
56857
56931
|
}
|
|
56858
56932
|
}
|
|
56859
|
-
function buildChunkName(node) {
|
|
56860
|
-
const dir = relative6(appDir, node.sourceDir || "");
|
|
56861
|
-
const parts = dir.split(sep3).filter(Boolean);
|
|
56862
|
-
const slug = parts.length > 0 ? parts.join("-") : "index";
|
|
56863
|
-
return slug.replace(/[\[\]]/g, "_");
|
|
56864
|
-
}
|
|
56865
56933
|
const codeSplit = !!options?.codeSplit;
|
|
56866
56934
|
const transformPlugins = options?.plugins || [];
|
|
56867
56935
|
const componentOwners = new VskComponentOwners();
|
|
@@ -56913,22 +56981,26 @@ async function generateClientBundle2(routeTree, appDir, componentMap, options) {
|
|
|
56913
56981
|
compileFile2(loadingPath, node.loading, chunkCode, chunkImports);
|
|
56914
56982
|
}
|
|
56915
56983
|
if (chunkCode.length > 0) {
|
|
56916
|
-
const chunkName = `page-${
|
|
56917
|
-
if (!
|
|
56918
|
-
|
|
56919
|
-
|
|
56920
|
-
|
|
56921
|
-
|
|
56984
|
+
const chunkName = `page-${buildChunkName2(appDir, node)}.js`;
|
|
56985
|
+
if (!onlyRoutes || onlyRoutes.has(node.fullPath)) {
|
|
56986
|
+
if (!chunkImports.ok)
|
|
56987
|
+
console.error("[vesk] chunk import merge aborted for", chunkName + ":", chunkImports.reason);
|
|
56988
|
+
const head = chunkImports.render();
|
|
56989
|
+
const code = (head ? head + "\n\n" : "") + chunkCode.join("\n\n");
|
|
56990
|
+
chunkEntries.push({ name: chunkName, code, node, importsTable: chunkImports, imports: chunkHasImports2(head.length, !chunkImports.ok) });
|
|
56991
|
+
}
|
|
56922
56992
|
}
|
|
56923
56993
|
walkSplit2(node.children || [], [..._chain, node]);
|
|
56924
56994
|
}
|
|
56925
56995
|
}, annotate2 = function(nodes) {
|
|
56926
56996
|
for (const node of nodes) {
|
|
56927
|
-
const chunkName = `page-${
|
|
56997
|
+
const chunkName = `page-${buildChunkName2(appDir, node)}.js`;
|
|
56928
56998
|
const emitted = chunks.find((c) => c.name === chunkName && c.code.trim());
|
|
56929
56999
|
if (emitted) {
|
|
56930
57000
|
const fileName = options?.hmr ? chunkName : hashedName(chunkName, emitted.code);
|
|
56931
57001
|
node.chunk = `/_vesk/static/${fileName}`;
|
|
57002
|
+
} else if (options?.skipRouteChunks) {
|
|
57003
|
+
node.chunk = `/_vesk/static/${chunkName}`;
|
|
56932
57004
|
}
|
|
56933
57005
|
annotate2(node.children || []);
|
|
56934
57006
|
}
|
|
@@ -56948,7 +57020,7 @@ async function generateClientBundle2(routeTree, appDir, componentMap, options) {
|
|
|
56948
57020
|
console.error("[vesk] chunk import merge aborted for shared.js:", sharedImports.reason);
|
|
56949
57021
|
const head = sharedImports.render();
|
|
56950
57022
|
const code = (head ? head + "\n\n" : "") + sharedCode.join("\n\n");
|
|
56951
|
-
chunkEntries.push({ name:
|
|
57023
|
+
chunkEntries.push({ name: SHARED_CHUNK_NAME2, code, node: null, importsTable: sharedImports, imports: chunkHasImports2(head.length, !sharedImports.ok) });
|
|
56952
57024
|
}
|
|
56953
57025
|
const chunkIIFE = (body) => `(()=>{
|
|
56954
57026
|
const __components = globalThis.__components || (globalThis.__components = {});
|
|
@@ -57051,9 +57123,9 @@ ${body}
|
|
|
57051
57123
|
});
|
|
57052
57124
|
}
|
|
57053
57125
|
} : null;
|
|
57054
|
-
|
|
57126
|
+
const buildChunkEntry = async (entry) => {
|
|
57055
57127
|
if (!entry.code.trim())
|
|
57056
|
-
|
|
57128
|
+
return null;
|
|
57057
57129
|
let finalCode;
|
|
57058
57130
|
if (entry.imports) {
|
|
57059
57131
|
const tmpBase = mkdtempSync2(join20(resolve24(appDir, ".."), "tmp-vesk-chunk-"));
|
|
@@ -57111,7 +57183,14 @@ ${entry.code}
|
|
|
57111
57183
|
} else {
|
|
57112
57184
|
finalCode = chunkIIFE(demoteExports2(entry.code));
|
|
57113
57185
|
}
|
|
57114
|
-
|
|
57186
|
+
return { name: entry.name, code: finalCode };
|
|
57187
|
+
};
|
|
57188
|
+
const effectiveChunkEntries = options?.skipRouteChunks ? chunkEntries.filter((e) => e.name === SHARED_CHUNK_NAME2) : chunkEntries;
|
|
57189
|
+
const CHUNK_CONCURRENCY = Math.max(1, Math.min(6, (availableParallelism2?.() ?? 4) - 1));
|
|
57190
|
+
const built = await mapWithConcurrency2(effectiveChunkEntries, CHUNK_CONCURRENCY, buildChunkEntry);
|
|
57191
|
+
for (const c of built) {
|
|
57192
|
+
if (c !== null)
|
|
57193
|
+
chunks.push(c);
|
|
57115
57194
|
}
|
|
57116
57195
|
annotate2(routeTree);
|
|
57117
57196
|
sharedModuleBundle = sharedBundleCode;
|
|
@@ -64116,18 +64195,128 @@ async function startDevServer(port, projectDir, config, host) {
|
|
|
64116
64195
|
for (const c of chunks) next.set(`/_vesk/static/${c.name}`, c.code);
|
|
64117
64196
|
clientChunks = next;
|
|
64118
64197
|
}
|
|
64198
|
+
const routeChunksBuilt = /* @__PURE__ */ new Set();
|
|
64199
|
+
let clientGeneration = 0;
|
|
64200
|
+
const devCacheDir = () => join26(projectDir, "node_modules", ".vesk", "dev-cache");
|
|
64201
|
+
function devCacheKey() {
|
|
64202
|
+
const parts = [`flags:${!!config.routeDataCache}`];
|
|
64203
|
+
const walk9 = (dir) => {
|
|
64204
|
+
let entries = [];
|
|
64205
|
+
try {
|
|
64206
|
+
entries = readdirSync13(dir);
|
|
64207
|
+
} catch {
|
|
64208
|
+
return;
|
|
64209
|
+
}
|
|
64210
|
+
for (const name of entries.sort()) {
|
|
64211
|
+
if (name === "node_modules" || name.startsWith(".")) continue;
|
|
64212
|
+
const p = join26(dir, name);
|
|
64213
|
+
let st;
|
|
64214
|
+
try {
|
|
64215
|
+
st = statSync21(p);
|
|
64216
|
+
} catch {
|
|
64217
|
+
continue;
|
|
64218
|
+
}
|
|
64219
|
+
if (st.isDirectory()) {
|
|
64220
|
+
walk9(p);
|
|
64221
|
+
continue;
|
|
64222
|
+
}
|
|
64223
|
+
if (!/\.(vsk|ts|tsx|js|jsx|vue|svelte)$/.test(name)) continue;
|
|
64224
|
+
parts.push(`${p}:${st.mtimeMs}:${st.size}`);
|
|
64225
|
+
}
|
|
64226
|
+
};
|
|
64227
|
+
walk9(appDirPath);
|
|
64228
|
+
try {
|
|
64229
|
+
parts.push(`compiler:${readFileSync38(join26(process.cwd(), "node_modules", "@vesk", "compiler", "package.json"), "utf8")}`);
|
|
64230
|
+
} catch {
|
|
64231
|
+
}
|
|
64232
|
+
return createHash2("sha256").update(parts.join("\n")).digest("hex").slice(0, 32);
|
|
64233
|
+
}
|
|
64234
|
+
function readDevBundleCache() {
|
|
64235
|
+
try {
|
|
64236
|
+
const file = join26(devCacheDir(), "client-bundle.json");
|
|
64237
|
+
const parsed = JSON.parse(readFileSync38(file, "utf8"));
|
|
64238
|
+
if (parsed.key !== devCacheKey() || typeof parsed.main !== "string" || !Array.isArray(parsed.chunks)) return null;
|
|
64239
|
+
return { main: parsed.main, chunks: parsed.chunks };
|
|
64240
|
+
} catch {
|
|
64241
|
+
return null;
|
|
64242
|
+
}
|
|
64243
|
+
}
|
|
64244
|
+
function writeDevBundleCache(main, chunks) {
|
|
64245
|
+
try {
|
|
64246
|
+
const dir = devCacheDir();
|
|
64247
|
+
mkdirSync19(dir, { recursive: true });
|
|
64248
|
+
const file = join26(dir, "client-bundle.json");
|
|
64249
|
+
const tmp = join26(dir, `client-bundle.${process.pid}.tmp`);
|
|
64250
|
+
writeFileSync21(tmp, JSON.stringify({ key: devCacheKey(), main, chunks }), "utf8");
|
|
64251
|
+
renameSync2(tmp, file);
|
|
64252
|
+
} catch {
|
|
64253
|
+
}
|
|
64254
|
+
}
|
|
64255
|
+
async function ensureRouteChunk(fullPath) {
|
|
64256
|
+
if (routeChunksBuilt.has(fullPath)) return;
|
|
64257
|
+
routeChunksBuilt.add(fullPath);
|
|
64258
|
+
const generation = clientGeneration;
|
|
64259
|
+
const { chunks } = await generateClientBundle2(routeTree, appDirPath, /* @__PURE__ */ new Map(), {
|
|
64260
|
+
importRuntime: true,
|
|
64261
|
+
hmr: true,
|
|
64262
|
+
codeSplit: true,
|
|
64263
|
+
cache: bundleCache,
|
|
64264
|
+
onlyRoutes: [fullPath],
|
|
64265
|
+
...config.routeDataCache !== void 0 ? { routeDataCache: config.routeDataCache } : {}
|
|
64266
|
+
});
|
|
64267
|
+
if (generation !== clientGeneration) {
|
|
64268
|
+
routeChunksBuilt.delete(fullPath);
|
|
64269
|
+
return;
|
|
64270
|
+
}
|
|
64271
|
+
const next = new Map(clientChunks);
|
|
64272
|
+
for (const c of chunks) next.set(`/_vesk/static/${c.name}`, c.code);
|
|
64273
|
+
clientChunks = next;
|
|
64274
|
+
}
|
|
64275
|
+
function routeFullPathForChunk(chunkName) {
|
|
64276
|
+
let found = null;
|
|
64277
|
+
const walk9 = (nodes) => {
|
|
64278
|
+
for (const node of nodes) {
|
|
64279
|
+
if (found) return;
|
|
64280
|
+
if (`page-${buildChunkName2(appDirPath, node)}.js` === chunkName) {
|
|
64281
|
+
found = node.fullPath;
|
|
64282
|
+
return;
|
|
64283
|
+
}
|
|
64284
|
+
walk9(node.children || []);
|
|
64285
|
+
}
|
|
64286
|
+
};
|
|
64287
|
+
walk9(routeTree);
|
|
64288
|
+
return found;
|
|
64289
|
+
}
|
|
64119
64290
|
async function buildClientBundle() {
|
|
64120
64291
|
try {
|
|
64292
|
+
const cached = readDevBundleCache();
|
|
64293
|
+
if (cached) {
|
|
64294
|
+
clientBundle = cached.main;
|
|
64295
|
+
devBundleBytes = Buffer.byteLength(cached.main, "utf8");
|
|
64296
|
+
storeChunks(cached.chunks);
|
|
64297
|
+
for (const c of cached.chunks) {
|
|
64298
|
+
const fullPath = c.name === SHARED_CHUNK_NAME2 ? null : routeFullPathForChunk(c.name);
|
|
64299
|
+
if (fullPath) routeChunksBuilt.add(fullPath);
|
|
64300
|
+
}
|
|
64301
|
+
LOG.info?.(`client bundle restored from cache (${cached.chunks.length} chunks)`);
|
|
64302
|
+
return;
|
|
64303
|
+
}
|
|
64121
64304
|
const { main, chunks } = await generateClientBundle2(routeTree, appDirPath, /* @__PURE__ */ new Map(), {
|
|
64122
64305
|
importRuntime: true,
|
|
64123
64306
|
hmr: true,
|
|
64124
64307
|
codeSplit: true,
|
|
64125
64308
|
cache: bundleCache,
|
|
64309
|
+
// Startup cost otherwise scales with app size: one self-contained
|
|
64310
|
+
// compile + esbuild pass per route. A dev session visits a handful of
|
|
64311
|
+
// routes, so each route's chunk is built on first request instead
|
|
64312
|
+
// (see ensureRouteChunk).
|
|
64313
|
+
skipRouteChunks: true,
|
|
64126
64314
|
...config.routeDataCache !== void 0 ? { routeDataCache: config.routeDataCache } : {}
|
|
64127
64315
|
});
|
|
64128
64316
|
clientBundle = main;
|
|
64129
64317
|
devBundleBytes = Buffer.byteLength(main, "utf8");
|
|
64130
64318
|
storeChunks(chunks);
|
|
64319
|
+
writeDevBundleCache(main, chunks);
|
|
64131
64320
|
} catch (e) {
|
|
64132
64321
|
LOG.err(`client build error:`, e.message);
|
|
64133
64322
|
throw e;
|
|
@@ -64144,6 +64333,10 @@ async function startDevServer(port, projectDir, config, host) {
|
|
|
64144
64333
|
returnEditedSources: true,
|
|
64145
64334
|
...config.routeDataCache !== void 0 ? { routeDataCache: config.routeDataCache } : {}
|
|
64146
64335
|
});
|
|
64336
|
+
const keepShared = (name) => name === SHARED_CHUNK_NAME2;
|
|
64337
|
+
clientChunks = new Map([...clientChunks].filter(([url]) => keepShared(url.slice(url.lastIndexOf("/") + 1))));
|
|
64338
|
+
routeChunksBuilt.clear();
|
|
64339
|
+
clientGeneration++;
|
|
64147
64340
|
storeChunks(chunks);
|
|
64148
64341
|
return { err: null, editedSource: editedSources?.get(fullPath) ?? null, actualName: editedNames?.get(fullPath) ?? null };
|
|
64149
64342
|
} catch (e) {
|
|
@@ -64634,7 +64827,19 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
64634
64827
|
return;
|
|
64635
64828
|
}
|
|
64636
64829
|
if (url.pathname.startsWith("/_vesk/static/") && url.pathname.endsWith(".js")) {
|
|
64637
|
-
|
|
64830
|
+
let code = clientChunks.get(url.pathname);
|
|
64831
|
+
if (code === void 0) {
|
|
64832
|
+
const name = url.pathname.slice(url.pathname.lastIndexOf("/") + 1);
|
|
64833
|
+
const fullPath = routeFullPathForChunk(name);
|
|
64834
|
+
if (fullPath) {
|
|
64835
|
+
try {
|
|
64836
|
+
await ensureRouteChunk(fullPath);
|
|
64837
|
+
} catch (e) {
|
|
64838
|
+
LOG.err(`client chunk build failed for ${name}:`, e.message);
|
|
64839
|
+
}
|
|
64840
|
+
code = clientChunks.get(url.pathname);
|
|
64841
|
+
}
|
|
64842
|
+
}
|
|
64638
64843
|
if (code !== void 0) {
|
|
64639
64844
|
res.writeHead(200, { "Content-Type": "application/javascript", "Cache-Control": "no-store" });
|
|
64640
64845
|
res.end(code);
|
|
@@ -64842,6 +65047,16 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
64842
65047
|
}
|
|
64843
65048
|
const matched = match;
|
|
64844
65049
|
const forData = req.headers["x-vesk-data"] === "1";
|
|
65050
|
+
if (!forData && matched && Array.isArray(matched.nodes)) {
|
|
65051
|
+
const leaf2 = matched.nodes.find((n) => n.page);
|
|
65052
|
+
if (leaf2 && typeof leaf2.fullPath === "string") {
|
|
65053
|
+
try {
|
|
65054
|
+
await ensureRouteChunk(leaf2.fullPath);
|
|
65055
|
+
} catch (e) {
|
|
65056
|
+
LOG.err(`client chunk build failed for ${leaf2.fullPath}:`, e.message);
|
|
65057
|
+
}
|
|
65058
|
+
}
|
|
65059
|
+
}
|
|
64845
65060
|
async function renderSSR() {
|
|
64846
65061
|
const ssg2 = globalThis;
|
|
64847
65062
|
ssg2.__vsk_ssr_data = {};
|
|
@@ -65729,7 +65944,7 @@ if (cmd === "init") {
|
|
|
65729
65944
|
process.exit(0);
|
|
65730
65945
|
}
|
|
65731
65946
|
mkdirSync20(appDirPath, { recursive: true });
|
|
65732
|
-
|
|
65947
|
+
writeFileSync23(target, [
|
|
65733
65948
|
`@import 'tailwindcss';`,
|
|
65734
65949
|
``,
|
|
65735
65950
|
`@layer base {`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vesk/vesk-cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.64",
|
|
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.
|
|
12
|
-
"@vesk/compiler": "^0.2.
|
|
13
|
-
"@vesk/plugin-tailwind": "^0.2.
|
|
14
|
-
"@vesk/runtime": "^0.2.
|
|
11
|
+
"@vesk/adapter": "^0.2.64",
|
|
12
|
+
"@vesk/compiler": "^0.2.64",
|
|
13
|
+
"@vesk/plugin-tailwind": "^0.2.64",
|
|
14
|
+
"@vesk/runtime": "^0.2.64",
|
|
15
15
|
"esrap": "^2.3.0",
|
|
16
16
|
"typescript": "^5.8.0",
|
|
17
17
|
"ws": "^8.18.0",
|