@nifrajs/web 2.2.0 → 2.3.0

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 (163) hide show
  1. package/README.md +3 -3
  2. package/dist/build-vite.d.ts +4 -4
  3. package/dist/build-vite.d.ts.map +1 -1
  4. package/dist/build-vite.js +20 -74
  5. package/dist/build-vite.js.map +1 -1
  6. package/dist/build.d.ts +64 -42
  7. package/dist/build.d.ts.map +1 -1
  8. package/dist/build.js +100 -78
  9. package/dist/build.js.map +1 -1
  10. package/dist/bun-dev-entry.d.ts +1 -1
  11. package/dist/bun-dev-entry.js +1 -1
  12. package/dist/chunk-names.js +1 -1
  13. package/dist/client.d.ts +3 -9
  14. package/dist/client.d.ts.map +1 -1
  15. package/dist/client.js +201 -29
  16. package/dist/client.js.map +1 -1
  17. package/dist/conformance.d.ts +2 -2
  18. package/dist/conformance.js +3 -3
  19. package/dist/deferred.d.ts +11 -11
  20. package/dist/deferred.d.ts.map +1 -1
  21. package/dist/deferred.js +16 -16
  22. package/dist/dev-error.d.ts +2 -2
  23. package/dist/dev-error.js +3 -3
  24. package/dist/dev-port.d.ts +2 -2
  25. package/dist/dev-port.js +1 -1
  26. package/dist/dev.d.ts +3 -3
  27. package/dist/dev.js +9 -9
  28. package/dist/draft.d.ts +12 -12
  29. package/dist/draft.js +11 -11
  30. package/dist/fn-state.d.ts +56 -0
  31. package/dist/fn-state.d.ts.map +1 -0
  32. package/dist/fn-state.js +77 -0
  33. package/dist/fn-state.js.map +1 -0
  34. package/dist/fn.d.ts +111 -0
  35. package/dist/fn.d.ts.map +1 -0
  36. package/dist/fn.js +125 -0
  37. package/dist/fn.js.map +1 -0
  38. package/dist/fonts-google.d.ts +9 -9
  39. package/dist/fonts-google.js +10 -10
  40. package/dist/fonts.d.ts +7 -7
  41. package/dist/fonts.js +1 -1
  42. package/dist/forms.d.ts +8 -8
  43. package/dist/fs.d.ts +1 -1
  44. package/dist/fs.js +1 -1
  45. package/dist/index.d.ts +151 -70
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +317 -139
  48. package/dist/index.js.map +1 -1
  49. package/dist/internal/head-attributes.d.ts +15 -0
  50. package/dist/internal/head-attributes.d.ts.map +1 -0
  51. package/dist/internal/head-attributes.js +99 -0
  52. package/dist/internal/head-attributes.js.map +1 -0
  53. package/dist/internal/script-types.d.ts +14 -0
  54. package/dist/internal/script-types.d.ts.map +1 -0
  55. package/dist/internal/script-types.js +17 -0
  56. package/dist/internal/script-types.js.map +1 -0
  57. package/dist/internal/server-boundary.d.ts +60 -0
  58. package/dist/internal/server-boundary.d.ts.map +1 -0
  59. package/dist/internal/server-boundary.js +174 -0
  60. package/dist/internal/server-boundary.js.map +1 -0
  61. package/dist/internal/timing-safe-equal.d.ts +1 -1
  62. package/dist/internal/timing-safe-equal.js +1 -1
  63. package/dist/internal/vite-import.d.ts +63 -0
  64. package/dist/internal/vite-import.d.ts.map +1 -0
  65. package/dist/internal/vite-import.js +94 -0
  66. package/dist/internal/vite-import.js.map +1 -0
  67. package/dist/islands.d.ts +5 -5
  68. package/dist/islands.js +5 -5
  69. package/dist/isr.d.ts +15 -15
  70. package/dist/isr.js +7 -7
  71. package/dist/manifest.d.ts +73 -35
  72. package/dist/manifest.d.ts.map +1 -1
  73. package/dist/manifest.js +10 -16
  74. package/dist/manifest.js.map +1 -1
  75. package/dist/module-graph.d.ts +5 -5
  76. package/dist/module-graph.js +4 -4
  77. package/dist/navigation.d.ts +120 -5
  78. package/dist/navigation.d.ts.map +1 -1
  79. package/dist/navigation.js +37 -5
  80. package/dist/navigation.js.map +1 -1
  81. package/dist/plugins/css-modules.d.ts +3 -3
  82. package/dist/plugins/css-modules.js +0 -0
  83. package/dist/plugins/kit.d.ts +8 -8
  84. package/dist/plugins/kit.js +9 -9
  85. package/dist/plugins/scss.js +3 -3
  86. package/dist/plugins/vite-leak-guard.d.ts +1 -1
  87. package/dist/plugins/vite-leak-guard.js +1 -1
  88. package/dist/plugins/vite-server-fn.d.ts +23 -0
  89. package/dist/plugins/vite-server-fn.d.ts.map +1 -0
  90. package/dist/plugins/vite-server-fn.js +51 -0
  91. package/dist/plugins/vite-server-fn.js.map +1 -0
  92. package/dist/plugins/vite-server-only.d.ts +49 -0
  93. package/dist/plugins/vite-server-only.d.ts.map +1 -0
  94. package/dist/plugins/vite-server-only.js +57 -0
  95. package/dist/plugins/vite-server-only.js.map +1 -0
  96. package/dist/prerender.d.ts +5 -5
  97. package/dist/prerender.js +7 -7
  98. package/dist/query.d.ts +10 -10
  99. package/dist/query.js +15 -15
  100. package/dist/route-manifest.d.ts +1 -1
  101. package/dist/route-manifest.js +2 -2
  102. package/dist/router.d.ts +30 -21
  103. package/dist/router.d.ts.map +1 -1
  104. package/dist/router.js +57 -28
  105. package/dist/router.js.map +1 -1
  106. package/dist/search.d.ts +94 -0
  107. package/dist/search.d.ts.map +1 -0
  108. package/dist/search.js +232 -0
  109. package/dist/search.js.map +1 -0
  110. package/dist/server-only.d.ts +6 -6
  111. package/dist/server-only.js +7 -7
  112. package/dist/service-worker.d.ts +56 -0
  113. package/dist/service-worker.d.ts.map +1 -0
  114. package/dist/service-worker.js +127 -0
  115. package/dist/service-worker.js.map +1 -0
  116. package/dist/vite.d.ts +15 -13
  117. package/dist/vite.d.ts.map +1 -1
  118. package/dist/vite.js +31 -21
  119. package/dist/vite.js.map +1 -1
  120. package/package.json +33 -4
  121. package/server-manifest.d.ts +31 -0
  122. package/src/build-vite.ts +24 -77
  123. package/src/build.ts +137 -105
  124. package/src/bun-dev-entry.ts +1 -1
  125. package/src/chunk-names.ts +1 -1
  126. package/src/client.ts +215 -32
  127. package/src/conformance.ts +3 -3
  128. package/src/deferred.ts +17 -17
  129. package/src/dev-error.ts +3 -3
  130. package/src/dev-port.ts +2 -2
  131. package/src/dev.ts +12 -12
  132. package/src/draft.ts +15 -15
  133. package/src/fn-state.ts +107 -0
  134. package/src/fn.ts +199 -0
  135. package/src/fonts-google.ts +13 -13
  136. package/src/fonts.ts +7 -7
  137. package/src/forms.ts +8 -8
  138. package/src/fs.ts +2 -2
  139. package/src/index.ts +460 -181
  140. package/src/internal/head-attributes.ts +109 -0
  141. package/src/internal/script-types.ts +18 -0
  142. package/src/internal/server-boundary.ts +187 -0
  143. package/src/internal/timing-safe-equal.ts +1 -1
  144. package/src/internal/vite-import.ts +92 -0
  145. package/src/islands.ts +7 -7
  146. package/src/isr.ts +17 -17
  147. package/src/manifest.ts +83 -42
  148. package/src/module-graph.ts +6 -6
  149. package/src/navigation.ts +151 -5
  150. package/src/plugins/css-modules.ts +0 -0
  151. package/src/plugins/kit.ts +11 -11
  152. package/src/plugins/scss.ts +3 -3
  153. package/src/plugins/vite-leak-guard.ts +2 -2
  154. package/src/plugins/vite-server-fn.ts +67 -0
  155. package/src/plugins/vite-server-only.ts +75 -0
  156. package/src/prerender.ts +10 -10
  157. package/src/query.ts +22 -22
  158. package/src/route-manifest.ts +3 -3
  159. package/src/router.ts +91 -41
  160. package/src/search.ts +297 -0
  161. package/src/server-only.ts +7 -7
  162. package/src/service-worker.ts +165 -0
  163. package/src/vite.ts +41 -29
