@teyik0/furin 0.4.0-alpha.1 → 0.5.0-alpha.1
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/adapter/bun.d.ts +2 -18
- package/dist/adapter/package.d.ts +2 -2
- package/dist/adapter/runtime-build.d.ts +33 -0
- package/dist/adapter/vercel.d.ts +3 -0
- package/dist/build/client.d.ts +1 -1
- package/dist/build/compile-entry.d.ts +6 -4
- package/dist/build/compile-entry.ts +36 -77
- package/dist/build/elysia-aot.d.ts +9 -0
- package/dist/build/entry-template.d.ts +9 -3
- package/dist/build/entry-template.ts +55 -13
- package/dist/build/index.d.ts +1 -1
- package/dist/build/index.js +8912 -6391
- package/dist/build/server-app-entry.d.ts +12 -0
- package/dist/build/ssg-cache.d.ts +13 -0
- package/dist/build/types.d.ts +25 -2
- package/dist/build/virtual-entry.d.ts +8 -0
- package/dist/cache.d.ts +6 -0
- package/dist/cache.js +282 -0
- package/dist/cli/index.js +8936 -6308
- package/dist/cli/preview.d.ts +7 -0
- package/dist/client/boundaries.d.ts +1 -0
- package/dist/client/browser-events-runtime.d.ts +2 -0
- package/dist/client/browser-events.d.ts +2 -0
- package/dist/client/define-route.d.ts +9 -8
- package/dist/client/dev-error-overlay.d.ts +1 -0
- package/dist/client/dev-error-overlay.ts +201 -0
- package/dist/client/document.d.ts +1 -0
- package/dist/client/hmr.d.ts +4 -2
- package/dist/client/internal/runtime-types.d.ts +8 -1
- package/dist/client/link.js +465 -86
- package/dist/client/router/provider.d.ts +1 -1
- package/dist/client/router/sync-catch-up.d.ts +1 -1
- package/dist/client/router/types.d.ts +8 -10
- package/dist/client/sync.d.ts +1 -0
- package/dist/client.js +37 -23
- package/dist/config.d.ts +35 -17
- package/dist/config.js +10 -2
- package/dist/define-route.d.ts +282 -1015
- package/dist/devtools/protocol.d.ts +2 -2
- package/dist/furin.d.ts +21 -6
- package/dist/furin.js +12823 -8484
- package/dist/plugin/index.js +476 -7
- package/dist/plugin/routes.d.ts +10 -3
- package/dist/rsc/build/index.d.ts +5 -1
- package/dist/server/assets/production.d.ts +3 -0
- package/dist/server/auto-invalidate/plugin.d.ts +8 -24
- package/dist/server/auto-invalidate/runtime.d.ts +2 -2
- package/dist/server/browser-events/plugin.d.ts +11 -0
- package/dist/server/browser-events/types.d.ts +9 -0
- package/dist/server/cache/invalidation.d.ts +2 -3
- package/dist/server/cache/isr.d.ts +1 -0
- package/dist/server/cache/page-cache-state.d.ts +5 -0
- package/dist/server/cache/page-cache.d.ts +53 -0
- package/dist/server/cache/purger.d.ts +7 -0
- package/dist/server/cache/redis/index.d.ts +39 -0
- package/dist/server/cache/redis/index.js +396 -0
- package/dist/server/cache/redis/scripts.d.ts +6 -0
- package/dist/server/cache/runtime-cache.d.ts +21 -0
- package/dist/server/context-logger.d.ts +2 -2
- package/dist/server/dev/browser-events.d.ts +4 -0
- package/dist/server/dev/diagnostics.d.ts +39 -0
- package/dist/server/dev/error.d.ts +17 -0
- package/dist/server/dev/graph.d.ts +86 -0
- package/dist/server/dev/plugin.d.ts +9 -0
- package/dist/server/dev/request-security.d.ts +1 -0
- package/dist/server/dev/rewrite-module-specifiers.d.ts +7 -0
- package/dist/server/dev/runtime.production.d.ts +6 -0
- package/dist/server/dev/symbolicate.d.ts +11 -0
- package/dist/server/dev/transform-failure.d.ts +4 -0
- package/dist/server/dev-page-plugin.d.ts +7 -0
- package/dist/server/dev-page-plugin.production.d.ts +1 -0
- package/dist/server/devtools/hub.d.ts +3 -2
- package/dist/server/devtools/instrumentation.d.ts +1 -1
- package/dist/server/devtools/instrumentation.production.d.ts +1 -1
- package/dist/server/devtools/plugin.d.ts +1 -1
- package/dist/server/evlog.d.ts +14 -0
- package/dist/server/external-prerender.d.ts +2 -0
- package/dist/server/instance.d.ts +2 -2
- package/dist/server/internal.d.ts +20 -2
- package/dist/server/internal.js +2973 -1
- package/dist/server/render/element.d.ts +1 -0
- package/dist/server/render/index.d.ts +1 -1
- package/dist/server/render/index.ts +1 -1
- package/dist/server/render/not-found.d.ts +1 -1
- package/dist/server/render/ppr-document.d.ts +21 -0
- package/dist/server/render/ppr-request.d.ts +26 -0
- package/dist/server/render/ppr-route.d.ts +3 -1
- package/dist/server/render/shell.ts +0 -12
- package/dist/server/render/ssg.d.ts +7 -0
- package/dist/server/render/ssr.d.ts +17 -6
- package/dist/server/render/static-params.d.ts +4 -0
- package/dist/server/router/defined-route.d.ts +1 -1
- package/dist/server/router/hmr.production.d.ts +2 -0
- package/dist/server/router/patterns.d.ts +1 -0
- package/dist/server/router/plugin.d.ts +3 -1
- package/dist/server/router/schemas.d.ts +1 -0
- package/dist/server/sync/adapter.d.ts +13 -0
- package/dist/server/sync/config.d.ts +5 -5
- package/dist/server/sync/index.d.ts +6 -6
- package/dist/server/sync/index.js +1252 -599
- package/dist/server/sync/notifier.d.ts +1 -0
- package/dist/server/sync/plugin.d.ts +31 -158
- package/dist/server/sync/postgres/index.d.ts +12 -1
- package/dist/server/sync/postgres/index.js +101 -6
- package/dist/server/sync/stream.d.ts +37 -61
- package/dist/shared/await.d.ts +3 -3
- package/dist/shared/browser-events.d.ts +22 -0
- package/dist/shared/compact-json.d.ts +8 -0
- package/dist/shared/deferred-ndjson.d.ts +6 -5
- package/dist/shared/dev-diagnostics.d.ts +36 -0
- package/dist/shared/elysia-contract.d.ts +8 -14
- package/dist/shared/prefix.d.ts +2 -0
- package/package.json +26 -11
- package/src/adapter/README.md +53 -1
- package/src/adapter/bun.ts +106 -283
- package/src/adapter/package.ts +21 -11
- package/src/adapter/runtime-build.ts +382 -0
- package/src/adapter/static.ts +87 -8
- package/src/adapter/vercel.ts +876 -0
- package/src/build/client.ts +55 -13
- package/src/build/compile-entry.ts +36 -77
- package/src/build/elysia-aot.ts +102 -0
- package/src/build/entry-template.ts +55 -13
- package/src/build/hydrate.ts +60 -20
- package/src/build/index.ts +17 -8
- package/src/build/production-instrumentation.ts +56 -4
- package/src/build/server-app-entry.ts +60 -0
- package/src/build/shared.ts +5 -2
- package/src/build/ssg-cache.ts +93 -12
- package/src/build/types.ts +31 -2
- package/src/build/virtual-entry.ts +28 -0
- package/src/cache.ts +26 -0
- package/src/cli/config.ts +3 -3
- package/src/cli/index.ts +58 -3
- package/src/cli/preview.ts +90 -0
- package/src/client/boundaries.tsx +10 -1
- package/src/client/browser-events-runtime.ts +204 -0
- package/src/client/browser-events.ts +22 -0
- package/src/client/define-route.ts +7 -17
- package/src/client/dev-error-overlay.ts +201 -0
- package/src/client/document.tsx +4 -7
- package/src/client/hmr.ts +26 -3
- package/src/client/internal/runtime-types.ts +10 -1
- package/src/client/router/boundary-tree.tsx +4 -4
- package/src/client/router/provider.tsx +165 -63
- package/src/client/router/sync-catch-up.ts +3 -4
- package/src/client/router/types.ts +6 -6
- package/src/client/sync.ts +1 -0
- package/src/config.ts +28 -2
- package/src/define-route.ts +285 -134
- package/src/devtools/devtools-element.js +56 -77
- package/src/devtools/protocol.ts +2 -2
- package/src/furin.ts +272 -203
- package/src/plugin/route-config-autofix.ts +11 -2
- package/src/plugin/routes.ts +291 -65
- package/src/plugin/transform-client.ts +685 -3
- package/src/react-dom-edge.d.ts +6 -0
- package/src/rsc/build/index.ts +15 -3
- package/src/server/assets/production.ts +99 -0
- package/src/server/auto-invalidate/plugin.ts +4 -4
- package/src/server/auto-invalidate/runtime.ts +76 -41
- package/src/server/browser-events/plugin.ts +173 -0
- package/src/server/browser-events/types.ts +11 -0
- package/src/server/cache/dev-loader.ts +30 -29
- package/src/server/cache/invalidation.ts +67 -35
- package/src/server/cache/isr.ts +9 -0
- package/src/server/cache/page-cache-state.ts +22 -0
- package/src/server/cache/page-cache.ts +300 -0
- package/src/server/cache/purger.ts +41 -0
- package/src/server/cache/redis/index.ts +350 -0
- package/src/server/cache/redis/scripts.ts +160 -0
- package/src/server/cache/runtime-cache.ts +137 -0
- package/src/server/context-logger.ts +5 -5
- package/src/server/dev/browser-events.ts +54 -0
- package/src/server/dev/diagnostics.ts +297 -0
- package/src/server/dev/error.ts +148 -0
- package/src/server/dev/graph.ts +438 -0
- package/src/server/dev/plugin.ts +130 -0
- package/src/server/dev/request-security.ts +38 -0
- package/src/server/dev/rewrite-module-specifiers.ts +81 -0
- package/src/server/dev/runtime.production.ts +28 -0
- package/src/server/dev/symbolicate.ts +135 -0
- package/src/server/dev/transform-failure.ts +8 -0
- package/src/server/dev-page-plugin.production.ts +3 -0
- package/src/server/dev-page-plugin.ts +136 -53
- package/src/server/devtools/hub.ts +6 -5
- package/src/server/devtools/instrumentation.production.ts +1 -1
- package/src/server/devtools/instrumentation.ts +12 -6
- package/src/server/devtools/plugin.ts +7 -150
- package/src/server/evlog.ts +99 -0
- package/src/server/external-prerender.ts +10 -0
- package/src/server/instance.ts +3 -3
- package/src/server/internal.ts +46 -2
- package/src/server/render/assemble.ts +4 -4
- package/src/server/render/document.tsx +13 -4
- package/src/server/render/element.tsx +18 -14
- package/src/server/render/index.ts +1 -1
- package/src/server/render/isr.ts +509 -136
- package/src/server/render/loaders.ts +31 -15
- package/src/server/render/not-found.ts +32 -8
- package/src/server/render/ppr-document.ts +239 -0
- package/src/server/render/ppr-request.ts +104 -0
- package/src/server/render/ppr-route.ts +335 -28
- package/src/server/render/shell.ts +0 -12
- package/src/server/render/ssg.ts +186 -24
- package/src/server/render/ssr.ts +215 -89
- package/src/server/render/static-params.ts +174 -0
- package/src/server/render/template.ts +47 -11
- package/src/server/router/defined-route.ts +9 -40
- package/src/server/router/hmr.production.ts +7 -0
- package/src/server/router/hmr.ts +108 -67
- package/src/server/router/patterns.ts +5 -1
- package/src/server/router/plugin.ts +164 -66
- package/src/server/router/schema-merge.ts +1 -1
- package/src/server/router/schemas.ts +174 -61
- package/src/server/router/source-version.ts +3 -10
- package/src/server/sync/adapter.ts +13 -0
- package/src/server/sync/config.ts +12 -12
- package/src/server/sync/index.ts +8 -8
- package/src/server/sync/notifier.ts +1 -0
- package/src/server/sync/plugin.ts +18 -11
- package/src/server/sync/postgres/index.ts +111 -5
- package/src/server/sync/response.ts +3 -3
- package/src/server/sync/runtime.ts +12 -0
- package/src/server/sync/stream.ts +78 -113
- package/src/shared/await.tsx +3 -3
- package/src/shared/browser-events.ts +28 -0
- package/src/shared/compact-json.ts +77 -0
- package/src/shared/deferred-ndjson.ts +20 -6
- package/src/shared/dev-diagnostics.ts +44 -0
- package/src/shared/elysia-contract.ts +23 -25
- package/src/shared/prefix.ts +8 -0
- package/src/shared/route-map.ts +10 -1
package/src/adapter/package.ts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { existsSync, rmSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { join, relative, resolve } from "node:path";
|
|
3
|
-
import { type
|
|
3
|
+
import { createBuildFingerprint, type RuntimeTargetApp } from "../adapter/runtime-build.ts";
|
|
4
4
|
import { runBunBuild } from "../build/bun-build.ts";
|
|
5
5
|
import { buildClient } from "../build/client.ts";
|
|
6
6
|
import { buildEntrySource } from "../build/entry-template.ts";
|
|
7
7
|
import { copyDirRecursive, ensureDir, toPosixPath } from "../build/shared.ts";
|
|
8
8
|
import { buildSSGCacheSnapshot } from "../build/ssg-cache.ts";
|
|
9
9
|
import type { BuildAppOptions, PackageTargetBuildManifest } from "../build/types.ts";
|
|
10
|
-
import {
|
|
10
|
+
import { createVirtualBuildEntry } from "../build/virtual-entry.ts";
|
|
11
|
+
import {
|
|
12
|
+
composableRouteModuleSpecifier,
|
|
13
|
+
createRoutesPlugin,
|
|
14
|
+
routeSourcePaths,
|
|
15
|
+
} from "../plugin/routes.ts";
|
|
11
16
|
import { ssgRouteCache } from "../server/cache/ssg.ts";
|
|
12
17
|
import { generateProdIndexHtml } from "../server/render/shell.ts";
|
|
13
18
|
import { setProductionTemplateContent } from "../server/render/template.ts";
|
|
@@ -36,12 +41,13 @@ import { setProductionTemplateContent } from "../server/render/template.ts";
|
|
|
36
41
|
* package without sources is production-only; its context is found by prefix.
|
|
37
42
|
*/
|
|
38
43
|
export async function buildPackageTarget(
|
|
39
|
-
app:
|
|
44
|
+
app: RuntimeTargetApp,
|
|
40
45
|
rootDir: string,
|
|
41
46
|
buildRoot: string,
|
|
42
47
|
options: BuildAppOptions
|
|
43
48
|
): Promise<PackageTargetBuildManifest> {
|
|
44
49
|
const { prefix, root, routes, pagesDir } = app;
|
|
50
|
+
const modulePaths = routeSourcePaths(app);
|
|
45
51
|
const targetDir = join(buildRoot, "package");
|
|
46
52
|
|
|
47
53
|
rmSync(targetDir, { force: true, recursive: true });
|
|
@@ -50,10 +56,13 @@ export async function buildPackageTarget(
|
|
|
50
56
|
const { entryChunk, cssChunks } = await buildClient(routes, {
|
|
51
57
|
basePath: prefix,
|
|
52
58
|
clientLogging: options.clientLogging ?? false,
|
|
59
|
+
metafilePath: options.analyze ? join(buildRoot, "analysis", "package-client.json") : undefined,
|
|
60
|
+
optimizeImports: options.optimizeImports,
|
|
53
61
|
outDir: targetDir,
|
|
54
62
|
pagesDir,
|
|
55
63
|
plugins: options.plugins,
|
|
56
64
|
publicPath: `${prefix}/_client/`,
|
|
65
|
+
reactCompiler: options.reactCompiler,
|
|
57
66
|
rootLayout: root.path,
|
|
58
67
|
});
|
|
59
68
|
|
|
@@ -66,7 +75,9 @@ export async function buildPackageTarget(
|
|
|
66
75
|
cssChunks,
|
|
67
76
|
routes,
|
|
68
77
|
root,
|
|
69
|
-
null
|
|
78
|
+
null,
|
|
79
|
+
modulePaths,
|
|
80
|
+
rootDir
|
|
70
81
|
);
|
|
71
82
|
const buildId = Bun.hash(buildFingerprint).toString(16).slice(0, 12);
|
|
72
83
|
|
|
@@ -124,8 +135,8 @@ export async function buildPackageTarget(
|
|
|
124
135
|
{
|
|
125
136
|
buildId,
|
|
126
137
|
clientLogging: options.clientLogging ?? false,
|
|
127
|
-
modulePaths
|
|
128
|
-
nativeRoutes:
|
|
138
|
+
modulePaths,
|
|
139
|
+
nativeRoutes: composableRouteModuleSpecifier(app),
|
|
129
140
|
prefix,
|
|
130
141
|
rootConventions,
|
|
131
142
|
rootPath: root.path,
|
|
@@ -138,10 +149,11 @@ export async function buildPackageTarget(
|
|
|
138
149
|
mode: "register",
|
|
139
150
|
});
|
|
140
151
|
const registerEntry = join(targetDir, "register.ts");
|
|
141
|
-
|
|
152
|
+
const register = createVirtualBuildEntry(registerEntry, registerSource, "ts");
|
|
142
153
|
|
|
143
154
|
const result = await runBunBuild({
|
|
144
|
-
entrypoints: [
|
|
155
|
+
entrypoints: [register.entrypoint],
|
|
156
|
+
files: register.files,
|
|
145
157
|
minify: false,
|
|
146
158
|
naming: { chunk: "[name]-[hash].[ext]", entry: "[name].[ext]" },
|
|
147
159
|
outdir: targetDir,
|
|
@@ -150,6 +162,7 @@ export async function buildPackageTarget(
|
|
|
150
162
|
// the package's own page sources get bundled in.
|
|
151
163
|
packages: "external",
|
|
152
164
|
plugins: [
|
|
165
|
+
register.plugin,
|
|
153
166
|
...(options.plugins ?? []),
|
|
154
167
|
createRoutesPlugin({ instances: [app], target: "server" }),
|
|
155
168
|
],
|
|
@@ -159,9 +172,6 @@ export async function buildPackageTarget(
|
|
|
159
172
|
if (!result.success) {
|
|
160
173
|
throw new AggregateError(result.logs, "[furin] package register build failed");
|
|
161
174
|
}
|
|
162
|
-
rmSync(registerEntry, { force: true });
|
|
163
|
-
rmSync(join(targetDir, "_hydrate.tsx"), { force: true });
|
|
164
|
-
|
|
165
175
|
// 2. index.js — the factory the host mounts. The baked relative pagesDir
|
|
166
176
|
// keeps monorepo dev working; in a published package the compile context is
|
|
167
177
|
// resolved by prefix instead.
|
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
import { existsSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { buildClient } from "../build/client.ts";
|
|
5
|
+
import type { BuildEntryOptions, EntryAppContext } from "../build/entry-template.ts";
|
|
6
|
+
import { toPosixPath } from "../build/shared.ts";
|
|
7
|
+
import {
|
|
8
|
+
buildRoutePrerenders,
|
|
9
|
+
buildSSGCacheSnapshot,
|
|
10
|
+
type RoutePrerender,
|
|
11
|
+
type SSGCacheSnapshot,
|
|
12
|
+
} from "../build/ssg-cache.ts";
|
|
13
|
+
import type { BuildAppOptions } from "../build/types.ts";
|
|
14
|
+
import { composableRouteModuleSpecifier, routeSourcePaths } from "../plugin/routes.ts";
|
|
15
|
+
import { buildRscGraph } from "../rsc/build/index.ts";
|
|
16
|
+
import { ssgRouteCache } from "../server/cache/ssg.ts";
|
|
17
|
+
import { hasRequestLoader } from "../server/render/loaders.ts";
|
|
18
|
+
import { generateProdIndexHtml } from "../server/render/shell.ts";
|
|
19
|
+
import { setProductionTemplateContent } from "../server/render/template.ts";
|
|
20
|
+
import type { ResolvedRoute, RootLayout } from "../server/router/types.ts";
|
|
21
|
+
import { clientDirNameForPrefix } from "../shared/prefix.ts";
|
|
22
|
+
|
|
23
|
+
// import.meta.resolve() runs at runtime (not inlined at bundle time), resolves
|
|
24
|
+
// through package exports, and is the Web-standard API. The main entry is
|
|
25
|
+
// `src/furin.ts` (or `dist/furin.js`), so we strip two path segments to reach
|
|
26
|
+
// the package root.
|
|
27
|
+
const _pkgRoot = dirname(dirname(fileURLToPath(import.meta.resolve("@teyik0/furin"))));
|
|
28
|
+
const _pkgSrcDir = existsSync(join(_pkgRoot, "src", "furin.ts"))
|
|
29
|
+
? join(_pkgRoot, "src")
|
|
30
|
+
: join(_pkgRoot, "dist");
|
|
31
|
+
// The published package always ships `src/` (see package.json "files"), and the
|
|
32
|
+
// "bun" export condition resolves to the TypeScript sources, so the fingerprint
|
|
33
|
+
// inputs are always the `.ts` files. Some of these inputs (e.g. entry-template)
|
|
34
|
+
// are never emitted to `dist/` as `.js`, so detecting the extension off the dist
|
|
35
|
+
// copy would point at files that don't exist and silently weaken the build ID.
|
|
36
|
+
const _ext = ".ts";
|
|
37
|
+
const PPR_ROUTE_IMPORT_RE = /ppr-route(?:\.ts)?$/;
|
|
38
|
+
const ANY_MODULE_RE = /.*/;
|
|
39
|
+
const REACT_SERVER_IMPORT_RE = /^react-dom\/server(?:\.edge)?$/;
|
|
40
|
+
const REACT_STATIC_IMPORT_RE = /^react-dom\/static\.edge$/;
|
|
41
|
+
const BUILD_ID_INPUT_PATHS = [
|
|
42
|
+
`${_pkgSrcDir}/build/compile-entry${_ext}`,
|
|
43
|
+
`${_pkgSrcDir}/build/entry-template${_ext}`,
|
|
44
|
+
`${_pkgSrcDir}/plugin/routes${_ext}`,
|
|
45
|
+
`${_pkgSrcDir}/server/render/document.tsx`,
|
|
46
|
+
`${_pkgSrcDir}/server/render/element.tsx`,
|
|
47
|
+
`${_pkgSrcDir}/server/render/index${_ext}`,
|
|
48
|
+
`${_pkgSrcDir}/server/render/isr${_ext}`,
|
|
49
|
+
`${_pkgSrcDir}/server/render/loaders${_ext}`,
|
|
50
|
+
`${_pkgSrcDir}/server/render/not-found${_ext}`,
|
|
51
|
+
`${_pkgSrcDir}/server/render/ppr-route${_ext}`,
|
|
52
|
+
`${_pkgSrcDir}/server/render/ppr-document${_ext}`,
|
|
53
|
+
`${_pkgSrcDir}/server/render/route-frame-transport${_ext}`,
|
|
54
|
+
`${_pkgSrcDir}/server/render/shell${_ext}`,
|
|
55
|
+
`${_pkgSrcDir}/server/render/ssr${_ext}`,
|
|
56
|
+
`${_pkgSrcDir}/shared/compact-json${_ext}`,
|
|
57
|
+
`${_pkgSrcDir}/shared/deferred-ndjson${_ext}`,
|
|
58
|
+
`${_pkgSrcDir}/shared/route-frame${_ext}`,
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
function compareCodeUnits(a: string, b: string): number {
|
|
62
|
+
if (a < b) {
|
|
63
|
+
return -1;
|
|
64
|
+
}
|
|
65
|
+
if (a > b) {
|
|
66
|
+
return 1;
|
|
67
|
+
}
|
|
68
|
+
return 0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Deterministic build-ID input covering everything that can change rendered
|
|
73
|
+
* output: client chunks, route shape, route/root/error/not-found source
|
|
74
|
+
* contents and the framework's own render pipeline sources.
|
|
75
|
+
*/
|
|
76
|
+
export async function createBuildFingerprint(
|
|
77
|
+
entryChunk: string,
|
|
78
|
+
cssChunks: string[],
|
|
79
|
+
routes: ResolvedRoute[],
|
|
80
|
+
root: RootLayout,
|
|
81
|
+
serverEntry: string | null,
|
|
82
|
+
routeSources: string[],
|
|
83
|
+
projectRoot: string
|
|
84
|
+
): Promise<string> {
|
|
85
|
+
const fingerprintPaths = new Set<string>([
|
|
86
|
+
root.path,
|
|
87
|
+
...routes.map((route) => route.path),
|
|
88
|
+
...routeSources,
|
|
89
|
+
]);
|
|
90
|
+
if (serverEntry) {
|
|
91
|
+
fingerprintPaths.add(serverEntry);
|
|
92
|
+
}
|
|
93
|
+
if (root.errorPath) {
|
|
94
|
+
fingerprintPaths.add(root.errorPath);
|
|
95
|
+
}
|
|
96
|
+
if (root.notFoundPath) {
|
|
97
|
+
fingerprintPaths.add(root.notFoundPath);
|
|
98
|
+
}
|
|
99
|
+
for (const route of routes) {
|
|
100
|
+
for (const segment of route.segmentBoundaries) {
|
|
101
|
+
if (segment.errorPath) {
|
|
102
|
+
fingerprintPaths.add(segment.errorPath);
|
|
103
|
+
}
|
|
104
|
+
if (segment.notFoundPath) {
|
|
105
|
+
fingerprintPaths.add(segment.notFoundPath);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
for (const path of BUILD_ID_INPUT_PATHS) {
|
|
110
|
+
if (!existsSync(path)) {
|
|
111
|
+
console.warn(
|
|
112
|
+
`[furin] Warning: build fingerprint input "${toPosixPath(path)}" is missing — ` +
|
|
113
|
+
"the generated build ID may not reflect all framework changes."
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
fingerprintPaths.add(path);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const fileParts = await Promise.all(
|
|
120
|
+
[...fingerprintPaths].toSorted().map(async (path) => {
|
|
121
|
+
const content = existsSync(path) ? await Bun.file(path).text() : "";
|
|
122
|
+
return `${stableFingerprintPath(path, projectRoot)}:${content}`;
|
|
123
|
+
})
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
const routeParts = routes
|
|
127
|
+
.map((route) =>
|
|
128
|
+
JSON.stringify({
|
|
129
|
+
mode: route.mode,
|
|
130
|
+
path: stableFingerprintPath(route.path, projectRoot),
|
|
131
|
+
pattern: route.pattern,
|
|
132
|
+
})
|
|
133
|
+
)
|
|
134
|
+
.sort(compareCodeUnits);
|
|
135
|
+
|
|
136
|
+
return [entryChunk, ...[...cssChunks].toSorted(), ...routeParts, ...fileParts].join("\n");
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function stableFingerprintPath(path: string, projectRoot: string): string {
|
|
140
|
+
const projectPath = relative(projectRoot, path);
|
|
141
|
+
if (
|
|
142
|
+
!isAbsolute(projectPath) &&
|
|
143
|
+
projectPath !== ".." &&
|
|
144
|
+
!projectPath.startsWith("../") &&
|
|
145
|
+
!projectPath.startsWith("..\\")
|
|
146
|
+
) {
|
|
147
|
+
return `app/${toPosixPath(projectPath)}`;
|
|
148
|
+
}
|
|
149
|
+
const frameworkPath = relative(_pkgRoot, path);
|
|
150
|
+
if (
|
|
151
|
+
!isAbsolute(frameworkPath) &&
|
|
152
|
+
frameworkPath !== ".." &&
|
|
153
|
+
!frameworkPath.startsWith("../") &&
|
|
154
|
+
!frameworkPath.startsWith("..\\")
|
|
155
|
+
) {
|
|
156
|
+
return `furin/${toPosixPath(frameworkPath)}`;
|
|
157
|
+
}
|
|
158
|
+
return `external/${basename(path)}`;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function buildCompileMetadata(root: RootLayout, routes: ResolvedRoute[]) {
|
|
162
|
+
const rootConventions =
|
|
163
|
+
root.errorPath || root.notFoundPath
|
|
164
|
+
? {
|
|
165
|
+
errorPath: root.errorPath ? toPosixPath(root.errorPath) : undefined,
|
|
166
|
+
notFoundPath: root.notFoundPath ? toPosixPath(root.notFoundPath) : undefined,
|
|
167
|
+
}
|
|
168
|
+
: undefined;
|
|
169
|
+
|
|
170
|
+
const routeMetadata: NonNullable<EntryAppContext["routeMetadata"]> = {};
|
|
171
|
+
for (const route of routes) {
|
|
172
|
+
routeMetadata[toPosixPath(route.path)] = {
|
|
173
|
+
segmentBoundaries: route.segmentBoundaries.map((boundary) => ({
|
|
174
|
+
depth: boundary.depth,
|
|
175
|
+
errorPath: boundary.errorPath ? toPosixPath(boundary.errorPath) : undefined,
|
|
176
|
+
notFoundPath: boundary.notFoundPath ? toPosixPath(boundary.notFoundPath) : undefined,
|
|
177
|
+
path: toPosixPath(boundary.path),
|
|
178
|
+
})),
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return { rootConventions, routeMetadata };
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** One mounted app's build input (root + routes scanned from its pagesDir). */
|
|
186
|
+
export interface RuntimeTargetApp {
|
|
187
|
+
pagesDir: string;
|
|
188
|
+
prefix: string;
|
|
189
|
+
root: RootLayout;
|
|
190
|
+
routes: ResolvedRoute[];
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** Avoid loading React's resumable renderer in applications without PPR routes. */
|
|
194
|
+
export function pprRuntimePlugin(apps: RuntimeTargetApp[]): Bun.BunPlugin {
|
|
195
|
+
const enabled = apps.some((app) =>
|
|
196
|
+
app.routes.some(
|
|
197
|
+
(route) =>
|
|
198
|
+
route.mode !== "ssr" &&
|
|
199
|
+
(app.root.route.requestLoader !== undefined || hasRequestLoader(route))
|
|
200
|
+
)
|
|
201
|
+
);
|
|
202
|
+
const pprPath = resolve(_pkgSrcDir, "server/render/ppr-route.ts");
|
|
203
|
+
const reactServerPath = fileURLToPath(
|
|
204
|
+
import.meta.resolve(enabled ? "react-dom/server.edge" : "react-dom/server")
|
|
205
|
+
);
|
|
206
|
+
const reactStaticPath = fileURLToPath(import.meta.resolve("react-dom/static.edge"));
|
|
207
|
+
return {
|
|
208
|
+
name: "furin-ppr-runtime",
|
|
209
|
+
setup(build) {
|
|
210
|
+
// Resolve before user plugins: linked-project plugins commonly resolve
|
|
211
|
+
// peer dependencies from their own root and can otherwise recurse.
|
|
212
|
+
build.onResolve({ filter: REACT_SERVER_IMPORT_RE }, ({ importer }) =>
|
|
213
|
+
isFrameworkRuntimeImporter(importer) ? { path: reactServerPath } : undefined
|
|
214
|
+
);
|
|
215
|
+
build.onResolve({ filter: REACT_STATIC_IMPORT_RE }, ({ importer }) =>
|
|
216
|
+
isFrameworkRuntimeImporter(importer) ? { path: reactStaticPath } : undefined
|
|
217
|
+
);
|
|
218
|
+
if (enabled) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
build.onResolve({ filter: PPR_ROUTE_IMPORT_RE }, ({ path, importer }) => {
|
|
222
|
+
const absolute = resolve(dirname(importer.split("?")[0] as string), path);
|
|
223
|
+
if (absolute !== pprPath && `${absolute}.ts` !== pprPath) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
return { namespace: "furin-no-ppr", path: "ppr" };
|
|
227
|
+
});
|
|
228
|
+
build.onLoad({ filter: ANY_MODULE_RE, namespace: "furin-no-ppr" }, () => ({
|
|
229
|
+
contents: `export function clearPprRouteCache() {}
|
|
230
|
+
export function invalidatePprRoute() { return false; }
|
|
231
|
+
export function renderPprRoute() { throw new Error("[furin] PPR route missing from the build manifest."); }
|
|
232
|
+
export const runPprPublicLoaders = renderPprRoute;`,
|
|
233
|
+
loader: "js",
|
|
234
|
+
}));
|
|
235
|
+
},
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function isFrameworkRuntimeImporter(importer: string): boolean {
|
|
240
|
+
if (importer === "") {
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
const fromRuntimeRoot = relative(_pkgSrcDir, importer.split("?")[0] as string);
|
|
244
|
+
return (
|
|
245
|
+
fromRuntimeRoot !== ".." &&
|
|
246
|
+
!fromRuntimeRoot.startsWith("../") &&
|
|
247
|
+
!fromRuntimeRoot.startsWith("..\\")
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export interface RuntimeAppBuild {
|
|
252
|
+
buildId: string;
|
|
253
|
+
clientDir: string;
|
|
254
|
+
entryApp: BuildEntryOptions["apps"][number];
|
|
255
|
+
indexHtml: string;
|
|
256
|
+
prerenders: RoutePrerender[];
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/** Builds one app's client bundle and compile-context payload. */
|
|
260
|
+
export async function buildRuntimeApp(
|
|
261
|
+
app: RuntimeTargetApp,
|
|
262
|
+
projectRoot: string,
|
|
263
|
+
targetDir: string,
|
|
264
|
+
serverEntry: string | null,
|
|
265
|
+
options: BuildAppOptions,
|
|
266
|
+
targetName: "bun" | "vercel"
|
|
267
|
+
): Promise<RuntimeAppBuild> {
|
|
268
|
+
const { prefix, root, routes } = app;
|
|
269
|
+
const modulePaths = routeSourcePaths(app);
|
|
270
|
+
const clientDirName = clientDirNameForPrefix(prefix);
|
|
271
|
+
const label = prefix === "" ? "root app" : `app "${prefix}"`;
|
|
272
|
+
|
|
273
|
+
const { entryChunk, cssChunks } = await buildClient(routes, {
|
|
274
|
+
basePath: prefix,
|
|
275
|
+
clientDirName,
|
|
276
|
+
clientLogging: options.clientLogging ?? false,
|
|
277
|
+
metafilePath: options.analyze
|
|
278
|
+
? join(dirname(targetDir), "analysis", `${targetName}-${clientDirName}.json`)
|
|
279
|
+
: undefined,
|
|
280
|
+
optimizeImports: options.optimizeImports,
|
|
281
|
+
outDir: targetDir,
|
|
282
|
+
pagesDir: app.pagesDir,
|
|
283
|
+
plugins: options.plugins,
|
|
284
|
+
publicPath: `${prefix}/_client/`,
|
|
285
|
+
reactCompiler: options.reactCompiler,
|
|
286
|
+
rootLayout: root.path,
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
const buildFingerprint = await createBuildFingerprint(
|
|
290
|
+
`${prefix}\n${entryChunk}`,
|
|
291
|
+
cssChunks,
|
|
292
|
+
routes,
|
|
293
|
+
root,
|
|
294
|
+
serverEntry,
|
|
295
|
+
modulePaths,
|
|
296
|
+
projectRoot
|
|
297
|
+
);
|
|
298
|
+
const buildId = Bun.hash(buildFingerprint).toString(16).slice(0, 12);
|
|
299
|
+
|
|
300
|
+
const clientDir = join(targetDir, clientDirName);
|
|
301
|
+
const indexHtml = generateProdIndexHtml(entryChunk, cssChunks, buildId, undefined, false);
|
|
302
|
+
writeFileSync(join(clientDir, "index.html"), indexHtml);
|
|
303
|
+
|
|
304
|
+
setProductionTemplateContent(indexHtml);
|
|
305
|
+
ssgRouteCache().clear();
|
|
306
|
+
let ssgCache: SSGCacheSnapshot | undefined;
|
|
307
|
+
let prerenders: RoutePrerender[] = [];
|
|
308
|
+
if (serverEntry) {
|
|
309
|
+
if (targetName === "vercel") {
|
|
310
|
+
prerenders = await buildRoutePrerenders(routes, root, "http://localhost", prefix);
|
|
311
|
+
} else {
|
|
312
|
+
ssgCache = await buildSSGCacheSnapshot(routes, root, "http://localhost", prefix);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
const { rootConventions, routeMetadata } = buildCompileMetadata(root, routes);
|
|
317
|
+
console.log(`[furin] Built ${label} (buildId ${buildId})`);
|
|
318
|
+
|
|
319
|
+
return {
|
|
320
|
+
buildId,
|
|
321
|
+
clientDir,
|
|
322
|
+
entryApp: {
|
|
323
|
+
buildId,
|
|
324
|
+
clientLogging: options.clientLogging ?? false,
|
|
325
|
+
deploymentTarget: targetName === "vercel" ? "vercel" : undefined,
|
|
326
|
+
embed: options.compile === "embed" ? { clientDir } : undefined,
|
|
327
|
+
modulePaths,
|
|
328
|
+
nativeRoutes: composableRouteModuleSpecifier(app),
|
|
329
|
+
prefix,
|
|
330
|
+
rootConventions,
|
|
331
|
+
rootPath: root.path,
|
|
332
|
+
routeMetadata,
|
|
333
|
+
routes: routes.map((route) => ({
|
|
334
|
+
mode: route.mode,
|
|
335
|
+
path: route.path,
|
|
336
|
+
pattern: route.pattern,
|
|
337
|
+
})),
|
|
338
|
+
ssgCache,
|
|
339
|
+
},
|
|
340
|
+
indexHtml,
|
|
341
|
+
prerenders,
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export async function buildRuntimeAppsSequentially(
|
|
346
|
+
apps: RuntimeTargetApp[],
|
|
347
|
+
projectRoot: string,
|
|
348
|
+
targetDir: string,
|
|
349
|
+
serverEntry: string | null,
|
|
350
|
+
options: BuildAppOptions,
|
|
351
|
+
targetName: "bun" | "vercel"
|
|
352
|
+
): Promise<{
|
|
353
|
+
builds: RuntimeAppBuild[];
|
|
354
|
+
entryApps: BuildEntryOptions["apps"];
|
|
355
|
+
headlineBuildId: string;
|
|
356
|
+
}> {
|
|
357
|
+
const builds: RuntimeAppBuild[] = [];
|
|
358
|
+
const entryApps: BuildEntryOptions["apps"] = [];
|
|
359
|
+
let headlineBuildId = "";
|
|
360
|
+
|
|
361
|
+
for (const app of apps) {
|
|
362
|
+
// biome-ignore lint/performance/noAwaitInLoops: each app installs a build-time template before SSG snapshotting, so this must remain ordered.
|
|
363
|
+
const built = await buildRuntimeApp(
|
|
364
|
+
app,
|
|
365
|
+
projectRoot,
|
|
366
|
+
targetDir,
|
|
367
|
+
serverEntry,
|
|
368
|
+
options,
|
|
369
|
+
targetName
|
|
370
|
+
);
|
|
371
|
+
builds.push(built);
|
|
372
|
+
entryApps.push(built.entryApp);
|
|
373
|
+
if (app.prefix === "" || headlineBuildId === "") {
|
|
374
|
+
headlineBuildId = built.buildId;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
if (serverEntry) {
|
|
378
|
+
await buildRscGraph(apps, targetDir, headlineBuildId, options.plugins);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
return { builds, entryApps, headlineBuildId };
|
|
382
|
+
}
|
package/src/adapter/static.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
// biome-ignore-all lint/performance/noAwaitInLoops: static build emits routes in sequence to keep output deterministic
|
|
2
2
|
import { cpSync, existsSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
3
|
+
import { dirname, isAbsolute, join, parse, relative, resolve, sep, win32 } from "node:path";
|
|
4
|
+
import { toCrossJSONAsync } from "seroval";
|
|
4
5
|
import { buildClient } from "../build/client.ts";
|
|
5
6
|
import { ensureDir, toPosixPath } from "../build/shared.ts";
|
|
6
7
|
import type { BuildAppOptions, StaticTargetBuildManifest } from "../build/types.ts";
|
|
8
|
+
import { toLogical } from "../client/router/link-utils.ts";
|
|
7
9
|
import type { StaticExportConfig } from "../config.ts";
|
|
8
10
|
import { resolvePath } from "../server/render/assemble.ts";
|
|
9
11
|
import { generateProdIndexHtml } from "../server/render/shell.ts";
|
|
10
12
|
import { prerenderSSG } from "../server/render/ssg.ts";
|
|
13
|
+
import { hasStaticParams, resolveStaticParams } from "../server/render/static-params.ts";
|
|
11
14
|
import { setProductionTemplateContent } from "../server/render/template.ts";
|
|
12
15
|
import { createSearchRouteMetadata } from "../server/router/schemas.ts";
|
|
13
16
|
import type { ResolvedRoute, RootLayout } from "../server/router/types.ts";
|
|
@@ -23,6 +26,13 @@ const DYNAMIC_SEGMENT_RE = /\/:[^/]+|\/\*/;
|
|
|
23
26
|
/** Strips all trailing slashes from a string. */
|
|
24
27
|
const TRAILING_SLASHES_RE = /\/+$/;
|
|
25
28
|
|
|
29
|
+
const STATIC_RENDER_ORIGIN = "http://localhost";
|
|
30
|
+
|
|
31
|
+
interface StaticRedirectLocation {
|
|
32
|
+
html: string;
|
|
33
|
+
spa: string | null;
|
|
34
|
+
}
|
|
35
|
+
|
|
26
36
|
// ── Path helpers ──────────────────────────────────────────────────────────────
|
|
27
37
|
|
|
28
38
|
/**
|
|
@@ -53,6 +63,55 @@ function sortRouteList(routes: string[]): string[] {
|
|
|
53
63
|
return routes.toSorted((a, b) => (a < b ? -1 : Number(a > b)));
|
|
54
64
|
}
|
|
55
65
|
|
|
66
|
+
function escapeHtmlAttribute(value: string): string {
|
|
67
|
+
return value
|
|
68
|
+
.replaceAll("&", "&")
|
|
69
|
+
.replaceAll('"', """)
|
|
70
|
+
.replaceAll("<", "<")
|
|
71
|
+
.replaceAll(">", ">");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function resolveStaticRedirectLocation(
|
|
75
|
+
location: string,
|
|
76
|
+
basePath: string,
|
|
77
|
+
sourcePath: string
|
|
78
|
+
): StaticRedirectLocation {
|
|
79
|
+
const sourceUrl = new URL(sourcePath, STATIC_RENDER_ORIGIN);
|
|
80
|
+
const targetUrl = new URL(location, sourceUrl);
|
|
81
|
+
if (targetUrl.protocol !== "http:" && targetUrl.protocol !== "https:") {
|
|
82
|
+
throw new Error(
|
|
83
|
+
`[furin] static: redirect from "${sourcePath}" uses unsupported protocol "${targetUrl.protocol}".`
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
if (targetUrl.origin !== sourceUrl.origin) {
|
|
87
|
+
return { html: targetUrl.href, spa: null };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const suffix = `${targetUrl.search}${targetUrl.hash}`;
|
|
91
|
+
const spa = `${toLogical(targetUrl.pathname, basePath)}${suffix}`;
|
|
92
|
+
if (
|
|
93
|
+
basePath === "" ||
|
|
94
|
+
targetUrl.pathname === basePath ||
|
|
95
|
+
targetUrl.pathname.startsWith(`${basePath}/`)
|
|
96
|
+
) {
|
|
97
|
+
return { html: `${targetUrl.pathname}${suffix}`, spa };
|
|
98
|
+
}
|
|
99
|
+
const pathname = targetUrl.pathname === "/" ? `${basePath}/` : `${basePath}${targetUrl.pathname}`;
|
|
100
|
+
return { html: `${pathname}${suffix}`, spa };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function createStaticRedirectHtml(location: string): string {
|
|
104
|
+
const escapedLocation = escapeHtmlAttribute(location);
|
|
105
|
+
return (
|
|
106
|
+
"<!doctype html>\n" +
|
|
107
|
+
'<meta charset="utf-8">\n' +
|
|
108
|
+
`<meta http-equiv="refresh" content="0;url=${escapedLocation}">\n` +
|
|
109
|
+
`<link rel="canonical" href="${escapedLocation}">\n` +
|
|
110
|
+
"<title>Redirecting…</title>\n" +
|
|
111
|
+
`<a href="${escapedLocation}">Redirecting…</a>\n`
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
56
115
|
function assertNoStaticExportSkips(onSSR: "error" | "skip", skippedRoutes: string[]): void {
|
|
57
116
|
if (onSSR !== "error" || skippedRoutes.length === 0) {
|
|
58
117
|
return;
|
|
@@ -108,8 +167,24 @@ async function prerenderAndWrite(
|
|
|
108
167
|
);
|
|
109
168
|
|
|
110
169
|
if (entry instanceof Response) {
|
|
111
|
-
|
|
112
|
-
|
|
170
|
+
const location = entry.headers.get("location");
|
|
171
|
+
if (entry.status < 300 || entry.status >= 400 || location === null) {
|
|
172
|
+
throw new Error(
|
|
173
|
+
`[furin] static: route "${route.pattern}" returned a response that cannot be exported.`
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
const staticLocation = resolveStaticRedirectLocation(location, basePath, urlPath);
|
|
177
|
+
ensureDir(dirname(htmlOutputFile));
|
|
178
|
+
writeFileSync(htmlOutputFile, createStaticRedirectHtml(staticLocation.html));
|
|
179
|
+
if (staticLocation.spa !== null) {
|
|
180
|
+
const serializedRedirect = await toCrossJSONAsync({
|
|
181
|
+
__furinRedirect: staticLocation.spa,
|
|
182
|
+
});
|
|
183
|
+
writeFileSync(dataOutputFile, `${JSON.stringify(serializedRedirect)}\n`);
|
|
184
|
+
}
|
|
185
|
+
renderedRoutes.push(urlPath);
|
|
186
|
+
console.log(
|
|
187
|
+
`[furin] static: ${urlPath} → ${toPosixPath(htmlOutputFile)} (redirects to ${staticLocation.html})`
|
|
113
188
|
);
|
|
114
189
|
return;
|
|
115
190
|
}
|
|
@@ -197,7 +272,7 @@ async function buildTaskQueue(
|
|
|
197
272
|
if (!DYNAMIC_SEGMENT_RE.test(route.pattern)) {
|
|
198
273
|
return { paramSets: [{}], route };
|
|
199
274
|
}
|
|
200
|
-
if (!route
|
|
275
|
+
if (!hasStaticParams(route)) {
|
|
201
276
|
console.warn(
|
|
202
277
|
`[furin] static: skipping dynamic route "${route.pattern}" — no staticParams() defined.`
|
|
203
278
|
);
|
|
@@ -205,7 +280,7 @@ async function buildTaskQueue(
|
|
|
205
280
|
return { paramSets: null, route };
|
|
206
281
|
}
|
|
207
282
|
try {
|
|
208
|
-
const paramSets = (await route
|
|
283
|
+
const paramSets = (await resolveStaticParams(route, STATIC_RENDER_ORIGIN)) ?? [];
|
|
209
284
|
return { paramSets, route };
|
|
210
285
|
} catch (err) {
|
|
211
286
|
return { error: err, paramSets: null, route };
|
|
@@ -320,7 +395,8 @@ export async function buildStaticTarget(
|
|
|
320
395
|
);
|
|
321
396
|
}
|
|
322
397
|
|
|
323
|
-
const
|
|
398
|
+
const rawOutDir = staticConfig.outDir ?? "dist";
|
|
399
|
+
const outDir = resolve(rootDir, rawOutDir);
|
|
324
400
|
|
|
325
401
|
// Guard against destructive rmSync on obviously wrong output directories.
|
|
326
402
|
const normalizedRoot = resolve(rootDir);
|
|
@@ -328,8 +404,8 @@ export async function buildStaticTarget(
|
|
|
328
404
|
if (
|
|
329
405
|
outDir === normalizedRoot ||
|
|
330
406
|
outDir === normalizedBuildRoot ||
|
|
331
|
-
outDir ===
|
|
332
|
-
|
|
407
|
+
outDir === parse(outDir).root ||
|
|
408
|
+
rawOutDir === win32.parse(rawOutDir).root
|
|
333
409
|
) {
|
|
334
410
|
throw new Error(
|
|
335
411
|
`[furin] static: outDir resolves to "${outDir}" which is unsafe to delete. ` +
|
|
@@ -388,10 +464,13 @@ export async function buildStaticTarget(
|
|
|
388
464
|
const { entryChunk, cssChunks } = await buildClient(ssgRoutes, {
|
|
389
465
|
basePath,
|
|
390
466
|
clientLogging: Boolean(options.clientLogging),
|
|
467
|
+
metafilePath: options.analyze ? join(buildRoot, "analysis", "static-client.json") : undefined,
|
|
468
|
+
optimizeImports: options.optimizeImports,
|
|
391
469
|
outDir: targetDir,
|
|
392
470
|
pagesDir: dirname(root.path),
|
|
393
471
|
plugins: options.plugins,
|
|
394
472
|
publicPath,
|
|
473
|
+
reactCompiler: options.reactCompiler,
|
|
395
474
|
rootLayout: root.path,
|
|
396
475
|
});
|
|
397
476
|
|