@elurjs/kit 2.4.7 → 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
@@ -5,6 +5,17 @@ All notable changes to Elur Kit are documented in this file.
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
+
8
19
  ## [2.4.7]
9
20
 
10
21
  ### Changed
package/dist/lib/cli.cjs CHANGED
@@ -211,19 +211,23 @@ function buildEntrySource(islands, outFile, hydrateImport = "@elurjs/kit/island"
211
211
  const islandHydration = registryLines ? `const registry = {
212
212
  ${registryLines}
213
213
  };
214
- // Defer hydration until the browser is idle so the first paint is not
215
- // blocked. Islands with directive "load" already have SSR-rendered DOM,
216
- // so the user sees content immediately hydration only adds interactivity.
217
- const hydrate = () => hydrateIslands(registry);
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)});
219
+ cleanupHydratedIslands();
220
+ hydrateIslands(registry);
221
+ document.addEventListener("elur:rendered", () => {
222
+ cleanupHydratedIslands();
223
+ hydrateIslands(registry);
224
+ });
225
+ };
218
226
  if ("requestIdleCallback" in window) {
219
227
  requestIdleCallback(hydrate, { timeout: 2000 });
220
228
  } else {
221
229
  setTimeout(hydrate, 0);
222
230
  }
223
- document.addEventListener("elur:rendered", () => {
224
- cleanupHydratedIslands();
225
- hydrateIslands(registry);
226
- });
227
231
 
228
232
  // Vite HMR: when an island module (or the entry itself) updates, dispose the
229
233
  // current islands and re-hydrate from the updated modules — the registry's
@@ -231,8 +235,7 @@ document.addEventListener("elur:rendered", () => {
231
235
  // needed (progressive enhancement, audit §10.2 / §12.2).
232
236
  if (import.meta.hot) {
233
237
  import.meta.hot.accept((newModule) => {
234
- cleanupHydratedIslands();
235
- hydrateIslands(registry);
238
+ hydrate();
236
239
  if (newModule) {
237
240
  // Re-run the module so its side effects (router, listeners) apply.
238
241
  }
@@ -240,7 +243,6 @@ if (import.meta.hot) {
240
243
  }` : "";
241
244
  return `// AUTO-GENERATED by @elurjs/kit. Do not edit.
242
245
  import { startClientRouter } from ${JSON.stringify(routerImport)};
243
- import { hydrateIslands, cleanupHydratedIslands } from ${JSON.stringify(hydrateImport)};
244
246
 
245
247
  startClientRouter();
246
248
  ${islandHydration}