@elurjs/kit 2.4.6 → 2.4.8

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/CHANGELOG.md CHANGED
@@ -1,10 +1,34 @@
1
1
  # Changelog
2
2
 
3
- All notable changes to Nix.js Kit are documented in this file.
3
+ All notable changes to Elur Kit are documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.4.8]
9
+
10
+ ### Changed
11
+
12
+ - **Hydrator split into a separate chunk** — the auto-generated
13
+ `entry-client.ts` now dynamically imports `hydrateIslands` instead of
14
+ statically importing it. Vite emits the hydrator as its own chunk, so
15
+ the initial `entry-client.js` bundle contains only the SPA router
16
+ (~18 KB → ~9 KB gzipped). The hydrator loads on idle via
17
+ `requestIdleCallback`, after the first paint.
18
+
19
+ ## [2.4.7]
20
+
21
+ ### Changed
22
+
23
+ - **Client entry now defers hydration with `requestIdleCallback`** — the
24
+ auto-generated `entry-client.ts` wraps `hydrateIslands(registry)` in
25
+ `requestIdleCallback(hydrate, { timeout: 2000 })` (with a `setTimeout`
26
+ fallback) so the browser can paint the server-rendered HTML before
27
+ hydrating islands. This reduces LCP element render delay on mobile
28
+ devices where the main thread was blocked by synchronous hydration.
29
+ Islands with directive `"load"` already have SSR-rendered DOM, so
30
+ users see content immediately — hydration only adds interactivity.
31
+
8
32
  ## [2.4.6]
9
33
 
10
34
  ### Fixed
package/dist/lib/cli.cjs CHANGED
@@ -211,11 +211,23 @@ function buildEntrySource(islands, outFile, hydrateImport = "@elurjs/kit/island"
211
211
  const islandHydration = registryLines ? `const registry = {
212
212
  ${registryLines}
213
213
  };
214
- hydrateIslands(registry);
215
- document.addEventListener("elur:rendered", () => {
214
+ // Dynamically import the hydrator so Vite splits it into a separate chunk.
215
+ // This keeps the initial entry-client bundle small (router only) the
216
+ // hydrator loads on idle, after the first paint.
217
+ const hydrate = async () => {
218
+ const { hydrateIslands, cleanupHydratedIslands } = await import(${JSON.stringify(hydrateImport)});
216
219
  cleanupHydratedIslands();
217
220
  hydrateIslands(registry);
218
- });
221
+ document.addEventListener("elur:rendered", () => {
222
+ cleanupHydratedIslands();
223
+ hydrateIslands(registry);
224
+ });
225
+ };
226
+ if ("requestIdleCallback" in window) {
227
+ requestIdleCallback(hydrate, { timeout: 2000 });
228
+ } else {
229
+ setTimeout(hydrate, 0);
230
+ }
219
231
 
220
232
  // Vite HMR: when an island module (or the entry itself) updates, dispose the
221
233
  // current islands and re-hydrate from the updated modules — the registry's
@@ -223,8 +235,7 @@ document.addEventListener("elur:rendered", () => {
223
235
  // needed (progressive enhancement, audit §10.2 / §12.2).
224
236
  if (import.meta.hot) {
225
237
  import.meta.hot.accept((newModule) => {
226
- cleanupHydratedIslands();
227
- hydrateIslands(registry);
238
+ hydrate();
228
239
  if (newModule) {
229
240
  // Re-run the module so its side effects (router, listeners) apply.
230
241
  }
@@ -232,7 +243,6 @@ if (import.meta.hot) {
232
243
  }` : "";
233
244
  return `// AUTO-GENERATED by @elurjs/kit. Do not edit.
234
245
  import { startClientRouter } from ${JSON.stringify(routerImport)};
235
- import { hydrateIslands, cleanupHydratedIslands } from ${JSON.stringify(hydrateImport)};
236
246
 
237
247
  startClientRouter();
238
248
  ${islandHydration}