package/dist/vite.js CHANGED
@@ -1,14 +1,14 @@
1
1
  /**
2
- * `@nifrajs/web/vite` — a **dev-only** server with true HMR, backed by Vite in middleware mode. nifra's
2
+ * `@nifrajs/web/vite` - a **dev-only** server with true HMR, backed by Vite in middleware mode. nifra's
3
3
  * production pipeline stays Bun-native (`@nifrajs/web/build` → `Bun.build`); this is purely for the dev
4
4
  * loop. Bun's own HMR is dev-server-only and DCE's `import.meta.hot` under `Bun.build` (nifra's bundler),
5
5
  * so HMR comes from Vite + the framework's official Vite plugin (React Fast Refresh, Vue/Svelte/Solid
6
- * HMR) — which you inject via `plugins` (the same structural-injection idiom as the Bun/codec plugins).
6
+ * HMR) - which you inject via `plugins` (the same structural-injection idiom as the Bun/codec plugins).
7
7
  *
8
8
  * Flow: Vite serves + HMR-swaps the client modules (nifra's codegen'd entry + the route files); nifra
9
9
  * still **SSRs** each request, and the rendered HTML is run through `vite.transformIndexHtml` so Vite
10
10
  * injects its HMR client + the framework's refresh preamble. Node `http` (not `Bun.serve`) because
11
- * Vite's `middlewares` are Connect-style — it runs fine under Bun.
11
+ * Vite's `middlewares` are Connect-style - it runs fine under Bun.
12
12
  */
13
13
  import { writeFileSync } from "node:fs";
