@vesk/vesk-cli 0.2.46 → 0.2.47

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 +61 -14
  2. package/package.json +5 -5
package/dist/cli.js CHANGED
@@ -19045,14 +19045,40 @@ function depsFresh(cachedVal) {
19045
19045
  }
19046
19046
  return true;
19047
19047
  }
19048
- function readSsrSource(absPath) {
19048
+ function evict(cache2) {
19049
+ if (cache2.size <= BUILD_CACHE_MAX) return;
19050
+ let dropped = 0;
19051
+ for (const key of cache2.keys()) {
19052
+ cache2.delete(key);
19053
+ if (++dropped >= BUILD_CACHE_EVICT) break;
19054
+ }
19055
+ }
19056
+ function readSourceCached(absPath) {
19057
+ let mtimeMs;
19058
+ try {
19059
+ mtimeMs = statSync(absPath).mtimeMs;
19060
+ } catch {
19061
+ return null;
19062
+ }
19063
+ const hit = rawSourceCache.get(absPath);
19064
+ if (hit && hit.mtimeMs === mtimeMs) return hit.raw;
19049
19065
  let raw2;
19050
19066
  try {
19051
19067
  raw2 = readFileSync2(absPath, "utf-8");
19052
- } catch (err) {
19053
- console.warn(`[vesk] SSR: failed to read ${absPath}: ${err?.message ?? String(err)}`);
19068
+ } catch {
19069
+ return null;
19070
+ }
19071
+ rawSourceCache.set(absPath, { mtimeMs, raw: raw2 });
19072
+ evict(rawSourceCache);
19073
+ return raw2;
19074
+ }
19075
+ function readSsrSource(absPath) {
19076
+ const cachedRaw = readSourceCached(absPath);
19077
+ if (cachedRaw === null) {
19078
+ console.warn(`[vesk] SSR: failed to read ${absPath}`);
19054
19079
  return null;
19055
19080
  }
19081
+ const raw2 = cachedRaw;
19056
19082
  let ast = null;
19057
19083
  try {
19058
19084
  ast = parse4(raw2, { filename: absPath });
@@ -19712,23 +19738,40 @@ function collectModuleBundled(absPath, collector) {
19712
19738
  collector.modules.push({ key, code: `module.exports = ${raw2};`, dir, deps: {} });
19713
19739
  return key;
19714
19740
  }
19715
- const src2 = readSsrSource(absPath);
19716
- if (!src2 || !src2.ast) {
19717
- const raw2 = src2 ? src2.raw : "// unreadable during build\nmodule.exports = {};";
19718
- collector.modules.push({ key, code: raw2, dir, deps: {} });
19719
- return key;
19741
+ let mtimeMs = -1;
19742
+ try {
19743
+ mtimeMs = statSync(absPath).mtimeMs;
19744
+ } catch {
19745
+ }
19746
+ const cached = mtimeMs >= 0 ? bundledCodeCache.get(absPath) : void 0;
19747
+ let code;
19748
+ let specifiers;
19749
+ if (cached && cached.mtimeMs === mtimeMs) {
19750
+ code = cached.code;
19751
+ specifiers = cached.specifiers;
19752
+ } else {
19753
+ const src2 = readSsrSource(absPath);
19754
+ if (!src2 || !src2.ast) {
19755
+ const raw2 = src2 ? src2.raw : "// unreadable during build\nmodule.exports = {};";
19756
+ collector.modules.push({ key, code: raw2, dir, deps: {} });
19757
+ return key;
19758
+ }
19759
+ let stripped = src2.ast;
19760
+ if (hasTsSyntax(src2.ast)) stripped = stripTsTypes(src2.ast);
19761
+ stripped.body = (stripped.body || []).filter((n) => n ? !isTypeOnlyStatement(n) : false);
19762
+ specifiers = [...collectModuleSpecifiers(src2.ast)];
19763
+ code = esmToCjs(stripped.body);
19764
+ bundledCodeCache.set(absPath, { mtimeMs, code, specifiers });
19765
+ evict(bundledCodeCache);
19720
19766
  }
19721
- let stripped = src2.ast;
19722
- if (hasTsSyntax(src2.ast)) stripped = stripTsTypes(src2.ast);
19723
- stripped.body = (stripped.body || []).filter((n) => n ? !isTypeOnlyStatement(n) : false);
19724
19767
  const deps = {};
19725
- for (const spec of collectModuleSpecifiers(src2.ast)) {
19768
+ for (const spec of specifiers) {
19726
19769
  if (!isRelativeSpec(spec)) continue;
19727
19770
  const depPath = resolveSsrModule(spec, dir);
19728
19771
  if (!depPath) continue;
19729
19772
  deps[spec] = collectModuleBundled(depPath, collector);
19730
19773
  }
19731
- collector.modules.push({ key, code: esmToCjs(stripped.body), dir, deps });
19774
+ collector.modules.push({ key, code, dir, deps });
19732
19775
  return key;
19733
19776
  }
19734
19777
  function collectModuleBundle(importStrs, fromDir, collector) {
@@ -19748,7 +19791,7 @@ function collectModuleBundle(importStrs, fromDir, collector) {
19748
19791
  }
19749
19792
  return bindings;
19750
19793
  }
19751
- var RUNTIME_PREFIXES, EXTENSIONS, BUILTIN_PREFIX, BUILTIN_CACHE, MODULE_CACHE, MAX_CACHE_ENTRIES, depStack, EVALUATING, EMPTY_ALIASES, ALIAS_CACHE, exportCounter;
19794
+ var RUNTIME_PREFIXES, EXTENSIONS, BUILTIN_PREFIX, BUILTIN_CACHE, MODULE_CACHE, MAX_CACHE_ENTRIES, depStack, rawSourceCache, BUILD_CACHE_MAX, BUILD_CACHE_EVICT, EVALUATING, EMPTY_ALIASES, ALIAS_CACHE, exportCounter, bundledCodeCache;
19752
19795
  var init_module_imports = __esm({
19753
19796
  "../compiler/src/module-imports.ts"() {
19754
19797
  "use strict";
@@ -19762,10 +19805,14 @@ var init_module_imports = __esm({
19762
19805
  MODULE_CACHE = /* @__PURE__ */ new Map();
19763
19806
  MAX_CACHE_ENTRIES = 256;
19764
19807
  depStack = [];
19808
+ rawSourceCache = /* @__PURE__ */ new Map();
19809
+ BUILD_CACHE_MAX = 8192;
19810
+ BUILD_CACHE_EVICT = 2048;
19765
19811
  EVALUATING = /* @__PURE__ */ new Map();
19766
19812
  EMPTY_ALIASES = { exact: /* @__PURE__ */ new Map(), wildcard: [] };
19767
19813
  ALIAS_CACHE = /* @__PURE__ */ new Map();
19768
19814
  exportCounter = 0;
19815
+ bundledCodeCache = /* @__PURE__ */ new Map();
19769
19816
  }
19770
19817
  });
19771
19818
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vesk/vesk-cli",
3
- "version": "0.2.46",
3
+ "version": "0.2.47",
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.46",
12
- "@vesk/compiler": "^0.2.46",
13
- "@vesk/plugin-tailwind": "^0.2.46",
14
- "@vesk/runtime": "^0.2.46",
11
+ "@vesk/adapter": "^0.2.47",
12
+ "@vesk/compiler": "^0.2.47",
13
+ "@vesk/plugin-tailwind": "^0.2.47",
14
+ "@vesk/runtime": "^0.2.47",
15
15
  "esrap": "^2.3.0",
16
16
  "typescript": "^5.8.0",
17
17
  "ws": "^8.18.0",