@nifrajs/web 2.1.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.
- package/README.md +3 -3
- package/dist/build-vite.d.ts +68 -0
- package/dist/build-vite.d.ts.map +1 -0
- package/dist/build-vite.js +433 -0
- package/dist/build-vite.js.map +1 -0
- package/dist/build.d.ts +174 -65
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +376 -135
- package/dist/build.js.map +1 -1
- package/dist/bun-dev-entry.d.ts +83 -0
- package/dist/bun-dev-entry.d.ts.map +1 -0
- package/dist/bun-dev-entry.js +136 -0
- package/dist/bun-dev-entry.js.map +1 -0
- package/dist/chunk-names.js +1 -1
- package/dist/client.d.ts +3 -9
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +209 -27
- package/dist/client.js.map +1 -1
- package/dist/conformance.d.ts +2 -2
- package/dist/conformance.js +3 -3
- package/dist/deferred.d.ts +11 -11
- package/dist/deferred.d.ts.map +1 -1
- package/dist/deferred.js +16 -16
- package/dist/dev-error.d.ts +2 -2
- package/dist/dev-error.js +3 -3
- package/dist/dev-port.d.ts +36 -0
- package/dist/dev-port.d.ts.map +1 -0
- package/dist/dev-port.js +48 -0
- package/dist/dev-port.js.map +1 -0
- package/dist/dev.d.ts +62 -5
- package/dist/dev.d.ts.map +1 -1
- package/dist/dev.js +419 -60
- package/dist/dev.js.map +1 -1
- package/dist/draft.d.ts +44 -7
- package/dist/draft.d.ts.map +1 -1
- package/dist/draft.js +92 -9
- package/dist/draft.js.map +1 -1
- package/dist/fn-state.d.ts +56 -0
- package/dist/fn-state.d.ts.map +1 -0
- package/dist/fn-state.js +77 -0
- package/dist/fn-state.js.map +1 -0
- package/dist/fn.d.ts +111 -0
- package/dist/fn.d.ts.map +1 -0
- package/dist/fn.js +125 -0
- package/dist/fn.js.map +1 -0
- package/dist/fonts-google.d.ts +9 -9
- package/dist/fonts-google.js +10 -10
- package/dist/fonts.d.ts +7 -7
- package/dist/fonts.js +1 -1
- package/dist/forms.d.ts +8 -8
- package/dist/fs.d.ts +15 -2
- package/dist/fs.d.ts.map +1 -1
- package/dist/fs.js +8 -2
- package/dist/fs.js.map +1 -1
- package/dist/index.d.ts +266 -74
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +869 -179
- package/dist/index.js.map +1 -1
- package/dist/internal/head-attributes.d.ts +15 -0
- package/dist/internal/head-attributes.d.ts.map +1 -0
- package/dist/internal/head-attributes.js +99 -0
- package/dist/internal/head-attributes.js.map +1 -0
- package/dist/internal/script-types.d.ts +14 -0
- package/dist/internal/script-types.d.ts.map +1 -0
- package/dist/internal/script-types.js +17 -0
- package/dist/internal/script-types.js.map +1 -0
- package/dist/internal/server-boundary.d.ts +60 -0
- package/dist/internal/server-boundary.d.ts.map +1 -0
- package/dist/internal/server-boundary.js +174 -0
- package/dist/internal/server-boundary.js.map +1 -0
- package/dist/internal/timing-safe-equal.d.ts +16 -0
- package/dist/internal/timing-safe-equal.d.ts.map +1 -0
- package/dist/internal/timing-safe-equal.js +26 -0
- package/dist/internal/timing-safe-equal.js.map +1 -0
- package/dist/internal/vite-import.d.ts +63 -0
- package/dist/internal/vite-import.d.ts.map +1 -0
- package/dist/internal/vite-import.js +94 -0
- package/dist/internal/vite-import.js.map +1 -0
- package/dist/islands.d.ts +5 -5
- package/dist/islands.js +5 -5
- package/dist/isr.d.ts +15 -15
- package/dist/isr.d.ts.map +1 -1
- package/dist/isr.js +8 -21
- package/dist/isr.js.map +1 -1
- package/dist/llms-txt.d.ts.map +1 -1
- package/dist/llms-txt.js +12 -6
- package/dist/llms-txt.js.map +1 -1
- package/dist/manifest.d.ts +121 -40
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +136 -26
- package/dist/manifest.js.map +1 -1
- package/dist/module-graph.d.ts +91 -0
- package/dist/module-graph.d.ts.map +1 -0
- package/dist/module-graph.js +92 -0
- package/dist/module-graph.js.map +1 -0
- package/dist/navigation.d.ts +120 -5
- package/dist/navigation.d.ts.map +1 -1
- package/dist/navigation.js +37 -5
- package/dist/navigation.js.map +1 -1
- package/dist/plugins/css-modules.d.ts +3 -3
- package/dist/plugins/css-modules.d.ts.map +1 -1
- package/dist/plugins/css-modules.js +0 -0
- package/dist/plugins/css-modules.js.map +1 -1
- package/dist/plugins/kit.d.ts +8 -8
- package/dist/plugins/kit.js +9 -9
- package/dist/plugins/scss.js +3 -3
- package/dist/plugins/vite-leak-guard.d.ts +45 -0
- package/dist/plugins/vite-leak-guard.d.ts.map +1 -0
- package/dist/plugins/vite-leak-guard.js +67 -0
- package/dist/plugins/vite-leak-guard.js.map +1 -0
- package/dist/plugins/vite-server-fn.d.ts +23 -0
- package/dist/plugins/vite-server-fn.d.ts.map +1 -0
- package/dist/plugins/vite-server-fn.js +51 -0
- package/dist/plugins/vite-server-fn.js.map +1 -0
- package/dist/plugins/vite-server-only.d.ts +49 -0
- package/dist/plugins/vite-server-only.d.ts.map +1 -0
- package/dist/plugins/vite-server-only.js +57 -0
- package/dist/plugins/vite-server-only.js.map +1 -0
- package/dist/prerender.d.ts +5 -5
- package/dist/prerender.js +7 -7
- package/dist/public-dir.d.ts +36 -0
- package/dist/public-dir.d.ts.map +1 -0
- package/dist/public-dir.js +89 -0
- package/dist/public-dir.js.map +1 -0
- package/dist/query.d.ts +10 -10
- package/dist/query.js +15 -15
- package/dist/route-manifest.d.ts +91 -0
- package/dist/route-manifest.d.ts.map +1 -0
- package/dist/route-manifest.js +128 -0
- package/dist/route-manifest.js.map +1 -0
- package/dist/router.d.ts +94 -22
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +170 -58
- package/dist/router.js.map +1 -1
- package/dist/search.d.ts +94 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +232 -0
- package/dist/search.js.map +1 -0
- package/dist/server-only.d.ts +6 -6
- package/dist/server-only.js +7 -7
- package/dist/service-worker.d.ts +56 -0
- package/dist/service-worker.d.ts.map +1 -0
- package/dist/service-worker.js +127 -0
- package/dist/service-worker.js.map +1 -0
- package/dist/vite.d.ts +25 -17
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +75 -33
- package/dist/vite.js.map +1 -1
- package/package.json +48 -4
- package/server-manifest.d.ts +31 -0
- package/src/build-vite.ts +553 -0
- package/src/build.ts +563 -172
- package/src/bun-dev-entry.ts +184 -0
- package/src/chunk-names.ts +1 -1
- package/src/client.ts +221 -30
- package/src/conformance.ts +3 -3
- package/src/deferred.ts +17 -17
- package/src/dev-error.ts +3 -3
- package/src/dev-port.ts +63 -0
- package/src/dev.ts +468 -66
- package/src/draft.ts +124 -12
- package/src/fn-state.ts +107 -0
- package/src/fn.ts +199 -0
- package/src/fonts-google.ts +13 -13
- package/src/fonts.ts +7 -7
- package/src/forms.ts +8 -8
- package/src/fs.ts +24 -6
- package/src/index.ts +1174 -225
- package/src/internal/head-attributes.ts +109 -0
- package/src/internal/script-types.ts +18 -0
- package/src/internal/server-boundary.ts +187 -0
- package/src/internal/timing-safe-equal.ts +24 -0
- package/src/internal/vite-import.ts +92 -0
- package/src/islands.ts +7 -7
- package/src/isr.ts +18 -30
- package/src/llms-txt.ts +13 -5
- package/src/manifest.ts +264 -48
- package/src/module-graph.ts +146 -0
- package/src/navigation.ts +151 -5
- package/src/plugins/css-modules.ts +0 -0
- package/src/plugins/kit.ts +11 -11
- package/src/plugins/scss.ts +3 -3
- package/src/plugins/vite-leak-guard.ts +110 -0
- package/src/plugins/vite-server-fn.ts +67 -0
- package/src/plugins/vite-server-only.ts +75 -0
- package/src/prerender.ts +10 -10
- package/src/public-dir.ts +108 -0
- package/src/query.ts +22 -22
- package/src/route-manifest.ts +240 -0
- package/src/router.ts +288 -74
- package/src/search.ts +297 -0
- package/src/server-only.ts +7 -7
- package/src/service-worker.ts +165 -0
- package/src/vite.ts +103 -49
package/dist/vite.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Minimal app surface
|
|
1
|
+
/** Minimal app surface - `createWebApp(...)` satisfies it. */
|
|
2
2
|
interface FetchApp {
|
|
3
3
|
fetch(request: Request): Response | Promise<Response>;
|
|
4
4
|
}
|
|
@@ -8,15 +8,19 @@ export interface ViteDevServerOptions {
|
|
|
8
8
|
/** Client runtime module providing `mountRouter` (e.g. `"@nifrajs/web-react/client"`). */
|
|
9
9
|
readonly clientModule: string;
|
|
10
10
|
/**
|
|
11
|
-
* Build the nifra app for the given dev client-entry URL.
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* Build the nifra app for the given dev client-entry URL.
|
|
12
|
+
*
|
|
13
|
+
* `load` resolves a route module through **Vite's** graph (`ssrLoadModule`). Pass it to
|
|
14
|
+
* `discoverRoutes(routesDir, { load })` so SSR and the client are resolved by the SAME toolchain.
|
|
15
|
+
* Without it SSR resolves through Bun while the client resolves through Vite - two resolvers, one
|
|
16
|
+
* process - which is what makes `resolve.dedupe` fail to reach SSR and produces the dual-React
|
|
17
|
+
* crash. Vite re-evaluates on change, so no `importQuery` cache-buster is needed alongside it.
|
|
14
18
|
*/
|
|
15
|
-
readonly createApp: (clientEntry: string,
|
|
16
|
-
/** Vite plugins
|
|
19
|
+
readonly createApp: (clientEntry: string, load: (absolutePath: string) => Promise<unknown>) => FetchApp | Promise<FetchApp>;
|
|
20
|
+
/** Vite plugins - inject your framework's official plugin, e.g. `[react()]`. */
|
|
17
21
|
readonly plugins?: readonly unknown[];
|
|
18
22
|
/**
|
|
19
|
-
* Extra `resolve.conditions` prepended ahead of nifra's defaults
|
|
23
|
+
* Extra `resolve.conditions` prepended ahead of nifra's defaults - some frameworks need their own
|
|
20
24
|
* (e.g. Solid's `"solid"` condition routes `solid-js` to its source/JSX-dev build).
|
|
21
25
|
*/
|
|
22
26
|
readonly conditions?: readonly string[];
|
|
@@ -31,16 +35,20 @@ export interface ViteDevServerOptions {
|
|
|
31
35
|
readonly port?: number;
|
|
32
36
|
/**
|
|
33
37
|
* Use polling for the file watcher. Native fs events (fsevents/inotify) are unreliable inside
|
|
34
|
-
* containers, networked filesystems, and some sandboxes
|
|
38
|
+
* containers, networked filesystems, and some sandboxes - there, HMR silently never fires. Set
|
|
35
39
|
* `true` (or the env var `CHOKIDAR_USEPOLLING=1`) to poll instead. Default: off (native events).
|
|
36
40
|
*/
|
|
37
41
|
readonly poll?: boolean;
|
|
42
|
+
/** Vite public directory. Defaults to `<root>/public`; `false` disables it. */
|
|
43
|
+
readonly publicDir?: string | false;
|
|
44
|
+
/** Client-visible environment prefix (default `"PUBLIC_"`; empty disables exposure). */
|
|
45
|
+
readonly publicEnvPrefix?: string;
|
|
38
46
|
}
|
|
39
47
|
export interface ViteDevServer {
|
|
40
48
|
readonly port: number;
|
|
41
49
|
stop(): Promise<void>;
|
|
42
50
|
}
|
|
43
|
-
/** The bits of a Node ServerResponse `pipeWebBodyToNode` touches
|
|
51
|
+
/** The bits of a Node ServerResponse `pipeWebBodyToNode` touches - structural, to avoid a node:http dep here. */
|
|
44
52
|
interface NodeResLike {
|
|
45
53
|
flushHeaders?(): void;
|
|
46
54
|
on(event: "close", cb: () => void): void;
|
|
@@ -53,30 +61,30 @@ interface NodeHeaderSink {
|
|
|
53
61
|
}
|
|
54
62
|
/**
|
|
55
63
|
* Copy a Web `Response`'s headers onto a Node response, emitting EACH `Set-Cookie` as its own header. The
|
|
56
|
-
* `Headers` iterator (and `.get`) join multiple set-cookie values with ", ", which corrupts cookies
|
|
64
|
+
* `Headers` iterator (and `.get`) join multiple set-cookie values with ", ", which corrupts cookies - e.g.
|
|
57
65
|
* better-auth's `session_token` + `session_data` collapse into one unparseable cookie and the session is
|
|
58
66
|
* silently lost. `getSetCookie()` returns them split; Node's `setHeader` emits one header per array element.
|
|
59
67
|
*/
|
|
60
68
|
export declare function applyResponseHeaders(headers: Headers, res: NodeHeaderSink): void;
|
|
61
69
|
/**
|
|
62
70
|
* Stream a Web `Response` body to a Node response chunk-by-chunk. Buffering the whole body (e.g.
|
|
63
|
-
* `arrayBuffer()`) waits for the stream to END
|
|
71
|
+
* `arrayBuffer()`) waits for the stream to END - which an open-ended SSE (`text/event-stream`) body never
|
|
64
72
|
* does, so it hung `nifra dev` (the Bun production server streamed it fine). This flushes each chunk as it
|
|
65
73
|
* arrives and cancels the reader if the client disconnects; a finite body just streams its chunk(s) + ends.
|
|
66
74
|
*/
|
|
67
75
|
export declare function pipeWebBodyToNode(body: ReadableStream<Uint8Array> | null, res: NodeResLike): Promise<void>;
|
|
68
76
|
/**
|
|
69
77
|
* Strip `optimizeDeps.rollupOptions.jsx` from a plugin's `config` hook output when running under
|
|
70
|
-
* rolldown-vite
|
|
78
|
+
* rolldown-vite - the source of the scary, harmless `Warning: Invalid input options … "jsx" Invalid
|
|
71
79
|
* key: Expected never but received "jsx"` on `nifra dev`.
|
|
72
80
|
*
|
|
73
81
|
* Why it happens: `@vitejs/plugin-react@4.x` (and peers) target an *older* rolldown-vite optimizeDeps
|
|
74
|
-
* API
|
|
82
|
+
* API - they inject `optimizeDeps.rollupOptions.jsx` to tell the dep pre-bundler to transform JSX. Vite
|
|
75
83
|
* 8's rolldown dep-optimizer renamed that surface to `optimizeDeps.rolldownOptions` (and moved jsx under
|
|
76
84
|
* `transform.jsx`), so the stale `rollupOptions.jsx` is an unrecognized input option → the warning. It's
|
|
77
85
|
* a version-skew artifact, not a real misconfig: the route source JSX transform runs through the
|
|
78
86
|
* plugin's own `transform` hook (untouched here), and node_modules deps that get pre-bundled almost
|
|
79
|
-
* never contain raw JSX
|
|
87
|
+
* never contain raw JSX - so dropping the dead key changes no behavior and keeps HMR/Fast Refresh
|
|
80
88
|
* intact. We *strip* (rather than translate to `rolldownOptions`) so the fix is version-agnostic: a
|
|
81
89
|
* plugin already emitting the correct `rolldownOptions` is left untouched, and a future plugin bump that
|
|
82
90
|
* stops emitting `rollupOptions.jsx` makes this a no-op.
|
|
@@ -84,12 +92,12 @@ export declare function pipeWebBodyToNode(body: ReadableStream<Uint8Array> | nul
|
|
|
84
92
|
* Scoped narrowly: only the `optimizeDeps.rollupOptions.jsx` key is removed, only under rolldown-vite,
|
|
85
93
|
* and only from the value a plugin's `config` hook returns. Non-rolldown Vite is passed through verbatim.
|
|
86
94
|
*
|
|
87
|
-
* FLATTEN FIRST: a Vite plugin factory may return an ARRAY of plugins
|
|
95
|
+
* FLATTEN FIRST: a Vite plugin factory may return an ARRAY of plugins - `@vitejs/plugin-react`'s `react()`
|
|
88
96
|
* returns `[vite:react-babel, vite:react-refresh]`, and it's `react:react-babel`'s `config` hook that emits
|
|
89
97
|
* the offending `optimizeDeps.rollupOptions.jsx`. `nifra.config.ts` writes `vitePlugins = [react()]`, so the
|
|
90
98
|
* plugin list arrives NESTED (`[[babel, refresh]]`). Without flattening, `.map` sees the inner array (which
|
|
91
|
-
* has no `config`), leaves it untouched, and Vite
|
|
92
|
-
*
|
|
99
|
+
* has no `config`), leaves it untouched, and Vite - which flattens plugin arrays itself before running them
|
|
100
|
+
* - then executes the un-stripped babel hook, so the warning survives. Flattening here (Vite accepts a flat
|
|
93
101
|
* list identically) is what lets the strip reach every real plugin.
|
|
94
102
|
*/
|
|
95
103
|
export declare function normalizeRolldownPlugins(plugins: readonly unknown[], isRolldown: boolean): readonly unknown[];
|
package/dist/vite.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AA4BA,8DAA8D;AAC9D,UAAU,QAAQ;IAChB,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;CACtD;AAuBD,MAAM,WAAW,oBAAoB;IACnC,4DAA4D;IAC5D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,0FAA0F;IAC1F,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B;;;;;;;;OAQG;IACH,QAAQ,C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AAS,MAAM,EAAE,GAAG,IAAI,CAAA;CACjE;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,GAAG,IAAI,CAOhF;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,IAAI,EACvC,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,IAAI,CAAC,CAkBf;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,SAAS,OAAO,EAAE,EAC3B,UAAU,EAAE,OAAO,GAClB,SAAS,OAAO,EAAE,CAkCpB;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,aAAa,CAAC,CA8I/F"}
|
package/dist/vite.js
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `@nifrajs/web/vite`
|
|
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)
|
|
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
|
|
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";
|
|
15
15
|
import { relative, resolve as resolvePath } from "node:path";
|
|
16
16
|
import { renderDevErrorOverlay } from "./dev-error.js";
|
|
17
|
+
import { listenOrExplain } from "./dev-port.js";
|
|
17
18
|
import { discoverRoutes } from "./fs.js";
|
|
18
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";
|
|
19
24
|
// The codegen'd client entry is written here (at the Vite root) so Vite serves + HMRs it.
|
|
20
25
|
const DEV_ENTRY = ".nifra-vite-entry.tsx";
|
|
21
26
|
const readNodeBody = async (req) => {
|
|
@@ -51,7 +56,7 @@ function toWebRequest(req, body) {
|
|
|
51
56
|
}
|
|
52
57
|
/**
|
|
53
58
|
* Copy a Web `Response`'s headers onto a Node response, emitting EACH `Set-Cookie` as its own header. The
|
|
54
|
-
* `Headers` iterator (and `.get`) join multiple set-cookie values with ", ", which corrupts cookies
|
|
59
|
+
* `Headers` iterator (and `.get`) join multiple set-cookie values with ", ", which corrupts cookies - e.g.
|
|
55
60
|
* better-auth's `session_token` + `session_data` collapse into one unparseable cookie and the session is
|
|
56
61
|
* silently lost. `getSetCookie()` returns them split; Node's `setHeader` emits one header per array element.
|
|
57
62
|
*/
|
|
@@ -67,7 +72,7 @@ export function applyResponseHeaders(headers, res) {
|
|
|
67
72
|
}
|
|
68
73
|
/**
|
|
69
74
|
* Stream a Web `Response` body to a Node response chunk-by-chunk. Buffering the whole body (e.g.
|
|
70
|
-
* `arrayBuffer()`) waits for the stream to END
|
|
75
|
+
* `arrayBuffer()`) waits for the stream to END - which an open-ended SSE (`text/event-stream`) body never
|
|
71
76
|
* does, so it hung `nifra dev` (the Bun production server streamed it fine). This flushes each chunk as it
|
|
72
77
|
* arrives and cancels the reader if the client disconnects; a finite body just streams its chunk(s) + ends.
|
|
73
78
|
*/
|
|
@@ -88,22 +93,22 @@ export async function pipeWebBodyToNode(body, res) {
|
|
|
88
93
|
}
|
|
89
94
|
}
|
|
90
95
|
catch {
|
|
91
|
-
// client disconnected mid-stream
|
|
96
|
+
// client disconnected mid-stream - the `close` handler already cancelled the reader
|
|
92
97
|
}
|
|
93
98
|
res.end();
|
|
94
99
|
}
|
|
95
100
|
/**
|
|
96
101
|
* Strip `optimizeDeps.rollupOptions.jsx` from a plugin's `config` hook output when running under
|
|
97
|
-
* rolldown-vite
|
|
102
|
+
* rolldown-vite - the source of the scary, harmless `Warning: Invalid input options … "jsx" Invalid
|
|
98
103
|
* key: Expected never but received "jsx"` on `nifra dev`.
|
|
99
104
|
*
|
|
100
105
|
* Why it happens: `@vitejs/plugin-react@4.x` (and peers) target an *older* rolldown-vite optimizeDeps
|
|
101
|
-
* API
|
|
106
|
+
* API - they inject `optimizeDeps.rollupOptions.jsx` to tell the dep pre-bundler to transform JSX. Vite
|
|
102
107
|
* 8's rolldown dep-optimizer renamed that surface to `optimizeDeps.rolldownOptions` (and moved jsx under
|
|
103
108
|
* `transform.jsx`), so the stale `rollupOptions.jsx` is an unrecognized input option → the warning. It's
|
|
104
109
|
* a version-skew artifact, not a real misconfig: the route source JSX transform runs through the
|
|
105
110
|
* plugin's own `transform` hook (untouched here), and node_modules deps that get pre-bundled almost
|
|
106
|
-
* never contain raw JSX
|
|
111
|
+
* never contain raw JSX - so dropping the dead key changes no behavior and keeps HMR/Fast Refresh
|
|
107
112
|
* intact. We *strip* (rather than translate to `rolldownOptions`) so the fix is version-agnostic: a
|
|
108
113
|
* plugin already emitting the correct `rolldownOptions` is left untouched, and a future plugin bump that
|
|
109
114
|
* stops emitting `rollupOptions.jsx` makes this a no-op.
|
|
@@ -111,12 +116,12 @@ export async function pipeWebBodyToNode(body, res) {
|
|
|
111
116
|
* Scoped narrowly: only the `optimizeDeps.rollupOptions.jsx` key is removed, only under rolldown-vite,
|
|
112
117
|
* and only from the value a plugin's `config` hook returns. Non-rolldown Vite is passed through verbatim.
|
|
113
118
|
*
|
|
114
|
-
* FLATTEN FIRST: a Vite plugin factory may return an ARRAY of plugins
|
|
119
|
+
* FLATTEN FIRST: a Vite plugin factory may return an ARRAY of plugins - `@vitejs/plugin-react`'s `react()`
|
|
115
120
|
* returns `[vite:react-babel, vite:react-refresh]`, and it's `react:react-babel`'s `config` hook that emits
|
|
116
121
|
* the offending `optimizeDeps.rollupOptions.jsx`. `nifra.config.ts` writes `vitePlugins = [react()]`, so the
|
|
117
122
|
* plugin list arrives NESTED (`[[babel, refresh]]`). Without flattening, `.map` sees the inner array (which
|
|
118
|
-
* has no `config`), leaves it untouched, and Vite
|
|
119
|
-
*
|
|
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
|
|
120
125
|
* list identically) is what lets the strip reach every real plugin.
|
|
121
126
|
*/
|
|
122
127
|
export function normalizeRolldownPlugins(plugins, isRolldown) {
|
|
@@ -148,7 +153,7 @@ export function normalizeRolldownPlugins(plugins, isRolldown) {
|
|
|
148
153
|
return plugin;
|
|
149
154
|
const wrappedHandler = (config, env) => {
|
|
150
155
|
const returned = handler(config, env);
|
|
151
|
-
// The hook may return a promise
|
|
156
|
+
// The hook may return a promise - normalize both shapes.
|
|
152
157
|
return returned instanceof Promise ? returned.then(stripJsxKey) : stripJsxKey(returned);
|
|
153
158
|
};
|
|
154
159
|
// Preserve the ORIGINAL shape: a function stays a function; the object form keeps its `order`
|
|
@@ -168,17 +173,19 @@ export async function createViteDevServer(options) {
|
|
|
168
173
|
const routesDir = resolvePath(options.routesDir);
|
|
169
174
|
const port = options.port ?? DEFAULT_DEV_PORT;
|
|
170
175
|
// Codegen the client entry with Vite-servable, root-relative specifiers (e.g. `/routes/index.tsx`).
|
|
171
|
-
const manifest = discoverRoutes(routesDir);
|
|
172
176
|
const toUrl = (file) => `/${relative(root, `${routesDir}/${file}`)}`;
|
|
173
|
-
|
|
177
|
+
const writeClientEntry = () => {
|
|
178
|
+
const manifest = discoverRoutes(routesDir);
|
|
179
|
+
writeFileSync(resolvePath(root, DEV_ENTRY), generateClientEntry(manifest, { clientModule: options.clientModule, resolve: toUrl }));
|
|
180
|
+
};
|
|
181
|
+
writeClientEntry();
|
|
174
182
|
const entryUrl = `/${DEV_ENTRY}`;
|
|
175
183
|
// Create our HTTP server FIRST, then hand it to Vite as the HMR WebSocket host (`hmr.server`). In
|
|
176
|
-
// middleware mode Vite would otherwise open a *separate* ws port (24678)
|
|
184
|
+
// middleware mode Vite would otherwise open a *separate* ws port (24678) - fragile: it conflicts
|
|
177
185
|
// across restarts ("Port undefined is already in use" → the client never connects). Sharing one
|
|
178
186
|
// port means HMR rides the same origin as the app, robust across restarts. The handler closes over
|
|
179
187
|
// `vite`, which is assigned just below before the server starts listening.
|
|
180
188
|
let vite;
|
|
181
|
-
let version = 0;
|
|
182
189
|
let app;
|
|
183
190
|
const server = createHttpServer((req, res) => {
|
|
184
191
|
vite.middlewares(req, res, () => {
|
|
@@ -190,7 +197,7 @@ export async function createViteDevServer(options) {
|
|
|
190
197
|
const contentType = nifraRes.headers.get("content-type") ?? "";
|
|
191
198
|
res.statusCode = nifraRes.status;
|
|
192
199
|
if (!contentType.includes("text/html")) {
|
|
193
|
-
// Data / redirect / asset response
|
|
200
|
+
// Data / redirect / asset response - pass through untouched, streamed (SSE-safe). Set-Cookie is
|
|
194
201
|
// emitted per-header so multi-cookie responses (e.g. better-auth sessions) aren't collapsed.
|
|
195
202
|
applyResponseHeaders(nifraRes.headers, res);
|
|
196
203
|
await pipeWebBodyToNode(nifraRes.body, res);
|
|
@@ -203,7 +210,7 @@ export async function createViteDevServer(options) {
|
|
|
203
210
|
}
|
|
204
211
|
catch (err) {
|
|
205
212
|
// Source-map the stack first (Vite maps the bundled frames back to your `.ts`), then render
|
|
206
|
-
// the readable dev overlay instead of a bare text dump. Dev-only
|
|
213
|
+
// the readable dev overlay instead of a bare text dump. Dev-only - production maps to `_error`.
|
|
207
214
|
if (err instanceof Error)
|
|
208
215
|
vite.ssrFixStacktrace(err);
|
|
209
216
|
res.statusCode = 500;
|
|
@@ -214,15 +221,20 @@ export async function createViteDevServer(options) {
|
|
|
214
221
|
});
|
|
215
222
|
});
|
|
216
223
|
// `conditions: ["bun"]` makes Vite resolve nifra's workspace packages (`@nifrajs/web-react/client`, …) to
|
|
217
|
-
// their TS **source**
|
|
224
|
+
// their TS **source** - so the dev server needs no prior `dist` build of the adapter packages.
|
|
218
225
|
const usePolling = options.poll ?? process.env.CHOKIDAR_USEPOLLING === "1";
|
|
219
|
-
|
|
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();
|
|
220
229
|
const { createServer } = viteModule;
|
|
221
230
|
// Under rolldown-vite (Vite 8+), strip the stale `optimizeDeps.rollupOptions.jsx` some framework
|
|
222
|
-
// plugins still emit
|
|
231
|
+
// plugins still emit - it triggers a noisy "Invalid key … jsx" warning but does nothing useful here.
|
|
223
232
|
const plugins = normalizeRolldownPlugins(options.plugins ?? [], viteModule.rolldownVersion !== undefined);
|
|
224
233
|
vite = await createServer({
|
|
225
234
|
root,
|
|
235
|
+
// Dev must not inherit Vite's default `VITE_*` exposure beside Nifra's documented boundary.
|
|
236
|
+
envPrefix: vitePublicEnvPrefix(options.publicEnvPrefix),
|
|
237
|
+
...(options.publicDir !== undefined ? { publicDir: options.publicDir } : {}),
|
|
226
238
|
appType: "custom",
|
|
227
239
|
server: {
|
|
228
240
|
middlewareMode: true,
|
|
@@ -230,31 +242,61 @@ export async function createViteDevServer(options) {
|
|
|
230
242
|
// Explicit watch config; poll when native fs events aren't delivered (containers/sandboxes).
|
|
231
243
|
watch: usePolling ? { usePolling: true, interval: 80 } : {},
|
|
232
244
|
},
|
|
233
|
-
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],
|
|
234
248
|
resolve: {
|
|
235
249
|
conditions: [...(options.conditions ?? []), "bun", "module", "browser", "development"],
|
|
236
250
|
// Dedupe React to ONE copy. In a multi-root workspace a shared package can pull react/react-dom
|
|
237
251
|
// from a SIBLING app's node_modules, so the dev server loads two React cores → a second hook
|
|
238
252
|
// dispatcher → `resolveDispatcher().useState` null on any hook-using route (the error points at the
|
|
239
|
-
// component, not the resolution
|
|
253
|
+
// component, not the resolution - brutal to diagnose). Mirrors the build-time reactDedupePlugin so
|
|
240
254
|
// dev matches prod. No-op for non-React apps (the package simply isn't present to dedupe).
|
|
241
255
|
dedupe: ["react", "react-dom"],
|
|
242
256
|
},
|
|
243
257
|
...(options.define ? { define: options.define } : {}),
|
|
244
258
|
});
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
259
|
+
const ssrLoad = (absolutePath) => vite.ssrLoadModule(absolutePath);
|
|
260
|
+
app = await options.createApp(entryUrl, ssrLoad);
|
|
261
|
+
// Re-create the app on change so a hard reload picks up a route ADD/REMOVE (the manifest comes
|
|
262
|
+
// from a directory scan, which `ssrLoadModule` cannot invalidate). Module CONTENT no longer needs a
|
|
263
|
+
// version counter: Vite owns SSR resolution now and re-evaluates changed modules itself, which is
|
|
264
|
+
// the cache-busting the old `importQuery` was emulating against Bun's import cache.
|
|
265
|
+
let refreshVersion = 0;
|
|
266
|
+
const refreshApp = () => {
|
|
267
|
+
const version = ++refreshVersion;
|
|
268
|
+
Promise.resolve(options.createApp(entryUrl, ssrLoad))
|
|
250
269
|
.then((next) => {
|
|
251
|
-
|
|
270
|
+
if (version === refreshVersion)
|
|
271
|
+
app = next;
|
|
252
272
|
})
|
|
253
273
|
.catch((err) => console.error("[nifra/web/vite] app re-create failed:", err));
|
|
254
|
-
}
|
|
255
|
-
|
|
274
|
+
};
|
|
275
|
+
vite.watcher.on("change", refreshApp);
|
|
276
|
+
for (const event of ["add", "unlink"]) {
|
|
277
|
+
vite.watcher.on(event, (path) => {
|
|
278
|
+
if (path.startsWith(`${routesDir}/`) || path.startsWith(`${routesDir}\\`))
|
|
279
|
+
writeClientEntry();
|
|
280
|
+
refreshApp();
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
try {
|
|
284
|
+
await listenOrExplain(server, port);
|
|
285
|
+
}
|
|
286
|
+
catch (err) {
|
|
287
|
+
// Nothing is listening, but Vite is fully up by now - watchers, the dep optimizer, its own sockets -
|
|
288
|
+
// and every one of those keeps the event loop alive. Left open, the process prints the diagnosis and
|
|
289
|
+
// then HANGS on it, which is worse than the raw crash this guard replaced: the user sees a dev server
|
|
290
|
+
// that appears to be starting. Tear Vite down so the failure is terminal.
|
|
291
|
+
await vite.close().catch(() => { });
|
|
292
|
+
throw err;
|
|
293
|
+
}
|
|
294
|
+
// Report the port actually BOUND, not the one requested. They differ for `port: 0`, which is how you
|
|
295
|
+
// ask the OS for a free one - the correct thing to do in a test or when running several apps at once.
|
|
296
|
+
// Echoing the request back would return a literal 0, which connects to nothing.
|
|
297
|
+
const address = server.address();
|
|
256
298
|
return {
|
|
257
|
-
port,
|
|
299
|
+
port: typeof address === "object" && address !== null ? address.port : port,
|
|
258
300
|
stop: async () => {
|
|
259
301
|
server.close();
|
|
260
302
|
await vite.close();
|
package/dist/vite.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.js","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAA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
2
2
|
"name": "@nifrajs/web",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "Framework-agnostic SSR core for nifra
|
|
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",
|
|
@@ -64,6 +69,16 @@
|
|
|
64
69
|
"types": "./dist/build.d.ts",
|
|
65
70
|
"default": "./dist/build.js"
|
|
66
71
|
},
|
|
72
|
+
"./route-manifest": {
|
|
73
|
+
"bun": "./src/route-manifest.ts",
|
|
74
|
+
"types": "./dist/route-manifest.d.ts",
|
|
75
|
+
"default": "./dist/route-manifest.js"
|
|
76
|
+
},
|
|
77
|
+
"./build-vite": {
|
|
78
|
+
"bun": "./src/build-vite.ts",
|
|
79
|
+
"types": "./dist/build-vite.d.ts",
|
|
80
|
+
"default": "./dist/build-vite.js"
|
|
81
|
+
},
|
|
67
82
|
"./fonts": {
|
|
68
83
|
"bun": "./src/fonts-google.ts",
|
|
69
84
|
"types": "./dist/fonts-google.d.ts",
|
|
@@ -104,14 +119,43 @@
|
|
|
104
119
|
"types": "./dist/plugins/svg.d.ts",
|
|
105
120
|
"default": "./dist/plugins/svg.js"
|
|
106
121
|
},
|
|
122
|
+
"./plugins/vite-leak-guard": {
|
|
123
|
+
"bun": "./src/plugins/vite-leak-guard.ts",
|
|
124
|
+
"types": "./dist/plugins/vite-leak-guard.d.ts",
|
|
125
|
+
"default": "./dist/plugins/vite-leak-guard.js"
|
|
126
|
+
},
|
|
107
127
|
"./css-modules": {
|
|
108
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"
|
|
109
152
|
}
|
|
110
153
|
},
|
|
111
154
|
"files": [
|
|
112
155
|
"dist",
|
|
113
156
|
"src",
|
|
114
|
-
"css-modules.d.ts"
|
|
157
|
+
"css-modules.d.ts",
|
|
158
|
+
"server-manifest.d.ts"
|
|
115
159
|
],
|
|
116
160
|
"sideEffects": false,
|
|
117
161
|
"scripts": {
|
|
@@ -122,7 +166,7 @@
|
|
|
122
166
|
"access": "public"
|
|
123
167
|
},
|
|
124
168
|
"dependencies": {
|
|
125
|
-
"@nifrajs/core": "2.
|
|
169
|
+
"@nifrajs/core": "2.3.0"
|
|
126
170
|
},
|
|
127
171
|
"peerDependencies": {
|
|
128
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
|
+
}
|