14
14
  import { createServer as createHttpServer, } from "node:http";
@@ -17,6 +17,10 @@ import { renderDevErrorOverlay } from "./dev-error.js";
17
17
  import { listenOrExplain } from "./dev-port.js";
18
18
  import { discoverRoutes } from "./fs.js";
19
19
  import { DEFAULT_DEV_PORT, generateClientEntry } from "./index.js";
20
+ import { vitePublicEnvPrefix } from "./internal/server-boundary.js";
21
+ import { importVite } from "./internal/vite-import.js";
22
+ import { viteServerFnStub } from "./plugins/vite-server-fn.js";
23
+ import { viteServerOnlyEmpty } from "./plugins/vite-server-only.js";
20
24
  // The codegen'd client entry is written here (at the Vite root) so Vite serves + HMRs it.
21
25
  const DEV_ENTRY = ".nifra-vite-entry.tsx";
22
26
  const readNodeBody = async (req) => {
@@ -52,7 +56,7 @@ function toWebRequest(req, body) {
52
56
  }
53
57
  /**
54
58
  * Copy a Web `Response`'s headers onto a Node response, emitting EACH `Set-Cookie` as its own header. The
55
- * `Headers` iterator (and `.get`) join multiple set-cookie values with ", ", which corrupts cookies — e.g.
59
+ * `Headers` iterator (and `.get`) join multiple set-cookie values with ", ", which corrupts cookies - e.g.
56
60
  * better-auth's `session_token` + `session_data` collapse into one unparseable cookie and the session is
57
61
  * silently lost. `getSetCookie()` returns them split; Node's `setHeader` emits one header per array element.
58
62
  */
@@ -68,7 +72,7 @@ export function applyResponseHeaders(headers, res) {
68
72
  }
69
73
  /**
70
74
  * Stream a Web `Response` body to a Node response chunk-by-chunk. Buffering the whole body (e.g.
71
- * `arrayBuffer()`) waits for the stream to END — which an open-ended SSE (`text/event-stream`) body never
75
+ * `arrayBuffer()`) waits for the stream to END - which an open-ended SSE (`text/event-stream`) body never
72
76
  * does, so it hung `nifra dev` (the Bun production server streamed it fine). This flushes each chunk as it
73
77
  * arrives and cancels the reader if the client disconnects; a finite body just streams its chunk(s) + ends.
74
78
  */
@@ -89,22 +93,22 @@ export async function pipeWebBodyToNode(body, res) {
89
93
  }
90
94
  }
91
95
  catch {
92
- // client disconnected mid-stream — the `close` handler already cancelled the reader
96
+ // client disconnected mid-stream - the `close` handler already cancelled the reader
93
97
  }
94
98
  res.end();
95
99
  }
96
100
  /**
97
101
  * Strip `optimizeDeps.rollupOptions.jsx` from a plugin's `config` hook output when running under
98
- * rolldown-vite — the source of the scary, harmless `Warning: Invalid input options … "jsx" Invalid
102
+ * rolldown-vite - the source of the scary, harmless `Warning: Invalid input options … "jsx" Invalid
99
103
  * key: Expected never but received "jsx"` on `nifra dev`.
100
104
  *
101
105
  * Why it happens: `@vitejs/plugin-react@4.x` (and peers) target an *older* rolldown-vite optimizeDeps
102
- * API — they inject `optimizeDeps.rollupOptions.jsx` to tell the dep pre-bundler to transform JSX. Vite
106
+ * API - they inject `optimizeDeps.rollupOptions.jsx` to tell the dep pre-bundler to transform JSX. Vite
103
107
  * 8's rolldown dep-optimizer renamed that surface to `optimizeDeps.rolldownOptions` (and moved jsx under
104
108
  * `transform.jsx`), so the stale `rollupOptions.jsx` is an unrecognized input option → the warning. It's
105
109
  * a version-skew artifact, not a real misconfig: the route source JSX transform runs through the
106
110
  * plugin's own `transform` hook (untouched here), and node_modules deps that get pre-bundled almost
107
- * never contain raw JSX — so dropping the dead key changes no behavior and keeps HMR/Fast Refresh
111
+ * never contain raw JSX - so dropping the dead key changes no behavior and keeps HMR/Fast Refresh
108
112
  * intact. We *strip* (rather than translate to `rolldownOptions`) so the fix is version-agnostic: a
109
113
  * plugin already emitting the correct `rolldownOptions` is left untouched, and a future plugin bump that
110
114
  * stops emitting `rollupOptions.jsx` makes this a no-op.
@@ -112,12 +116,12 @@ export async function pipeWebBodyToNode(body, res) {
112
116
  * Scoped narrowly: only the `optimizeDeps.rollupOptions.jsx` key is removed, only under rolldown-vite,
113
117
  * and only from the value a plugin's `config` hook returns. Non-rolldown Vite is passed through verbatim.
114
118
  *
115
- * FLATTEN FIRST: a Vite plugin factory may return an ARRAY of plugins — `@vitejs/plugin-react`'s `react()`
119
+ * FLATTEN FIRST: a Vite plugin factory may return an ARRAY of plugins - `@vitejs/plugin-react`'s `react()`
116
120
  * returns `[vite:react-babel, vite:react-refresh]`, and it's `react:react-babel`'s `config` hook that emits
117
121
  * the offending `optimizeDeps.rollupOptions.jsx`. `nifra.config.ts` writes `vitePlugins = [react()]`, so the
118
122
  * plugin list arrives NESTED (`[[babel, refresh]]`). Without flattening, `.map` sees the inner array (which
119
- * has no `config`), leaves it untouched, and Vite — which flattens plugin arrays itself before running them
120
- * — then executes the un-stripped babel hook, so the warning survives. Flattening here (Vite accepts a flat
123
+ * has no `config`), leaves it untouched, and Vite - which flattens plugin arrays itself before running them
124
+ * - then executes the un-stripped babel hook, so the warning survives. Flattening here (Vite accepts a flat
121
125
  * list identically) is what lets the strip reach every real plugin.
122
126
  */
