@jundle/cloudflare 0.0.1-12 → 0.0.1-14

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/package.json +1 -1
  2. package/src/harness.js +35 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jundle/cloudflare",
3
- "version": "0.0.1-12",
3
+ "version": "0.0.1-14",
4
4
  "description": "Cloudflare Workers runtime for the jundle dev server (workerd via Miniflare).",
5
5
  "license": "ISC",
6
6
  "type": "module",
package/src/harness.js CHANGED
@@ -146,8 +146,10 @@ async function fetchJson(url) {
146
146
 
147
147
  // Pull-based invalidation (SPEC §16.11): one loopback fetch per
148
148
  // dispatch. Evicts invalidated dev-module keys (evaluated +
149
- // text) and JSON values for edited JSON files, then advances
150
- // the seen version. The dev server prunes acked batches.
149
+ // text) and JSON values for edited JSON files, and rebuilt
150
+ // dep files (dep text + evaluated deps, plus every app
151
+ // module — SPEC §16.5), then advances the seen version.
152
+ // The dev server prunes acked batches.
151
153
  // After eviction, pushes fresh SSR-variant instances for the
152
154
  // browser-env subset (see pushSsrUpdates) before the entry
153
155
  // re-imports, so the entry's decode already sees them.
@@ -168,6 +170,37 @@ async function syncVersion() {
168
170
  if (k.split("\0")[1] === file) assetValueCache.delete(k);
169
171
  }
170
172
  }
173
+ // Dep invalidation (SPEC §16.5, §16.11): an on-demand
174
+ // unification run rebuilt existing dep bundles (same
175
+ // URL, new bytes) or remapped existing specs (the old
176
+ // files are dead). Evict the changed dep text —
177
+ // bundle-dir units share the entry's `file\0rel`
178
+ // prefix — then clear every evaluated module, app and
179
+ // dep alike (mirrors NodeRunner.invalidateAll).
180
+ // Evaluated app modules may hold the old dep exports,
181
+ // the closure walk prunes cached subtrees, and dep
182
+ // modules hold state coupled to the app modules (the
183
+ // Flight client's chunk map assumes the shim's cache
184
+ // outlives it — clearing the shim without the client
185
+ // makes the client require a chunk the fresh shim
186
+ // never loaded). Only the TEXT eviction is targeted:
187
+ // unchanged dep text is still valid input, so it
188
+ // stays cached and no re-fetch is needed for it. The
189
+ // fresh text is fetched lazily by the next entry
190
+ // import, not eagerly here: a re-fetch failure after
191
+ // the version advanced would leave the dep
192
+ // permanently broken until restart.
193
+ const depFiles = data.depFiles || [];
194
+ if (depFiles.length > 0) {
195
+ for (const file of depFiles) {
196
+ for (const k of depText.keys()) {
197
+ if (k === file || k.startsWith(`${file}\0`)) depText.delete(k);
198
+ }
199
+ }
200
+ evaluated.clear();
201
+ textCache.clear();
202
+ depEvaluated.clear();
203
+ }
171
204
  await pushSsrUpdates(data.clientInvalidated || []);
172
205
  }
173
206