@nifrajs/web 2.14.1 → 3.2.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/boundary.d.ts +158 -0
- package/dist/boundary.d.ts.map +1 -0
- package/dist/boundary.js +237 -0
- package/dist/boundary.js.map +1 -0
- package/dist/build-plan.d.ts +228 -0
- package/dist/build-plan.d.ts.map +1 -0
- package/dist/build-plan.js +514 -0
- package/dist/build-plan.js.map +1 -0
- package/dist/build-vite.d.ts +2 -1
- package/dist/build-vite.d.ts.map +1 -1
- package/dist/build-vite.js +5 -3
- package/dist/build-vite.js.map +1 -1
- package/dist/build.d.ts +2 -197
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +92 -515
- package/dist/build.js.map +1 -1
- package/dist/chunk-names.d.ts.map +1 -1
- package/dist/chunk-names.js +3 -2
- package/dist/chunk-names.js.map +1 -1
- package/dist/dev-ssr-graph.d.ts.map +1 -1
- package/dist/dev-ssr-graph.js +63 -28
- package/dist/dev-ssr-graph.js.map +1 -1
- package/dist/diagnostic.d.ts.map +1 -1
- package/dist/diagnostic.js +9 -2
- package/dist/diagnostic.js.map +1 -1
- package/dist/fonts-google.d.ts.map +1 -1
- package/dist/fonts-google.js +3 -1
- package/dist/fonts-google.js.map +1 -1
- package/dist/fs.d.ts.map +1 -1
- package/dist/fs.js +2 -1
- package/dist/fs.js.map +1 -1
- package/dist/index.d.ts +16 -589
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -1824
- package/dist/index.js.map +1 -1
- package/dist/internal/codegen.d.ts +68 -0
- package/dist/internal/codegen.d.ts.map +1 -0
- package/dist/internal/codegen.js +317 -0
- package/dist/internal/codegen.js.map +1 -0
- package/dist/internal/fetcher-runtime.d.ts +19 -0
- package/dist/internal/fetcher-runtime.d.ts.map +1 -0
- package/dist/internal/fetcher-runtime.js +26 -0
- package/dist/internal/fetcher-runtime.js.map +1 -0
- package/dist/internal/head-merge.d.ts +2 -0
- package/dist/internal/head-merge.d.ts.map +1 -1
- package/dist/internal/head-merge.js +17 -1
- package/dist/internal/head-merge.js.map +1 -1
- package/dist/internal/identity-policy.d.ts +51 -0
- package/dist/internal/identity-policy.d.ts.map +1 -0
- package/dist/internal/identity-policy.js +67 -0
- package/dist/internal/identity-policy.js.map +1 -0
- package/dist/internal/parity.d.ts +104 -8
- package/dist/internal/parity.d.ts.map +1 -1
- package/dist/internal/parity.js +472 -56
- package/dist/internal/parity.js.map +1 -1
- package/dist/internal/query-runtime.d.ts +8 -0
- package/dist/internal/query-runtime.d.ts.map +1 -0
- package/dist/internal/query-runtime.js +29 -0
- package/dist/internal/query-runtime.js.map +1 -0
- package/dist/internal/render-document.d.ts +372 -0
- package/dist/internal/render-document.d.ts.map +1 -0
- package/dist/internal/render-document.js +744 -0
- package/dist/internal/render-document.js.map +1 -0
- package/dist/internal/runtime-contract.d.ts +48 -0
- package/dist/internal/runtime-contract.d.ts.map +1 -0
- package/dist/internal/runtime-contract.js +27 -0
- package/dist/internal/runtime-contract.js.map +1 -0
- package/dist/internal/web-app.d.ts +171 -0
- package/dist/internal/web-app.d.ts.map +1 -0
- package/dist/internal/web-app.js +844 -0
- package/dist/internal/web-app.js.map +1 -0
- package/dist/islands.d.ts +50 -2
- package/dist/islands.d.ts.map +1 -1
- package/dist/islands.js +96 -36
- package/dist/islands.js.map +1 -1
- package/dist/manifest.d.ts +41 -6
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js.map +1 -1
- package/dist/module-graph.d.ts.map +1 -1
- package/dist/module-graph.js +22 -9
- package/dist/module-graph.js.map +1 -1
- package/dist/nano.d.ts +125 -0
- package/dist/nano.d.ts.map +1 -0
- package/dist/nano.js +190 -0
- package/dist/nano.js.map +1 -0
- package/dist/plugins/css-modules.js +2 -2
- package/dist/plugins/css-modules.js.map +1 -1
- package/dist/plugins/kit.d.ts +12 -0
- package/dist/plugins/kit.d.ts.map +1 -1
- package/dist/plugins/kit.js +62 -12
- package/dist/plugins/kit.js.map +1 -1
- package/dist/plugins/postcss.js +2 -2
- package/dist/plugins/postcss.js.map +1 -1
- package/dist/plugins/scss.js +2 -2
- package/dist/plugins/scss.js.map +1 -1
- package/dist/plugins/stylex.d.ts +70 -0
- package/dist/plugins/stylex.d.ts.map +1 -0
- package/dist/plugins/stylex.js +166 -0
- package/dist/plugins/stylex.js.map +1 -0
- package/dist/plugins/svg.js +2 -2
- package/dist/plugins/svg.js.map +1 -1
- package/dist/render-seam.d.ts +5 -0
- package/dist/render-seam.d.ts.map +1 -1
- package/dist/render-seam.js +10 -0
- package/dist/render-seam.js.map +1 -1
- package/dist/router.d.ts +11 -1
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +254 -47
- package/dist/router.js.map +1 -1
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +34 -16
- package/dist/vite.js.map +1 -1
- package/package.json +49 -2
- package/src/boundary.ts +407 -0
- package/src/build-plan.ts +741 -0
- package/src/build-vite.ts +6 -7
- package/src/build.ts +120 -730
- package/src/chunk-names.ts +3 -2
- package/src/dev-ssr-graph.ts +63 -28
- package/src/diagnostic.ts +14 -2
- package/src/fonts-google.ts +3 -1
- package/src/fs.ts +2 -1
- package/src/index.ts +107 -2553
- package/src/internal/codegen.ts +400 -0
- package/src/internal/fetcher-runtime.ts +36 -0
- package/src/internal/head-merge.ts +19 -1
- package/src/internal/identity-policy.ts +94 -0
- package/src/internal/parity.ts +603 -71
- package/src/internal/query-runtime.ts +31 -0
- package/src/internal/render-document.ts +1116 -0
- package/src/internal/runtime-contract.ts +54 -0
- package/src/internal/web-app.ts +1114 -0
- package/src/islands.ts +106 -40
- package/src/manifest.ts +50 -3
- package/src/module-graph.ts +23 -9
- package/src/nano.ts +246 -0
- package/src/plugins/css-modules.ts +2 -2
- package/src/plugins/kit.ts +65 -12
- package/src/plugins/postcss.ts +2 -2
- package/src/plugins/scss.ts +2 -2
- package/src/plugins/stylex.ts +298 -0
- package/src/plugins/svg.ts +2 -2
- package/src/render-seam.ts +6 -0
- package/src/router.ts +293 -51
- package/src/vite.ts +41 -15
package/src/vite.ts
CHANGED
|
@@ -16,11 +16,12 @@ import {
|
|
|
16
16
|
type IncomingMessage,
|
|
17
17
|
type ServerResponse,
|
|
18
18
|
} from "node:http"
|
|
19
|
-
import { relative, resolve as resolvePath } from "node:path"
|
|
19
|
+
import { isAbsolute, join, relative, resolve as resolvePath, sep } from "node:path"
|
|
20
20
|
import { createDevDiagnostics } from "./dev-diagnostics.ts"
|
|
21
21
|
import { listenOrExplain } from "./dev-port.ts"
|
|
22
22
|
import { discoverRoutes } from "./fs.ts"
|
|
23
23
|
import { DEFAULT_DEV_PORT, generateClientEntry, setSsrModuleLoader } from "./index.ts"
|
|
24
|
+
import { viteDedupePackages } from "./internal/identity-policy.ts"
|
|
24
25
|
import {
|
|
25
26
|
assertIdentityParity,
|
|
26
27
|
collectIdentityParity,
|
|
@@ -30,7 +31,13 @@ import {
|
|
|
30
31
|
import { vitePublicEnvPrefix } from "./internal/server-boundary.ts"
|
|
31
32
|
import { importVite } from "./internal/vite-import.ts"
|
|
32
33
|
import { scopedName } from "./plugins/css-modules.ts"
|
|
33
|
-
import {
|
|
34
|
+
import {
|
|
35
|
+
DEV_ROOT_ENV,
|
|
36
|
+
DEV_ROUTES_ENV,
|
|
37
|
+
normalizeFilePath,
|
|
38
|
+
portablePath,
|
|
39
|
+
reproduciblePath,
|
|
40
|
+
} from "./plugins/kit.ts"
|
|
34
41
|
import { viteServerFnStub } from "./plugins/vite-server-fn.ts"
|
|
35
42
|
import { viteServerOnlyEmpty } from "./plugins/vite-server-only.ts"
|
|
36
43
|
|
|
@@ -138,6 +145,19 @@ export { LAST_ERROR_PATH } from "./diagnostic.ts"
|
|
|
138
145
|
// The codegen'd client entry is written here (at the Vite root) so Vite serves + HMRs it.
|
|
139
146
|
const DEV_ENTRY = ".nifra-vite-entry.tsx"
|
|
140
147
|
|
|
148
|
+
/** Candidate spellings for Vite's module-graph map. Vite has used native and slash-normalized
|
|
149
|
+
* absolute Windows paths across versions, while watcher events can additionally arrive as a file URL. */
|
|
150
|
+
const modulePathCandidates = (path: string): string[] => {
|
|
151
|
+
const native = normalizeFilePath(path)
|
|
152
|
+
const portable = portablePath(path)
|
|
153
|
+
return [...new Set([path, native, portable])]
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const pathInside = (root: string, path: string): boolean => {
|
|
157
|
+
const rel = relative(resolvePath(root), resolvePath(normalizeFilePath(path)))
|
|
158
|
+
return rel === "" || (rel !== ".." && !rel.startsWith(`..${sep}`) && !isAbsolute(rel))
|
|
159
|
+
}
|
|
160
|
+
|
|
141
161
|
const readNodeBody = async (req: IncomingMessage): Promise<Buffer | undefined> => {
|
|
142
162
|
if (req.method === "GET" || req.method === "HEAD") return undefined
|
|
143
163
|
const chunks: Buffer[] = []
|
|
@@ -343,7 +363,8 @@ export async function createViteDevServer(options: ViteDevServerOptions): Promis
|
|
|
343
363
|
process.env[DEV_ROUTES_ENV] = routesDir
|
|
344
364
|
|
|
345
365
|
// Codegen the client entry with Vite-servable, root-relative specifiers (e.g. `/routes/index.tsx`).
|
|
346
|
-
const toUrl = (file: string): string =>
|
|
366
|
+
const toUrl = (file: string): string =>
|
|
367
|
+
`/${relative(root, join(routesDir, file)).replaceAll("\\", "/")}`
|
|
347
368
|
const writeClientEntry = (): void => {
|
|
348
369
|
const manifest = discoverRoutes(routesDir)
|
|
349
370
|
writeFileSync(
|
|
@@ -467,12 +488,13 @@ export async function createViteDevServer(options: ViteDevServerOptions): Promis
|
|
|
467
488
|
plugins: [viteServerFnStub(), viteServerOnlyEmpty(), ...plugins],
|
|
468
489
|
resolve: {
|
|
469
490
|
conditions: resolveConditions,
|
|
470
|
-
// Dedupe
|
|
471
|
-
// from a SIBLING app's node_modules, so the dev server
|
|
472
|
-
// dispatcher → `resolveDispatcher().useState` null
|
|
473
|
-
//
|
|
474
|
-
//
|
|
475
|
-
|
|
491
|
+
// Dedupe each framework runtime to ONE copy. In a multi-root workspace a shared package can pull
|
|
492
|
+
// react/react-dom (or preact, or svelte) from a SIBLING app's node_modules, so the dev server
|
|
493
|
+
// loads two cores → a second hook dispatcher/options global → `resolveDispatcher().useState` null
|
|
494
|
+
// on any hook-using route (the error points at the component, not the resolution - brutal to
|
|
495
|
+
// diagnose). Same policy table the production builds read, so dev matches prod. No-op per
|
|
496
|
+
// framework the app does not use (the package simply isn't present to dedupe).
|
|
497
|
+
dedupe: [...viteDedupePackages()],
|
|
476
498
|
},
|
|
477
499
|
ssr: {
|
|
478
500
|
// Explicit listing forces external even for workspace-LINKED packages (Vite's default keeps
|
|
@@ -521,10 +543,13 @@ export async function createViteDevServer(options: ViteDevServerOptions): Promis
|
|
|
521
543
|
const invalidateImporterClosure = (path: string): void => {
|
|
522
544
|
const graph = vite.moduleGraph
|
|
523
545
|
if (graph === undefined) return
|
|
524
|
-
const roots = graph.getModulesByFile(path)
|
|
525
|
-
if (roots === undefined) return
|
|
526
546
|
const seen = new Set<ViteModuleNode>()
|
|
527
|
-
const stack = [
|
|
547
|
+
const stack: ViteModuleNode[] = []
|
|
548
|
+
for (const candidate of modulePathCandidates(path)) {
|
|
549
|
+
const roots = graph.getModulesByFile(candidate)
|
|
550
|
+
if (roots !== undefined) stack.push(...roots)
|
|
551
|
+
}
|
|
552
|
+
if (stack.length === 0) return
|
|
528
553
|
for (let mod = stack.pop(); mod !== undefined; mod = stack.pop()) {
|
|
529
554
|
if (seen.has(mod)) continue
|
|
530
555
|
seen.add(mod)
|
|
@@ -547,11 +572,12 @@ export async function createViteDevServer(options: ViteDevServerOptions): Promis
|
|
|
547
572
|
})
|
|
548
573
|
.catch((err) => console.error("[nifra/web/vite] app re-create failed:", err))
|
|
549
574
|
}
|
|
550
|
-
vite.watcher.on("change", refreshApp)
|
|
575
|
+
vite.watcher.on("change", (path) => refreshApp(normalizeFilePath(path)))
|
|
551
576
|
for (const event of ["add", "unlink"] as const) {
|
|
552
577
|
vite.watcher.on(event, (path) => {
|
|
553
|
-
|
|
554
|
-
|
|
578
|
+
const filePath = normalizeFilePath(path)
|
|
579
|
+
if (pathInside(routesDir, filePath)) writeClientEntry()
|
|
580
|
+
refreshApp(filePath)
|
|
555
581
|
})
|
|
556
582
|
}
|
|
557
583
|
|