123
127
  export function normalizeRolldownPlugins(plugins, isRolldown) {
@@ -149,7 +153,7 @@ export function normalizeRolldownPlugins(plugins, isRolldown) {
149
153
  return plugin;
150
154
  const wrappedHandler = (config, env) => {
151
155
  const returned = handler(config, env);
152
- // The hook may return a promise — normalize both shapes.
156
+ // The hook may return a promise - normalize both shapes.
153
157
  return returned instanceof Promise ? returned.then(stripJsxKey) : stripJsxKey(returned);
154
158
  };
155
159
  // Preserve the ORIGINAL shape: a function stays a function; the object form keeps its `order`
@@ -177,7 +181,7 @@ export async function createViteDevServer(options) {
177
181
  writeClientEntry();
178
182
  const entryUrl = `/${DEV_ENTRY}`;
179
183
  // Create our HTTP server FIRST, then hand it to Vite as the HMR WebSocket host (`hmr.server`). In
180
- // middleware mode Vite would otherwise open a *separate* ws port (24678) — fragile: it conflicts
184
+ // middleware mode Vite would otherwise open a *separate* ws port (24678) - fragile: it conflicts
181
185
  // across restarts ("Port undefined is already in use" → the client never connects). Sharing one
182
186
  // port means HMR rides the same origin as the app, robust across restarts. The handler closes over
183
187
  // `vite`, which is assigned just below before the server starts listening.
@@ -193,7 +197,7 @@ export async function createViteDevServer(options) {
193
197
  const contentType = nifraRes.headers.get("content-type") ?? "";
194
198
  res.statusCode = nifraRes.status;
195
199
  if (!contentType.includes("text/html")) {
196
- // Data / redirect / asset response — pass through untouched, streamed (SSE-safe). Set-Cookie is
200
+ // Data / redirect / asset response - pass through untouched, streamed (SSE-safe). Set-Cookie is
197
201
  // emitted per-header so multi-cookie responses (e.g. better-auth sessions) aren't collapsed.
198
202
  applyResponseHeaders(nifraRes.headers, res);
199
203
  await pipeWebBodyToNode(nifraRes.body, res);
@@ -206,7 +210,7 @@ export async function createViteDevServer(options) {
206
210
  }
207
211
  catch (err) {
208
212
  // Source-map the stack first (Vite maps the bundled frames back to your `.ts`), then render
209
- // the readable dev overlay instead of a bare text dump. Dev-only — production maps to `_error`.
213
+ // the readable dev overlay instead of a bare text dump. Dev-only - production maps to `_error`.
210
214
  if (err instanceof Error)
211
215
  vite.ssrFixStacktrace(err);
212
216
  res.statusCode = 500;
@@ -217,15 +221,19 @@ export async function createViteDevServer(options) {
217
221
  });
218
222
  });
219
223
  // `conditions: ["bun"]` makes Vite resolve nifra's workspace packages (`@nifrajs/web-react/client`, …) to
220
- // their TS **source** — so the dev server needs no prior `dist` build of the adapter packages.
224
+ // their TS **source** - so the dev server needs no prior `dist` build of the adapter packages.
221
225
  const usePolling = options.poll ?? process.env.CHOKIDAR_USEPOLLING === "1";
222
- const viteModule = (await import("vite"));
226
+ // Never `import("vite")` directly here: the guard in `importVite` has to run first, and the dev
227
+ // server importing vite unguarded is precisely what poisoned the module for the whole process.
228
+ const viteModule = await importVite();
223
229
  const { createServer } = viteModule;
224
230
  // Under rolldown-vite (Vite 8+), strip the stale `optimizeDeps.rollupOptions.jsx` some framework
225
- // plugins still emit — it triggers a noisy "Invalid key … jsx" warning but does nothing useful here.
231
+ // plugins still emit - it triggers a noisy "Invalid key … jsx" warning but does nothing useful here.
226
232
  const plugins = normalizeRolldownPlugins(options.plugins ?? [], viteModule.rolldownVersion !== undefined);
227
233
  vite = await createServer({
228
234
  root,
235
+ // Dev must not inherit Vite's default `VITE_*` exposure beside Nifra's documented boundary.
236
+ envPrefix: vitePublicEnvPrefix(options.publicEnvPrefix),
229
237
  ...(options.publicDir !== undefined ? { publicDir: options.publicDir } : {}),
230
238
  appType: "custom",
231
239
  server: {
@@ -234,13 +242,15 @@ export async function createViteDevServer(options) {
234
242
  // Explicit watch config; poll when native fs events aren't delivered (containers/sandboxes).
235
243
  watch: usePolling ? { usePolling: true, interval: 80 } : {},
236
244
  },
237
- plugins: [...plugins],
245
+ // Ahead of the user's plugins: a `*.fn` module must be replaced before anything else
246
+ // reads it, and the dev server is a client bundler like any other.
247
+ plugins: [viteServerFnStub(), viteServerOnlyEmpty(), ...plugins],
238
248
  resolve: {
239
249
  conditions: [...(options.conditions ?? []), "bun", "module", "browser", "development"],
240
250
  // Dedupe React to ONE copy. In a multi-root workspace a shared package can pull react/react-dom
241
251
  // from a SIBLING app's node_modules, so the dev server loads two React cores → a second hook
242
252
  // dispatcher → `resolveDispatcher().useState` null on any hook-using route (the error points at the
243
- // component, not the resolution — brutal to diagnose). Mirrors the build-time reactDedupePlugin so
253
+ // component, not the resolution - brutal to diagnose). Mirrors the build-time reactDedupePlugin so
244
254
  // dev matches prod. No-op for non-React apps (the package simply isn't present to dedupe).
245
255
  dedupe: ["react", "react-dom"],
246
256
  },
package/dist/vite.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vite.js","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACvC,OAAO,EACL,YAAY,IAAI,gBAAgB,GAGjC,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,QAAQ,EAAE,OAAO,IAAI,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,CAAC,CAAA;IACrC,KAAK,MAAM,KAAK,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAU,EAAE,CAAC;QAC/C,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE;YAC9B,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,SAAS,GAAG,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,SAAS,IAAI,CAAC;gBAAE,gBAAgB,EAAE,CAAA;YAC7F,UAAU,EAAE,CAAA;QACd,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,IAAI,CAAC;QACH,MAAM,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACrC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,qGAAqG;QACrG,qGAAqG;QACrG,sGAAsG;QACtG,0EAA0E;QAC1E,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;QAClC,MAAM,GAAG,CAAA;IACX,CAAC;IACD,qGAAqG;IACrG,sGAAsG;IACtG,gFAAgF;IAChF,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,CAAA;IAChC,OAAO;QACL,IAAI,EAAE,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI;QAC3E,IAAI,EAAE,KAAK,IAAI,EAAE;YACf,MAAM,CAAC,KAAK,EAAE,CAAA;YACd,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;QACpB,CAAC;KACF,CAAA;AACH,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nifrajs/web",
3
- "version": "2.2.0",
4
- "description": "Framework-agnostic SSR core for nifra — the render seam + HTML document orchestration.",
3
+ "version": "2.3.0",
4
+ "description": "Framework-agnostic SSR core for nifra - the render seam + HTML document orchestration.",
5
5
  "keywords": [
6
6
  "bun",
7
7
  "typescript",
@@ -54,6 +54,11 @@
54
54
  "types": "./dist/islands.d.ts",
55
55
  "default": "./dist/islands.js"
56
56
  },
57
+ "./service-worker": {
58
+ "bun": "./src/service-worker.ts",
59
+ "types": "./dist/service-worker.d.ts",
60
+ "default": "./dist/service-worker.js"
61
+ },
57
62
  "./server-only": {
58
63
  "bun": "./src/server-only.ts",
59
64
  "types": "./dist/server-only.d.ts",
@@ -121,12 +126,36 @@
121
126
  },
122
127
  "./css-modules": {
123
128
  "types": "./css-modules.d.ts"
129
+ },
130
+ "./server-manifest": {
131
+ "types": "./server-manifest.d.ts"
132
+ },
133
+ "./fn": {
134
+ "bun": "./src/fn.ts",
135
+ "types": "./dist/fn.d.ts",
136
+ "default": "./dist/fn.js"
137
+ },
138
+ "./plugins/vite-server-fn": {
139
+ "bun": "./src/plugins/vite-server-fn.ts",
140
+ "types": "./dist/plugins/vite-server-fn.d.ts",
141
+ "default": "./dist/plugins/vite-server-fn.js"
142
+ },
143
+ "./plugins/vite-server-only": {
144
+ "bun": "./src/plugins/vite-server-only.ts",
145
+ "types": "./dist/plugins/vite-server-only.d.ts",
146
+ "default": "./dist/plugins/vite-server-only.js"
147
+ },
148
+ "./fn-state": {
149
+ "bun": "./src/fn-state.ts",
150
+ "types": "./dist/fn-state.d.ts",
151
+ "default": "./dist/fn-state.js"
124
152
  }
125
153
  },
126
154
  "files": [
127
155
  "dist",
128
156
  "src",
129
- "css-modules.d.ts"
157
+ "css-modules.d.ts",
158
+ "server-manifest.d.ts"
130
159
  ],
131
160
  "sideEffects": false,
132
161
  "scripts": {
@@ -137,7 +166,7 @@
137
166
  "access": "public"
138
167
  },
139
168
  "dependencies": {
140
- "@nifrajs/core": "2.2.0"
169
+ "@nifrajs/core": "2.3.0"
141
170
  },
142
171
  "peerDependencies": {
143
172
  "sass": "^1.0.0",
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Ambient fallback types for a generated `server-manifest` module.
3
+ *
4
+ * `nifra build --target <t>` generates `server-manifest.ts` NEXT TO the server entry at build time, so a
5
+ * HAND-WRITTEN entry that imports `./server-manifest` has nothing to typecheck against until the first
6
+ * build - which is what forces a `@ts-nocheck` onto the very file that deploys. Reference this so the
7
+ * import is typed before then. Either from a `.d.ts` in your project:
8
+ *
9
+ * ```ts
10
+ * /// <reference types="@nifrajs/web/server-manifest" />
11
+ * ```
12
+ *
13
+ * or list it in `tsconfig.json` -> `compilerOptions.types: ["@nifrajs/web/server-manifest"]`.
14
+ *
15
+ * Once a build (or `nifra sync-manifest`) has written the real `server-manifest` next to your entry,
16
+ * TypeScript resolves the relative import to that file and its types win; this only fills the gap before
17
+ * then. Not needed with `nifra build --target`, which generates and bundles its own entry - a hand-written
18
+ * entry is the case this exists for.
19
+ */
20
+
21
+ declare module "*/server-manifest" {
22
+ import type { Manifest } from "@nifrajs/web"
23
+ /** Hashed client-bootstrap URL the entry passes to `createWebApp` (the hydration `<script src>`). */
24
+ export const clientEntry: string
25
+ /** Global stylesheet URLs, emitted as `<link rel="stylesheet">`. */
26
+ export const styles: readonly string[]
27
+ /** Per-route stylesheet URLs, keyed by route-relative source file. */
28
+ export const routeStyles: Readonly<Record<string, readonly string[]>>
29
+ /** The route manifest `createWebApp` renders. */
30
+ export const manifest: Manifest
31
+ }
package/src/build-vite.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * `@nifrajs/web/build-vite` — the **Vite/Rollup production build**: the escape hatch, not the default.
2
+ * `@nifrajs/web/build-vite` - the **Vite/Rollup production build**: the escape hatch, not the default.
3
3
  *
4
4
  * nifra's production default is Bun (`@nifrajs/web/build`), and stays so - it is faster and Bun-native,
5
5
  * which is what nifra competes on. This exists for the one case that default cannot serve: an app whose
@@ -33,10 +33,14 @@ import {
33
33
  } from "./build.ts"
34
34
  import { discoverRoutes } from "./fs.ts"
35
35
  import { generateClientEntry, generateServerManifest } from "./index.ts"
36
+ import { vitePublicEnvPrefix } from "./internal/server-boundary.ts"
37
+ import { importVite, isViteUnresolved } from "./internal/vite-import.ts"
36
38
  import { viteLeakGuard } from "./plugins/vite-leak-guard.ts"
39
+ import { viteServerFnStub } from "./plugins/vite-server-fn.ts"
40
+ import { viteServerOnlyEmpty } from "./plugins/vite-server-only.ts"
37
41
 
38
42
  // ---------------------------------------------------------------------------------------------------
39
- // Structural Vite typings — no hard `vite` dependency (mirrors vite.ts). Only the build API is used.
43
+ // Structural Vite typings - no hard `vite` dependency (mirrors vite.ts). Only the build API is used.
40
44
  // ---------------------------------------------------------------------------------------------------
41
45
 
42
46
  /** One entry in Vite's `.vite/manifest.json`: its emitted file + transitive CSS + imported chunks. */
@@ -53,73 +57,14 @@ interface ViteModule {
53
57
  build(config: Record<string, unknown>): Promise<unknown>
54
58
  }
55
59
 
56
- /**
57
- * Restore V8's `Error.captureStackTrace` contract on a runtime that is stricter than it.
58
- *
59
- * `captureStackTrace` is a V8 API, and V8 decorates ANY object handed to it. Some runtimes instead
60
- * require a real Error - one with the internal slot, which `Object.create(Error.prototype)` and
61
- * `new SubclassWithErrorPrototype()` do NOT have - and throw "First argument must be an Error object".
62
- *
63
- * That breaks importing vite outright. Vite bundles `follow-redirects`, which builds its error types the
64
- * pre-class way:
65
- *
66
- * function CustomError(props) { Error.captureStackTrace(this, this.constructor); … }
67
- * CustomError.prototype = new (baseClass || Error)()
68
- *
69
- * The last line CONSTRUCTS `baseClass` while defining the subclass, so `this` is an object that inherits
70
- * from Error but was never built by it - and the throw happens at module evaluation, before vite exports
71
- * anything. Every Vite build then fails with a message about stack traces, naming nothing about vite.
72
- *
73
- * Decorating a stack is best-effort by definition, so swallowing the rejection loses nothing: the shim
74
- * delegates, and only suppresses the refusal. Installed once, and deliberately not restored - the strict
75
- * behaviour is the deviation, and a library evaluated later would hit the same wall.
76
- */
77
- function relaxCaptureStackTrace(): void {
78
- const strict = Error.captureStackTrace
79
- if (
80
- typeof strict !== "function" ||
81
- Object.prototype.toString.call(new Error()) !== "[object Error]"
82
- ) {
83
- return
84
- }
85
- // Probe rather than sniff a version: construct exactly what follow-redirects does and see if it is
86
- // refused. A runtime that already follows V8 keeps its own implementation untouched.
87
- const inherited = Object.create(Error.prototype)
88
- try {
89
- strict.call(Error, inherited)
90
- return // permissive already - nothing to fix
91
- } catch {
92
- // stricter than V8; fall through and wrap
93
- }
94
- try {
95
- Error.captureStackTrace = ((target: object, constructorOpt?: unknown) => {
96
- try {
97
- ;(strict as (t: object, c?: unknown) => void).call(Error, target, constructorOpt)
98
- } catch {
99
- // The runtime refused to decorate this object. A missing `.stack` is not worth failing over.
100
- }
101
- }) as typeof Error.captureStackTrace
102
- } catch {
103
- // The property is frozen or non-writable. Nothing can be done about the import that follows, but
104
- // failing HERE would replace vite's own error with an assignment error - strictly less informative
105
- // than letting the import fail and be reported by `loadVite`.
106
- }
107
- }
108
-
109
60
  /** Load the app's Vite. Resolved from `root` so it's the project's copy, not this package's. */
110
61
  async function loadVite(): Promise<ViteModule> {
111
- relaxCaptureStackTrace()
112
62
  try {
113
- return (await import("vite")) as unknown as ViteModule
63
+ return await importVite<ViteModule>()
114
64
  } catch (cause) {
115
- // Two different failures arrive here and must not be conflated. `vite` is an OPTIONAL peer, so a
116
- // project without it fails to RESOLVE - the common case, and the one worth naming. But vite can
117
- // also resolve and fail while EVALUATING, which is not a missing dependency at all: vite 8 loads
118
- // rolldown's native binding on import, and a binding that will not load surfaces here too. Telling
119
- // that user to install what they already installed sends them the wrong way, so only a resolution
120
- // failure claims a missing package; anything else is reported as what it is.
65
+ // The two failures must not be conflated - see `isViteUnresolved`.
121
66
  const message = cause instanceof Error ? cause.message : String(cause)
122
- const unresolved = /cannot find (?:package|module)|ERR_MODULE_NOT_FOUND/i.test(message)
67
+ const unresolved = isViteUnresolved(cause)
123
68
  throw new Error(
124
69
  unresolved
125
70
  ? "[nifra/web] the Vite production build needs `vite` installed in this project (it is an " +
@@ -160,7 +105,7 @@ async function withSerializedNodeEnv<T>(mode: string, run: () => Promise<T>): Pr
160
105
  }
161
106
  }
162
107
 
163
- /** Options for {@link buildClientVite} — the Bun {@link BuildClientOptions} minus Bun-plugin specifics,
108
+ /** Options for {@link buildClientVite} - the Bun {@link BuildClientOptions} minus Bun-plugin specifics,
164
109
  * plus the Vite plugin list the app injects for its transforms. */
165
110
  export interface BuildClientViteOptions extends Omit<BuildClientOptions, "plugins"> {
166
111
  /** Vite plugins for the app's client transforms (e.g. `react()`, `vue()`). */
@@ -195,7 +140,7 @@ export async function buildClientVite(options: BuildClientViteOptions): Promise<
195
140
  `globalThis.process ??= { env: {} };\n${generateClientEntry(routeManifest, { clientModule, resolve })}`,
196
141
  )
197
142
 
198
- // Every unique route/layout/_404 file — each an additional entry so Vite emits a named chunk per file
143
+ // Every unique route/layout/_404 file - each an additional entry so Vite emits a named chunk per file
199
144
  // the bootstrap's lazy import dedupes to, giving the per-route chunk + CSS mapping below.
200
145
  const routeFiles = [
201
146
  ...new Set([
@@ -205,7 +150,7 @@ export async function buildClientVite(options: BuildClientViteOptions): Promise<
205
150
  ]),
206
151
  ].sort()
207
152
 
208
- // Vite manifest keys are the input path RELATIVE TO ROOT — precompute them so the lookup below is exact
153
+ // Vite manifest keys are the input path RELATIVE TO ROOT - precompute them so the lookup below is exact
209
154
  // (survives same-basename collisions like `index.tsx` + `blog/index.tsx`).
210
155
  const keyOf = (absPath: string): string => relative(root, absPath).replaceAll("\\", "/")
211
156
  const entryKey = keyOf(entryFile)
@@ -214,7 +159,7 @@ export async function buildClientVite(options: BuildClientViteOptions): Promise<
214
159
  for (const file of routeFiles) {
215
160
  const abs = resolvePath(resolve(file))
216
161
  // FLAT input names (no `/`), so Vite emits `routes_index_tsx-HASH.js` in `outDir` directly, not a
217
- // nested `routes/…` dir — the deploy assembly + size report map asset URLs by basename and expect a
162
+ // nested `routes/…` dir - the deploy assembly + size report map asset URLs by basename and expect a
218
163
  // flat layout. The manifest LOOKUP below is keyed by the src path (`keyOf`), independent of this name.
219
164
  input[keyOf(abs).replace(/[^\w]/g, "_")] = abs
220
165
  fileKey.set(file, keyOf(abs))
@@ -236,6 +181,8 @@ export async function buildClientVite(options: BuildClientViteOptions): Promise<
236
181
  root,
237
182
  base: publicPath,
238
183
  mode,
184
+ // Override Vite's independent `VITE_*` boundary; Nifra has one public-env policy.
185
+ envPrefix: vitePublicEnvPrefix(options.publicEnvPrefix),
239
186
  logLevel: "silent",
240
187
  // Nifra owns publicDir copying so direct and target builds share symlink confinement and
241
188
  // deploy-root placement. Vite's automatic copy would put root files inside /assets.
@@ -265,8 +212,8 @@ export async function buildClientVite(options: BuildClientViteOptions): Promise<
265
212
  // without this. External here means the guard fails the build (below) with the exact builtin.
266
213
  external: [/^node:/],
267
214
  input,
268
- // The leak guard is a Rollup plugin — last, so it sees the final graph.
269
- plugins: [leakGuard],
215
+ // The leak guard is a Rollup plugin - last, so it sees the final graph.
216
+ plugins: [viteServerFnStub(), viteServerOnlyEmpty(), leakGuard],
270
217
  output: {
271
218
  entryFileNames: "[name]-[hash].js",
272
219
  chunkFileNames: "[name]-[hash].js",
@@ -325,7 +272,7 @@ export async function buildClientVite(options: BuildClientViteOptions): Promise<
325
272
  routes._404 = c !== undefined ? [c] : []
326
273
  }
327
274
 
328
- // CSS per route — Vite's manifest `css` is the transitive stylesheet set for that entry.
275
+ // CSS per route - Vite's manifest `css` is the transitive stylesheet set for that entry.
329
276
  const stylesFor = (files: readonly string[]): readonly string[] => {
330
277
  const urls = new Set<string>()
331
278
  for (const file of files) {
@@ -335,7 +282,7 @@ export async function buildClientVite(options: BuildClientViteOptions): Promise<
335
282
  }
336
283
  return [...urls]
337
284
  }
338
- // CSS aggregate — every stylesheet the app emits, the always-safe fallback.
285
+ // CSS aggregate - every stylesheet the app emits, the always-safe fallback.
339
286
  const allCss = new Set<string>()
340
287
  for (const entry of Object.values(viteManifest)) {
341
288
  for (const css of entry.css ?? []) allCss.add(url(css))
@@ -347,7 +294,7 @@ export async function buildClientVite(options: BuildClientViteOptions): Promise<
347
294
  if (routeManifest.notFound) routeStyles._404 = stylesFor([routeManifest.notFound.file])
348
295
  }
349
296
 
350
- // assets — every emitted file + stylesheet across the manifest (chunks, entries, css).
297
+ // assets - every emitted file + stylesheet across the manifest (chunks, entries, css).
351
298
  const assets = new Set<string>()
352
299
  for (const entry of Object.values(viteManifest)) {
353
300
  assets.add(url(entry.file))
@@ -371,7 +318,7 @@ export async function buildClientVite(options: BuildClientViteOptions): Promise<
371
318
  return manifest
372
319
  }
373
320
 
374
- /** Options for {@link buildServerVite} — the same surface as `buildServer` minus Bun-plugin specifics. */
321
+ /** Options for {@link buildServerVite} - the same surface as `buildServer` minus Bun-plugin specifics. */
375
322
  export interface BuildServerViteOptions {
376
323
  readonly routesDir: string
377
324
  readonly serverEntry: string
@@ -385,7 +332,7 @@ export interface BuildServerViteOptions {
385
332
  readonly conditions?: readonly string[]
386
333
  readonly define?: Readonly<Record<string, string>>
387
334
  readonly minify?: boolean
388
- /** The runtime the worker targets — mirrors `buildServer`. `browser` = the edge (workerd/edge-light). */
335
+ /** The runtime the worker targets - mirrors `buildServer`. `browser` = the edge (workerd/edge-light). */
389
336
  readonly target?: "browser" | "node" | "bun"
390
337
  /** Vite project root (default: the parent of `routesDir`). */
391
338
  readonly root?: string
@@ -490,7 +437,7 @@ export async function buildServerVite(options: BuildServerViteOptions): Promise<
490
437
  generateServerManifest(routeManifest, { resolve, clientEntry, styles, routeStyles }),
491
438
  )
492
439
 
493
- // Pin the mode to match NODE_ENV — the react plugin's JSX runtime (jsx vs jsxDEV) follows it, and a
440
+ // Pin the mode to match NODE_ENV - the react plugin's JSX runtime (jsx vs jsxDEV) follows it, and a
494
441
  // mismatch throws `jsxDEV is not a function` at SSR (see buildClientVite for the full reasoning).
495
442
  const mode = options.minify === false ? "development" : "production"
496
443
  const vite = await loadVite()
@@ -560,7 +507,7 @@ export async function buildServerVite(options: BuildServerViteOptions): Promise<
560
507
  }
561
508
 
562
509
  /**
563
- * The Vite build STRATEGY — plugged into `buildTargetWith`. `plugins` arriving through the shared
510
+ * The Vite build STRATEGY - plugged into `buildTargetWith`. `plugins` arriving through the shared
564
511
  * orchestrator are the app's Vite plugins (the escape hatch's whole reason), cast to Vite's plugin type.
565
512
  */
566
513
  export const viteBundler: Bundler = {