@nifrajs/web 2.10.0 → 2.11.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/dist/client.d.ts +12 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +16 -0
- package/dist/client.js.map +1 -1
- package/dist/dev-ssr-graph.d.ts +33 -0
- package/dist/dev-ssr-graph.d.ts.map +1 -0
- package/dist/dev-ssr-graph.js +285 -0
- package/dist/dev-ssr-graph.js.map +1 -0
- package/dist/dev.d.ts.map +1 -1
- package/dist/dev.js +72 -17
- package/dist/dev.js.map +1 -1
- package/dist/index.d.ts +25 -24
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +46 -76
- package/dist/index.js.map +1 -1
- package/dist/internal/head-merge.d.ts +27 -0
- package/dist/internal/head-merge.d.ts.map +1 -0
- package/dist/internal/head-merge.js +65 -0
- package/dist/internal/head-merge.js.map +1 -0
- package/dist/internal/server-boundary.d.ts +1 -2
- package/dist/internal/server-boundary.d.ts.map +1 -1
- package/dist/internal/server-boundary.js +1 -2
- package/dist/internal/server-boundary.js.map +1 -1
- package/dist/plugins/css-modules.d.ts +12 -0
- 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 +54 -0
- package/dist/plugins/kit.d.ts.map +1 -1
- package/dist/plugins/kit.js +66 -0
- package/dist/plugins/kit.js.map +1 -1
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +27 -1
- package/dist/vite.js.map +1 -1
- package/package.json +3 -3
- package/src/client.ts +28 -0
- package/src/dev-ssr-graph.ts +311 -0
- package/src/dev.ts +77 -19
- package/src/index.ts +55 -70
- package/src/internal/head-merge.ts +80 -0
- package/src/internal/server-boundary.ts +1 -2
- package/src/plugins/css-modules.ts +0 -0
- package/src/plugins/kit.ts +71 -0
- package/src/vite.ts +29 -1
package/dist/plugins/kit.js
CHANGED
|
@@ -14,6 +14,15 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
|
|
|
14
14
|
*/
|
|
15
15
|
import { existsSync } from "node:fs";
|
|
16
16
|
import { dirname, relative } from "node:path";
|
|
17
|
+
/**
|
|
18
|
+
* Re-keys the app-owned imports of a module the SERVER half of a plugin just compiled, so an edit below
|
|
19
|
+
* a route reaches SSR instead of being served from Bun's import cache. A plugin that claims a file
|
|
20
|
+
* extension is the only code that ever sees that file's source, so it is the only place its imports can
|
|
21
|
+
* be versioned - every `generate: "ssr"` loader should return its output through this.
|
|
22
|
+
*
|
|
23
|
+
* A no-op on the client half and outside a dev server. See `../dev-ssr-graph.ts` for the whole design.
|
|
24
|
+
*/
|
|
25
|
+
export { rewriteSsrImports } from "../dev-ssr-graph.js";
|
|
17
26
|
const packageRootCache = new Map();
|
|
18
27
|
/** The nearest ancestor directory of `startDir` that holds a `package.json` (the file's package root),
|
|
19
28
|
* cached. Falls back to `startDir` if none is found, so it never throws. */
|
|
@@ -59,6 +68,63 @@ export function hash8(input) {
|
|
|
59
68
|
h = (Math.imul(h, 33) ^ input.charCodeAt(i)) >>> 0;
|
|
60
69
|
return h.toString(16).padStart(8, "0");
|
|
61
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Env flag a nifra dev server sets for its own lifetime, so a framework compiler plugin can tell a dev
|
|
73
|
+
* compile from a `nifra build` one. Exported for the dev server that sets it; plugins ask
|
|
74
|
+
* {@link devServerCompile} instead of reading it.
|
|
75
|
+
*/
|
|
76
|
+
export const DEV_HMR_ENV = "NIFRA_DEV_HMR";
|
|
77
|
+
/**
|
|
78
|
+
* True while a nifra dev server is running, i.e. the compile may emit HMR wiring (and, where the
|
|
79
|
+
* framework couples the two, dev-mode runtime output).
|
|
80
|
+
*
|
|
81
|
+
* The phase cannot be a plugin constructor argument: an app builds its `clientPlugins` once in
|
|
82
|
+
* `nifra.config.ts` and the same plugin objects serve both `nifra dev` and `nifra build`. Guarding the
|
|
83
|
+
* emitted code with `if (import.meta.hot)` is not sufficient either - `Bun.build` keeps the branch, so
|
|
84
|
+
* the HMR calls were measured shipping in production client chunks. The dev server announces itself in
|
|
85
|
+
* the environment instead, and `nifra build` never sets it. Read per compile (not captured at
|
|
86
|
+
* registration) so the flag is honoured however late the server sets it.
|
|
87
|
+
*/
|
|
88
|
+
export function devServerCompile() {
|
|
89
|
+
return process.env[DEV_HMR_ENV] === "1";
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The app root and the routes directory of the running dev server, for plugins that need to tell one of
|
|
93
|
+
* the app's own components from a dependency or a route module. Set alongside {@link DEV_HMR_ENV}; read
|
|
94
|
+
* through {@link devHotComponent}.
|
|
95
|
+
*/
|
|
96
|
+
export const DEV_ROOT_ENV = "NIFRA_DEV_ROOT";
|
|
97
|
+
export const DEV_ROUTES_ENV = "NIFRA_DEV_ROUTES";
|
|
98
|
+
const under = (path, dir) => dir !== undefined &&
|
|
99
|
+
dir !== "" &&
|
|
100
|
+
(path === dir || path.startsWith(dir.endsWith("/") ? dir : `${dir}/`));
|
|
101
|
+
/**
|
|
102
|
+
* Whether a dev compile of `path` may wrap the module in component-level hot-patching - i.e. whether it
|
|
103
|
+
* is one of the app's OWN components rather than a dependency or a route module.
|
|
104
|
+
*
|
|
105
|
+
* The exclusions are not caution, they are two things such a wrapper cannot survive:
|
|
106
|
+
*
|
|
107
|
+
* - a **dependency**, whose components are the framework's own composition machinery. An adapter folds
|
|
108
|
+
* a layout chain through them, so they are entered from a snippet or as a dynamic component - and a
|
|
109
|
+
* wrapper there sits between the SSR markup and the component that is supposed to claim it.
|
|
110
|
+
* - a **route module**, for the same reason one level down: a route or layout IS a chain member, so it
|
|
111
|
+
* is always the dynamic child. It is also the wrong boundary to patch - a route module carries the
|
|
112
|
+
* loader and meta the server ran, and re-running those is a navigation, not a patch. Editing one
|
|
113
|
+
* finds no accepting module and reloads the page, which is the correct outcome.
|
|
114
|
+
*
|
|
115
|
+
* Both cost nothing in practice: the components an edit loop actually touches are the views, and a view
|
|
116
|
+
* that wants to hot-patch lives outside the routes directory. Where the split is unknown (no dev server,
|
|
117
|
+
* or a root that was never announced), the answer is `false` - a full reload is always correct, a
|
|
118
|
+
* mispatched tree is not.
|
|
119
|
+
*/
|
|
120
|
+
export function devHotComponent(path) {
|
|
121
|
+
const root = process.env[DEV_ROOT_ENV];
|
|
122
|
+
if (!under(path, root))
|
|
123
|
+
return false;
|
|
124
|
+
if (path.includes("/node_modules/"))
|
|
125
|
+
return false;
|
|
126
|
+
return !under(path, process.env[DEV_ROUTES_ENV]);
|
|
127
|
+
}
|
|
62
128
|
/**
|
|
63
129
|
* Wire the virtual-CSS-module handlers onto `build` for `namespace`, returning an {@link StylesheetEmitter}.
|
|
64
130
|
* The `namespace` must be a plain identifier (letters/`-`); it's used verbatim as the import suffix and
|
package/dist/plugins/kit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kit.js","sourceRoot":"","sources":["../../src/plugins/kit.ts"],"names":[],"mappings":";;;;;;;;AAAA;;;;;GAKG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAM7C,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAkB,CAAA;AAElD;4EAC4E;AAC5E,SAAS,aAAa,CAAC,QAAgB;IACrC,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IAC7C,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,MAAM,CAAA;IACvC,IAAI,GAAG,GAAG,QAAQ,CAAA;IAClB,SAAS,CAAC;QACR,IAAI,UAAU,CAAC,GAAG,GAAG,eAAe,CAAC;YAAE,MAAK;QAC5C,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;QAC3B,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;YACnB,GAAG,GA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AAI,CAAC,OAAO,gCAAgC,SAAS,kBAAkB,IAAI,CAAC,OAAO,EAAE,CACrG,CAAA;QACH,CAAC;QACD,MAAM,IAAI,KAAK,CACb,eAAe,IAAI,CAAC,OAAO,wBAAwB,SAAS,oCAAoC,EAChG,EAAE,KAAK,EAAE,GAAG,EAAE,CACf,CAAA;IACH,CAAC;AACH,CAAC"}
|
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":"AA8BA,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,CAAC,SAAS,EAAE,CAClB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,KAC7C,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;IACjC,gFAAgF;IAChF,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,OAAO,EAAE,CAAA;IACrC;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACvC;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IAClD,mDAAmD;IACnD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;I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AAE,CAkCpB;AAkBD;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,aAAa,CAAC,CAiO/F"}
|
package/dist/vite.js
CHANGED
|
@@ -16,9 +16,11 @@ import { relative, resolve as resolvePath } from "node:path";
|
|
|
16
16
|
import { createDevDiagnostics } from "./dev-diagnostics.js";
|
|
17
17
|
import { listenOrExplain } from "./dev-port.js";
|
|
18
18
|
import { discoverRoutes } from "./fs.js";
|
|
19
|
-
import { DEFAULT_DEV_PORT, generateClientEntry } from "./index.js";
|
|
19
|
+
import { DEFAULT_DEV_PORT, generateClientEntry, setSsrModuleLoader } from "./index.js";
|
|
20
20
|
import { vitePublicEnvPrefix } from "./internal/server-boundary.js";
|
|
21
21
|
import { importVite } from "./internal/vite-import.js";
|
|
22
|
+
import { scopedName } from "./plugins/css-modules.js";
|
|
23
|
+
import { DEV_ROOT_ENV, DEV_ROUTES_ENV, reproduciblePath } from "./plugins/kit.js";
|
|
22
24
|
import { viteServerFnStub } from "./plugins/vite-server-fn.js";
|
|
23
25
|
import { viteServerOnlyEmpty } from "./plugins/vite-server-only.js";
|
|
24
26
|
export { LAST_ERROR_PATH } from "./diagnostic.js";
|
|
@@ -188,6 +190,11 @@ export async function createViteDevServer(options) {
|
|
|
188
190
|
const root = resolvePath(options.root ?? process.cwd());
|
|
189
191
|
const routesDir = resolvePath(options.routesDir);
|
|
190
192
|
const port = options.port ?? DEFAULT_DEV_PORT;
|
|
193
|
+
// Which files are the app's own components, for framework plugins that hot-patch at component
|
|
194
|
+
// granularity (`devHotComponent`). Announced in the environment rather than passed, because the
|
|
195
|
+
// plugin that reads it is constructed by the app, in its own config, before this server exists.
|
|
196
|
+
process.env[DEV_ROOT_ENV] = root;
|
|
197
|
+
process.env[DEV_ROUTES_ENV] = routesDir;
|
|
191
198
|
// Codegen the client entry with Vite-servable, root-relative specifiers (e.g. `/routes/index.tsx`).
|
|
192
199
|
const toUrl = (file) => `/${relative(root, `${routesDir}/${file}`)}`;
|
|
193
200
|
const writeClientEntry = () => {
|
|
@@ -328,9 +335,24 @@ export async function createViteDevServer(options) {
|
|
|
328
335
|
externalConditions: ssrConditions,
|
|
329
336
|
},
|
|
330
337
|
},
|
|
338
|
+
css: {
|
|
339
|
+
modules: {
|
|
340
|
+
// Vite ships its own CSS-Modules naming (`_name_<base64>`); the Bun pipeline and every
|
|
341
|
+
// `nifra build` use `scopedName`. Left alone, one class is called two different things
|
|
342
|
+
// depending on which pipeline served it, so a selector written against a generated name works
|
|
343
|
+
// in dev and vanishes in production - and the two dev pipelines disagree with each other. The
|
|
344
|
+
// name is defined once, in the plugin, and Vite is handed that definition.
|
|
345
|
+
generateScopedName: (name, filename) => scopedName(reproduciblePath(filename), name),
|
|
346
|
+
},
|
|
347
|
+
},
|
|
331
348
|
...(options.define ? { define: options.define } : {}),
|
|
332
349
|
});
|
|
333
350
|
const ssrLoad = (absolutePath) => vite.ssrLoadModule(absolutePath);
|
|
351
|
+
// Published so an ADAPTER can reach this graph too. Route modules already load through it; an
|
|
352
|
+
// adapter that has to load a compiled asset of its own on the server (`@nifrajs/web-svelte` and its
|
|
353
|
+
// `Chain.svelte`) would otherwise take it from the runtime, which has no compiler for it and no
|
|
354
|
+
// reason to agree with Vite about which copy of the framework runtime it renders through.
|
|
355
|
+
setSsrModuleLoader(ssrLoad);
|
|
334
356
|
app = await options.createApp(entryUrl, ssrLoad);
|
|
335
357
|
// Re-create the app on change so a hard reload picks up a route ADD/REMOVE (the manifest comes
|
|
336
358
|
// from a directory scan, which `ssrLoadModule` cannot invalidate). Module CONTENT no longer needs a
|
|
@@ -372,6 +394,10 @@ export async function createViteDevServer(options) {
|
|
|
372
394
|
return {
|
|
373
395
|
port: typeof address === "object" && address !== null ? address.port : port,
|
|
374
396
|
stop: async () => {
|
|
397
|
+
// Cleared with the server that owns it: the slot is process-global, so a stopped server leaving
|
|
398
|
+
// its loader behind would hand the next one's adapter a graph that is closed (tests start and
|
|
399
|
+
// stop several dev servers in one process).
|
|
400
|
+
setSsrModuleLoader(undefined);
|
|
375
401
|
server.close();
|
|
376
402
|
await vite.close();
|
|
377
403
|
},
|
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,WAAW,EAAE,MAAM,WAAW,CAAA;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AA+EnE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,0FAA0F;AAC1F,MAAM,SAAS,GAAG,uBAAuB,CAAA;AAEzC,MAAM,YAAY,GAAG,KAAK,EAAE,GAAoB,EAA+B,EAAE;IAC/E,IAAI,GAAG,CAAC,MAAM,KAAK,KAAK,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM;QAAE,OAAO,SAAS,CAAA;IACnE,MAAM,MAAM,GAAa,EAAE,CAAA;IAC3B,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG;QAAE,MAAM,CAAC,IAAI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A;IAClD,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,gGAAgG;YAChG,8FAA8F;YAC9F,4CAA4C;YAC5C,kBAAkB,CAAC,SAAS,CAAC,CAAA;YAC7B,MAAM,CAAC,KAAK,EAAE,CAAA;YACd,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;QACpB,CAAC;KACF,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nifrajs/web",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.0",
|
|
4
4
|
"description": "Framework-agnostic SSR core for nifra - the render seam + HTML document orchestration.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -171,7 +171,7 @@
|
|
|
171
171
|
"access": "public"
|
|
172
172
|
},
|
|
173
173
|
"dependencies": {
|
|
174
|
-
"@nifrajs/core": "2.
|
|
174
|
+
"@nifrajs/core": "2.11.0"
|
|
175
175
|
},
|
|
176
176
|
"peerDependencies": {
|
|
177
177
|
"sass": "^1.0.0",
|
|
@@ -191,7 +191,7 @@
|
|
|
191
191
|
"@nifrajs/test-utils": "workspace:*",
|
|
192
192
|
"@nifrajs/web-react": "workspace:*",
|
|
193
193
|
"sass": "^1.77.0",
|
|
194
|
-
"vite": "^8.
|
|
194
|
+
"vite": "^8.2.1"
|
|
195
195
|
},
|
|
196
196
|
"repository": {
|
|
197
197
|
"type": "git",
|
package/src/client.ts
CHANGED
|
@@ -20,6 +20,34 @@ import {
|
|
|
20
20
|
} from "./navigation.ts"
|
|
21
21
|
import type { ClientRouter } from "./router.ts"
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Everything the generated client entry needs, re-exported here so that entry imports ONE module and
|
|
25
|
+
* that module is DOM-only. It used to take these from `@nifrajs/web`, whose graph includes `renderPage`
|
|
26
|
+
* and the static-file server: bundled builds tree-shook the server half away, but Vite's dev server
|
|
27
|
+
* serves modules as written, so the browser evaluated `public-dir.ts` and died on `node:fs/promises`
|
|
28
|
+
* before hydrating. The fix is for the entry not to name the server module in the first place.
|
|
29
|
+
*/
|
|
30
|
+
export { mergeHeads, resolveMeta } from "./internal/head-merge.ts"
|
|
31
|
+
export {
|
|
32
|
+
getBrowserNavigate,
|
|
33
|
+
IDLE_BLOCKER,
|
|
34
|
+
registerBlocker,
|
|
35
|
+
resolveNavigate,
|
|
36
|
+
} from "./navigation.ts"
|
|
37
|
+
export { createMutation, createQueryClient } from "./query.ts"
|
|
38
|
+
export { createClientRouter, createMatcher } from "./router.ts"
|
|
39
|
+
// Same reason, for the ADAPTER packages (`@nifrajs/web-react` and friends). Every one of them reaches
|
|
40
|
+
// for these from the root - `searchOfChain` in its `/client` entry, the navigation and query values in
|
|
41
|
+
// its router/query modules - and every one of those modules is in the browser graph. They are defined
|
|
42
|
+
// in DOM-safe modules already; the only thing wrong was the specifier they were imported through.
|
|
43
|
+
export { searchOf, searchOfChain } from "./search.ts"
|
|
44
|
+
// Types are deliberately NOT re-exported here. `RouteSearch` is augmented by generated code through
|
|
45
|
+
// `declare module "@nifrajs/web"`, and an interface augmentation lands on the module it names - so a
|
|
46
|
+
// type taken from this path would be the un-augmented one and typed `navigate({ to, search })` would
|
|
47
|
+
// silently go loose. Adapters keep sourcing types from the root; what they must avoid is the
|
|
48
|
+
// `export type { X } from "@nifrajs/web"` FORM, which leaves a bare `import "@nifrajs/web"` behind for
|
|
49
|
+
// its side effects. `import type` + a local `export type` erases completely.
|
|
50
|
+
|
|
23
51
|
export interface InstallHistoryOptions {
|
|
24
52
|
/** Full-page fallback when a client navigation can't proceed (default: `location.assign`). */
|
|
25
53
|
readonly fallback?: (path: string) => void
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-module SSR invalidation for the **Bun pipeline's** dev server.
|
|
3
|
+
*
|
|
4
|
+
* Bun's runtime caches every module it has evaluated, and nothing invalidates that cache on a file
|
|
5
|
+
* change. The dev server's answer used to stop at the route module: `discoverRoutes({ importQuery })`
|
|
6
|
+
* appends a changing query to each route's own dynamic import, so the route re-evaluates. Its imports
|
|
7
|
+
* do not - a component, a helper, a `*.server` module all keep resolving to the same cached specifier,
|
|
8
|
+
* so SSR kept rendering the code that was on disk when the server started while the client, which Bun
|
|
9
|
+
* rebuilds properly, rendered the edit. Every framework on this pipeline had it; the Vite pipeline does
|
|
10
|
+
* not, because Vite owns its own SSR module graph.
|
|
11
|
+
*
|
|
12
|
+
* The fix is that module graph, in the small: watch what the server actually imported, notice which
|
|
13
|
+
* files changed, and give exactly those - and everything that imports them - a fresh cache key.
|
|
14
|
+
*
|
|
15
|
+
* ## Why a version per module, and why version 0 means no query
|
|
16
|
+
*
|
|
17
|
+
* A cache key is a `?v=<n>` query on the resolved absolute path. Bun treats a distinct query as a
|
|
18
|
+
* distinct registry entry and re-reads the file from disk (nifra's own Bun plugins already tolerate the
|
|
19
|
+
* suffix - see the `(\?|$)` in their filters), so a bump is a reload of that module and nothing else.
|
|
20
|
+
*
|
|
21
|
+
* That "nothing else" is the reason versions start at 0 and 0 rewrites nothing at all. A module that has
|
|
22
|
+
* never been edited keeps its bare path, which is the same registry entry the CLI already loaded when it
|
|
23
|
+
* read the app's config and backend - so a database client, a queue handle, any module-scope singleton
|
|
24
|
+
* shared between the backend and a route stays ONE instance. Versioning everything up front would have
|
|
25
|
+
* forked those on the first request. Editing such a module does fork it, deliberately: the routes get
|
|
26
|
+
* the new code and the already-running backend keeps the old, which is the same deal every dev server
|
|
27
|
+
* makes, and the same one a restart resolves.
|
|
28
|
+
*
|
|
29
|
+
* ## Why importers have to be bumped too
|
|
30
|
+
*
|
|
31
|
+
* Re-evaluating a module re-runs its imports through resolution, but a module that is NOT re-evaluated
|
|
32
|
+
* never re-resolves anything. With `route -> Layout -> Button` and an edit to `Button`, the route
|
|
33
|
+
* re-evaluates (its own query moved), asks for `Layout` under the key it always used, and gets the
|
|
34
|
+
* cached `Layout` back - which never mentions `Button` again. So a change propagates UP: the edited file
|
|
35
|
+
* and every transitive importer of it are bumped together, and the chain re-evaluates from the route
|
|
36
|
+
* down.
|
|
37
|
+
*
|
|
38
|
+
* ## Why the key is written into the source, not returned from `onResolve`
|
|
39
|
+
*
|
|
40
|
+
* Rewriting a resolution is the obvious mechanism and it only covers half of the imports people write.
|
|
41
|
+
* Bun's runtime consults resolver plugins for a specifier that carries a file extension
|
|
42
|
+
* (`"./Counter.tsx"`) and not for one that does not (`"./Counter"`, `"./components"`) - the extensionless
|
|
43
|
+
* form is resolved on an internal fast path that no plugin, in any namespace, is offered. Measured on
|
|
44
|
+
* Bun 1.3.14; the bundler has no such gap. Since extensionless is how most of this ecosystem's code is
|
|
45
|
+
* written, an `onResolve`-only fix would have silently covered a minority of real apps.
|
|
46
|
+
*
|
|
47
|
+
* So the version is applied one level earlier, in the importer's own source: on load, each app-owned
|
|
48
|
+
* module has its relative specifiers rewritten to absolute paths carrying the current version of the
|
|
49
|
+
* file they point at. `onResolve` stays as well, because it is the only hook that sees modules loaded by
|
|
50
|
+
* a third-party plugin this one does not wrap.
|
|
51
|
+
*
|
|
52
|
+
* Old versions stay in Bun's registry - a bounded dev-only leak, one entry per edit, which is what the
|
|
53
|
+
* route-level query already did.
|
|
54
|
+
*
|
|
55
|
+
* Bun-only + dev-only; never imported by the edge runtime or by a production build.
|
|
56
|
+
*/
|
|
57
|
+
import { statSync } from "node:fs"
|
|
58
|
+
import { dirname } from "node:path"
|
|
59
|
+
import type { BunPlugin } from "bun"
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Extensions worth a version. Source and data only: an asset (`.css`, `.svg`, an image) either has no
|
|
63
|
+
* server-side meaning or, like CSS Modules, compiles to a pure function of its path, so re-reading it
|
|
64
|
+
* would change nothing about the rendered HTML.
|
|
65
|
+
*/
|
|
66
|
+
const VERSIONED = /\.(?:mts|cts|mjs|cjs|tsx|jsx|ts|js|svelte|vue|mdx|md|json)$/
|
|
67
|
+
|
|
68
|
+
/** Source this module can load and rewrite itself, when no framework plugin claims the file first. */
|
|
69
|
+
const REWRITABLE = "mts|cts|mjs|cjs|tsx|jsx|ts|js"
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The `onLoad` filter, which has to do the whole job of selecting app source: a **runtime** `onLoad`
|
|
73
|
+
* handler may not decline a file it was offered (Bun raises `onLoad() expects an object returned`), so
|
|
74
|
+
* anything this matches is loaded here - and a dependency's `.js` loaded as ESM when the package meant
|
|
75
|
+
* CJS would break the app. Hence the shape: under the app root, no `node_modules` segment at any depth,
|
|
76
|
+
* no dot-directory (`.nifra-bun/`, `.git/`), and a source extension, with an optional cache-busting
|
|
77
|
+
* query. It mirrors {@link SsrGraph}'s ownership test; keep the two in step.
|
|
78
|
+
*/
|
|
79
|
+
const appSourceFilter = (root: string): RegExp =>
|
|
80
|
+
new RegExp(
|
|
81
|
+
`^${root.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/` +
|
|
82
|
+
`(?!.*/node_modules/)(?!\\.)(?!.*/\\.)[^?]*\\.(?:${REWRITABLE})(?:\\?|$)`,
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* `from "x"`, `import "x"`, `import("x")`, `require("x")` - every form that carries a static specifier,
|
|
87
|
+
* including `export ... from`. What it matches is only a candidate: a hit counts as an import only if the
|
|
88
|
+
* transpiler's own scan reported the same specifier, which is what keeps a lookalike string literal out.
|
|
89
|
+
*/
|
|
90
|
+
const SPECIFIER = /\b(from|import|require)(\s*\(?\s*)(["'])([^"'\n]+)\3/g
|
|
91
|
+
|
|
92
|
+
export interface SsrGraphOptions {
|
|
93
|
+
/** The app root. Only files under it (and outside `node_modules`) are tracked. */
|
|
94
|
+
readonly root: string
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface SsrGraph {
|
|
98
|
+
/**
|
|
99
|
+
* The Bun **runtime** plugin that records the graph and re-keys imports. Register it before the first
|
|
100
|
+
* route module is imported; a runtime plugin only affects modules loaded after it.
|
|
101
|
+
*/
|
|
102
|
+
readonly plugin: BunPlugin
|
|
103
|
+
/**
|
|
104
|
+
* Re-stat every tracked module and bump the versions of the changed ones and their importers.
|
|
105
|
+
* Returns `true` when anything moved, i.e. when the app has to be rebuilt.
|
|
106
|
+
*/
|
|
107
|
+
sweep(): boolean
|
|
108
|
+
/** Bumped by each {@link sweep} that found a change. Belongs in the key the built app is cached under. */
|
|
109
|
+
generation(): number
|
|
110
|
+
/** Release the process-wide hook {@link rewriteSsrImports} reads. */
|
|
111
|
+
dispose(): void
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** `/abs/path.ts?v=2` and `file:///abs/path.ts` both name `/abs/path.ts`. */
|
|
115
|
+
function plainPath(path: string): string {
|
|
116
|
+
const withoutQuery = path.split("?")[0] ?? path
|
|
117
|
+
return withoutQuery.startsWith("file://")
|
|
118
|
+
? decodeURIComponent(withoutQuery.slice("file://".length))
|
|
119
|
+
: withoutQuery
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const mtimeOf = (path: string): number =>
|
|
123
|
+
statSync(path, { throwIfNoEntry: false })?.mtimeMs ?? Number.NaN
|
|
124
|
+
|
|
125
|
+
/** What Bun should compile a file this module loaded itself as - the file's own extension decides. */
|
|
126
|
+
const loaderFor = (path: string): "tsx" | "ts" | "jsx" | "js" =>
|
|
127
|
+
path.endsWith(".tsx")
|
|
128
|
+
? "tsx"
|
|
129
|
+
: path.endsWith(".jsx")
|
|
130
|
+
? "jsx"
|
|
131
|
+
: /\.[cm]?ts$/.test(path)
|
|
132
|
+
? "ts"
|
|
133
|
+
: "js"
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* What to PARSE a module as when scanning it for imports. `ts` is the safe default even for plain JS and
|
|
137
|
+
* for a plugin's compiled output (TS ⊃ JS), and the one thing it cannot also parse is JSX - which is why
|
|
138
|
+
* the JSX extensions are called out. Nothing here is emitted; the scan only reads specifiers.
|
|
139
|
+
*/
|
|
140
|
+
const scanLoaderFor = (path: string): "tsx" | "ts" =>
|
|
141
|
+
path.endsWith(".tsx") || path.endsWith(".jsx") ? "tsx" : "ts"
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* The active graph, for the framework plugins that own a file extension this module cannot load itself
|
|
145
|
+
* (`.vue`, `.svelte`, `.tsx` under Solid, `.mdx`). Only one dev server runs per process.
|
|
146
|
+
*/
|
|
147
|
+
let active: { rewrite(contents: string, path: string): string } | undefined
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Re-key the app-owned imports of a module a **server-side** plugin just compiled. A plugin that claims a
|
|
151
|
+
* file extension is the only code that sees that file's source, so it is the only place its imports can
|
|
152
|
+
* be versioned; without this call every component in that language stays on the code it had at startup.
|
|
153
|
+
*
|
|
154
|
+
* A no-op outside a Bun dev server, and on the client half of a plugin - the client is bundled, and a
|
|
155
|
+
* bundle has no import cache to bust.
|
|
156
|
+
*/
|
|
157
|
+
export function rewriteSsrImports(contents: string, path: string, generate: "dom" | "ssr"): string {
|
|
158
|
+
if (generate !== "ssr" || active === undefined) return contents
|
|
159
|
+
return active.rewrite(contents, plainPath(path))
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** Track and version the app's own server-side module graph. See the module doc for the whole design. */
|
|
163
|
+
export function createSsrGraph(options: SsrGraphOptions): SsrGraph {
|
|
164
|
+
const root = options.root.endsWith("/") ? options.root.slice(0, -1) : options.root
|
|
165
|
+
const prefix = `${root}/`
|
|
166
|
+
/** Every tracked module, by absolute path: its current cache version and the mtime it was read at. */
|
|
167
|
+
const nodes = new Map<string, { version: number; mtime: number }>()
|
|
168
|
+
/** Reverse edges - who imports this file - which is the direction invalidation travels. */
|
|
169
|
+
const importers = new Map<string, Set<string>>()
|
|
170
|
+
let generation = 0
|
|
171
|
+
|
|
172
|
+
/** Inside the app, outside `node_modules`, outside dot-directories, and a file worth re-reading. */
|
|
173
|
+
const owned = (abs: string): boolean => {
|
|
174
|
+
if (!abs.startsWith(prefix)) return false
|
|
175
|
+
if (abs.includes("/node_modules/")) return false
|
|
176
|
+
// Relative to the app, so a project that itself lives under a dotted directory is not excluded
|
|
177
|
+
// wholesale - this is about the app's own generated trees (`.nifra/`, `.nifra-bun/`, `.git/`).
|
|
178
|
+
const rel = abs.slice(prefix.length)
|
|
179
|
+
if (rel.startsWith(".") || rel.includes("/.")) return false
|
|
180
|
+
return VERSIONED.test(abs)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const track = (abs: string, importer: string): void => {
|
|
184
|
+
if (!nodes.has(abs)) nodes.set(abs, { version: 0, mtime: mtimeOf(abs) })
|
|
185
|
+
const parents = importers.get(abs)
|
|
186
|
+
if (parents === undefined) importers.set(abs, new Set([importer]))
|
|
187
|
+
else parents.add(importer)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// `Bun.resolveSync` re-enters this plugin's own `onResolve`, which is an unbounded recursion rather
|
|
191
|
+
// than a slow path. The flag is safe because the handler and `resolveSync` are both synchronous.
|
|
192
|
+
let resolving = false
|
|
193
|
+
|
|
194
|
+
const resolveFrom = (specifier: string, dir: string): string | undefined => {
|
|
195
|
+
resolving = true
|
|
196
|
+
try {
|
|
197
|
+
return Bun.resolveSync(specifier, dir)
|
|
198
|
+
} catch {
|
|
199
|
+
// Unresolvable here is not this module's error to report - leave it to Bun, which raises the
|
|
200
|
+
// diagnostic the app author can act on.
|
|
201
|
+
return undefined
|
|
202
|
+
} finally {
|
|
203
|
+
resolving = false
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Record `specifier` as an edge out of `importer` and return what it should be imported as, or
|
|
209
|
+
* `undefined` to leave the specifier exactly as the author wrote it.
|
|
210
|
+
*/
|
|
211
|
+
const keyFor = (specifier: string, importer: string): string | undefined => {
|
|
212
|
+
const abs = resolveFrom(specifier, dirname(importer))
|
|
213
|
+
if (abs === undefined || !owned(abs)) return undefined
|
|
214
|
+
track(abs, importer)
|
|
215
|
+
const version = nodes.get(abs)?.version ?? 0
|
|
216
|
+
// Version 0 is the shared, unversioned instance - see the module doc.
|
|
217
|
+
return version === 0 ? undefined : `${abs}?v=${version}`
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const rewrite = (contents: string, importer: string): string => {
|
|
221
|
+
if (!importer.startsWith(prefix) || importer.includes("/node_modules/")) return contents
|
|
222
|
+
let scanned: readonly { readonly path: string }[]
|
|
223
|
+
try {
|
|
224
|
+
scanned = new Bun.Transpiler({ loader: scanLoaderFor(importer) }).scanImports(contents)
|
|
225
|
+
} catch {
|
|
226
|
+
// Source Bun cannot parse is source Bun is about to reject with a real error message. Hand it
|
|
227
|
+
// through untouched rather than adding a second, worse one.
|
|
228
|
+
return contents
|
|
229
|
+
}
|
|
230
|
+
const candidates = new Set(scanned.map((entry) => entry.path).filter((p) => p.startsWith(".")))
|
|
231
|
+
if (candidates.size === 0) return contents
|
|
232
|
+
const keys = new Map<string, string>()
|
|
233
|
+
for (const specifier of candidates) {
|
|
234
|
+
const key = keyFor(specifier, importer)
|
|
235
|
+
if (key !== undefined) keys.set(specifier, key)
|
|
236
|
+
}
|
|
237
|
+
if (keys.size === 0) return contents
|
|
238
|
+
// Same length in lines and columns up to the specifier itself, so a stack trace still points at the
|
|
239
|
+
// line the author wrote.
|
|
240
|
+
return contents.replace(SPECIFIER, (whole, keyword, gap, quote, specifier) =>
|
|
241
|
+
keys.has(specifier) ? `${keyword}${gap}${quote}${keys.get(specifier)}${quote}` : whole,
|
|
242
|
+
)
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const plugin: BunPlugin = {
|
|
246
|
+
name: "nifra-dev-ssr-graph",
|
|
247
|
+
setup(build) {
|
|
248
|
+
// Every app-owned module that no other plugin claims: read it, re-key its imports, hand it back.
|
|
249
|
+
// Loading it here is what makes the extensionless specifiers reachable at all (module doc).
|
|
250
|
+
build.onLoad({ filter: appSourceFilter(root) }, async (args) => {
|
|
251
|
+
const path = plainPath(args.path)
|
|
252
|
+
const contents = await Bun.file(path).text()
|
|
253
|
+
return { contents: rewrite(contents, path), loader: loaderFor(path) }
|
|
254
|
+
})
|
|
255
|
+
// The resolver half covers what the loader half cannot see: a module compiled by a plugin that
|
|
256
|
+
// does not call `rewriteSsrImports`. Extension-bearing specifiers only, which is all Bun offers.
|
|
257
|
+
build.onResolve({ filter: /^[./]/ }, (args) => {
|
|
258
|
+
if (resolving) return undefined
|
|
259
|
+
// A specifier that already carries a query is either this module's own rewrite or a plugin's
|
|
260
|
+
// virtual sub-request (`?vue-css` and friends) - both are already keyed.
|
|
261
|
+
if (args.path.includes("?")) return undefined
|
|
262
|
+
const importer = plainPath(args.importer)
|
|
263
|
+
if (!importer.startsWith(prefix) || importer.includes("/node_modules/")) return undefined
|
|
264
|
+
const key = keyFor(args.path, importer)
|
|
265
|
+
return key === undefined ? undefined : { path: key }
|
|
266
|
+
})
|
|
267
|
+
},
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const sweep = (): boolean => {
|
|
271
|
+
const dirty = new Set<string>()
|
|
272
|
+
for (const [abs, node] of nodes) {
|
|
273
|
+
const mtime = mtimeOf(abs)
|
|
274
|
+
// NaN (deleted, or unreadable mid-save) never equals the recorded value, so it counts as changed
|
|
275
|
+
// and the next successful stat settles it.
|
|
276
|
+
if (mtime === node.mtime) continue
|
|
277
|
+
node.mtime = mtime
|
|
278
|
+
dirty.add(abs)
|
|
279
|
+
}
|
|
280
|
+
if (dirty.size === 0) return false
|
|
281
|
+
// Breadth-first up the reverse edges: an importer of a changed module is itself stale, because it
|
|
282
|
+
// holds the old binding and would not re-resolve on its own.
|
|
283
|
+
const queue = [...dirty]
|
|
284
|
+
for (let i = 0; i < queue.length; i++) {
|
|
285
|
+
const child = queue[i]
|
|
286
|
+
if (child === undefined) continue
|
|
287
|
+
for (const parent of importers.get(child) ?? []) {
|
|
288
|
+
if (dirty.has(parent)) continue
|
|
289
|
+
dirty.add(parent)
|
|
290
|
+
queue.push(parent)
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
for (const abs of dirty) {
|
|
294
|
+
const node = nodes.get(abs)
|
|
295
|
+
if (node !== undefined) node.version += 1
|
|
296
|
+
}
|
|
297
|
+
generation += 1
|
|
298
|
+
return true
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
const hook = { rewrite }
|
|
302
|
+
active = hook
|
|
303
|
+
return {
|
|
304
|
+
plugin,
|
|
305
|
+
sweep,
|
|
306
|
+
generation: () => generation,
|
|
307
|
+
dispose: () => {
|
|
308
|
+
if (active === hook) active = undefined
|
|
309
|
+
},
|
|
310
|
+
}
|
|
311
|
+
}
|