@teyik0/furin 0.4.0-alpha.1 → 0.4.0-alpha.2
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 +4 -3
- package/dist/build/compile-entry.ts +24 -69
- package/dist/build/entry-template.d.ts +4 -2
- package/dist/build/entry-template.ts +31 -8
- package/dist/build/index.d.ts +1 -1
- package/dist/build/index.js +8596 -6375
- 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 +5 -0
- package/dist/cache.js +97 -0
- package/dist/cli/index.js +9099 -6771
- 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/link.js +251 -82
- 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.js +37 -23
- package/dist/config.d.ts +17 -0
- package/dist/config.js +9 -1
- package/dist/define-route.d.ts +11 -8
- package/dist/devtools/protocol.d.ts +2 -2
- package/dist/furin.d.ts +1 -1
- package/dist/furin.js +12991 -9491
- package/dist/plugin/index.js +476 -7
- package/dist/plugin/routes.d.ts +4 -3
- package/dist/rsc/build/index.d.ts +5 -1
- 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 +1 -2
- package/dist/server/cache/isr.d.ts +1 -0
- package/dist/server/cache/purger.d.ts +7 -0
- package/dist/server/cache/runtime-cache.d.ts +21 -0
- 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 +5 -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.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/external-prerender.d.ts +2 -0
- package/dist/server/instance.d.ts +2 -2
- package/dist/server/internal.d.ts +14 -2
- package/dist/server/internal.js +436 -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/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 +2 -0
- package/dist/server/render/ssr.d.ts +17 -6
- 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/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 +491 -516
- package/dist/server/sync/notifier.d.ts +1 -0
- 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 +4 -13
- 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/prefix.d.ts +2 -0
- package/package.json +16 -7
- package/src/adapter/README.md +45 -0
- package/src/adapter/bun.ts +45 -268
- package/src/adapter/package.ts +15 -9
- package/src/adapter/runtime-build.ts +375 -0
- package/src/adapter/static.ts +79 -2
- package/src/adapter/vercel.ts +857 -0
- package/src/build/client.ts +38 -13
- package/src/build/compile-entry.ts +24 -69
- package/src/build/entry-template.ts +31 -8
- package/src/build/hydrate.ts +60 -20
- package/src/build/index.ts +19 -5
- package/src/build/production-instrumentation.ts +56 -4
- package/src/build/shared.ts +2 -1
- package/src/build/ssg-cache.ts +97 -11
- package/src/build/types.ts +31 -2
- package/src/build/virtual-entry.ts +27 -0
- package/src/cache.ts +14 -0
- package/src/cli/index.ts +55 -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/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/config.ts +25 -0
- package/src/define-route.ts +20 -7
- package/src/devtools/devtools-element.js +56 -77
- package/src/devtools/protocol.ts +2 -2
- package/src/furin.ts +157 -77
- package/src/plugin/routes.ts +206 -36
- 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/auto-invalidate/runtime.ts +5 -2
- package/src/server/browser-events/plugin.ts +168 -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 +13 -22
- package/src/server/cache/isr.ts +9 -0
- package/src/server/cache/purger.ts +41 -0
- package/src/server/cache/runtime-cache.ts +137 -0
- 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 +24 -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 +92 -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/external-prerender.ts +10 -0
- package/src/server/instance.ts +3 -3
- package/src/server/internal.ts +39 -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 +44 -19
- package/src/server/render/loaders.ts +13 -3
- package/src/server/render/not-found.ts +28 -4
- 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 +152 -31
- package/src/server/render/shell.ts +0 -12
- package/src/server/render/ssg.ts +38 -20
- package/src/server/render/ssr.ts +211 -83
- package/src/server/render/template.ts +47 -11
- package/src/server/router/defined-route.ts +7 -39
- package/src/server/router/hmr.production.ts +7 -0
- package/src/server/router/hmr.ts +106 -67
- package/src/server/router/patterns.ts +5 -1
- package/src/server/router/plugin.ts +124 -35
- 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 +4 -1
- package/src/server/sync/postgres/index.ts +111 -5
- 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/prefix.ts +8 -0
- package/src/shared/route-map.ts +10 -1
package/src/build/client.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { basename, join } from "node:path";
|
|
2
|
+
import { basename, dirname, join } from "node:path";
|
|
3
3
|
import { transformForClient } from "../plugin/transform-client";
|
|
4
4
|
import { createRoutesPlugin } from "../plugin/routes.ts";
|
|
5
5
|
import { environmentGuardPlugin } from "../rsc/build/environment.ts";
|
|
@@ -9,9 +9,20 @@ import { runBunBuild } from "./bun-build.ts";
|
|
|
9
9
|
import { generateHydrateEntry } from "./hydrate";
|
|
10
10
|
import { CLIENT_MODULE_PATH, LINK_MODULE_PATH, SEARCH_MODULE_PATH } from "./shared";
|
|
11
11
|
import type { BuildClientOptions, BunBuildAliasConfig } from "./types";
|
|
12
|
+
import { createVirtualBuildEntry } from "./virtual-entry.ts";
|
|
12
13
|
|
|
13
14
|
const SCRIPT_FILE_FILTER = /\.(tsx?|jsx?)$/;
|
|
14
15
|
|
|
16
|
+
function resolveClientModuleSpecifiers(code: string): string {
|
|
17
|
+
return code
|
|
18
|
+
.replaceAll(`"@teyik0/furin/client"`, JSON.stringify(CLIENT_MODULE_PATH))
|
|
19
|
+
.replaceAll(`'furin/client'`, JSON.stringify(CLIENT_MODULE_PATH))
|
|
20
|
+
.replaceAll(`"@teyik0/furin/link"`, JSON.stringify(LINK_MODULE_PATH))
|
|
21
|
+
.replaceAll(`'furin/link'`, JSON.stringify(LINK_MODULE_PATH))
|
|
22
|
+
.replaceAll(`"@teyik0/furin/search"`, JSON.stringify(SEARCH_MODULE_PATH))
|
|
23
|
+
.replaceAll(`'furin/search'`, JSON.stringify(SEARCH_MODULE_PATH));
|
|
24
|
+
}
|
|
25
|
+
|
|
15
26
|
export interface BuildClientResult {
|
|
16
27
|
/** Public paths of all CSS chunks, e.g. `["/_client/chunk-abc.css"]` */
|
|
17
28
|
cssChunks: string[];
|
|
@@ -45,6 +56,9 @@ export async function buildClient(
|
|
|
45
56
|
basePath,
|
|
46
57
|
clientLogging,
|
|
47
58
|
clientDirName,
|
|
59
|
+
metafilePath,
|
|
60
|
+
optimizeImports,
|
|
61
|
+
reactCompiler,
|
|
48
62
|
pagesDir,
|
|
49
63
|
}: BuildClientOptions
|
|
50
64
|
): Promise<BuildClientResult> {
|
|
@@ -60,12 +74,14 @@ export async function buildClient(
|
|
|
60
74
|
mkdirSync(clientDir, { recursive: true });
|
|
61
75
|
}
|
|
62
76
|
|
|
63
|
-
const hydrateCode =
|
|
77
|
+
const hydrateCode = resolveClientModuleSpecifiers(
|
|
78
|
+
generateHydrateEntry(routes, rootLayout, basePath, clientLogging)
|
|
79
|
+
);
|
|
64
80
|
const hydratePath = join(
|
|
65
81
|
outDir,
|
|
66
82
|
dirName === "client" ? "_hydrate.tsx" : `_hydrate-${dirName}.tsx`
|
|
67
83
|
);
|
|
68
|
-
|
|
84
|
+
const hydrateEntry = createVirtualBuildEntry(hydratePath, hydrateCode, "tsx");
|
|
69
85
|
|
|
70
86
|
console.log("[furin] Building production client bundle…");
|
|
71
87
|
|
|
@@ -83,13 +99,7 @@ export async function buildClient(
|
|
|
83
99
|
// transformForClient now emits TS/TSX directly (no pre-transpile),
|
|
84
100
|
// so JSX → React handling is delegated to Bun.build's loader, which
|
|
85
101
|
// applies the project tsconfig's automatic runtime by default.
|
|
86
|
-
const transformed = result.code
|
|
87
|
-
.replaceAll(`"@teyik0/furin/client"`, JSON.stringify(CLIENT_MODULE_PATH))
|
|
88
|
-
.replaceAll(`'furin/client'`, JSON.stringify(CLIENT_MODULE_PATH))
|
|
89
|
-
.replaceAll(`"@teyik0/furin/link"`, JSON.stringify(LINK_MODULE_PATH))
|
|
90
|
-
.replaceAll(`'furin/link'`, JSON.stringify(LINK_MODULE_PATH))
|
|
91
|
-
.replaceAll(`"@teyik0/furin/search"`, JSON.stringify(SEARCH_MODULE_PATH))
|
|
92
|
-
.replaceAll(`'furin/search'`, JSON.stringify(SEARCH_MODULE_PATH));
|
|
102
|
+
const transformed = resolveClientModuleSpecifiers(result.code);
|
|
93
103
|
|
|
94
104
|
return {
|
|
95
105
|
contents: transformed,
|
|
@@ -104,25 +114,32 @@ export async function buildClient(
|
|
|
104
114
|
// with code-splitting incorrectly references a leaf chunk in the output
|
|
105
115
|
// index.html instead of the actual entry chunk, preventing React from
|
|
106
116
|
// mounting. We write index.html ourselves after the build.
|
|
107
|
-
entrypoints: [
|
|
117
|
+
entrypoints: [hydrateEntry.entrypoint],
|
|
118
|
+
files: hydrateEntry.files,
|
|
108
119
|
outdir: clientDir,
|
|
109
120
|
target: "browser",
|
|
110
121
|
format: "esm",
|
|
111
122
|
splitting: true,
|
|
123
|
+
optimizeImports,
|
|
124
|
+
reactCompiler: reactCompiler ?? true,
|
|
125
|
+
reactCompilerOutputMode: "client",
|
|
112
126
|
minify: true,
|
|
113
127
|
sourcemap: "none",
|
|
128
|
+
metafile: metafilePath !== undefined,
|
|
114
129
|
// Hash the entry point name so it gets immutable caching like chunks.
|
|
115
130
|
// Without this, _hydrate.js keeps the same name across builds and browsers
|
|
116
131
|
// serve stale versions that reference old chunk hashes → dynamic import 404.
|
|
117
132
|
naming: {
|
|
118
|
-
entry: "[
|
|
133
|
+
entry: "[name]-[hash].[ext]",
|
|
119
134
|
chunk: "[name]-[hash].[ext]",
|
|
120
135
|
},
|
|
121
136
|
// Absolute public path so SSR template asset URLs resolve on any route.
|
|
122
137
|
// Overridable via the `publicPath` option (e.g. "/furin/_client/" for basePath builds).
|
|
123
138
|
publicPath,
|
|
124
|
-
//
|
|
139
|
+
// Resolve the in-memory entry first. User plugins still run before Furin's
|
|
140
|
+
// transforms for every imported application module.
|
|
125
141
|
plugins: [
|
|
142
|
+
hydrateEntry.plugin,
|
|
126
143
|
...(plugins ?? []),
|
|
127
144
|
...(pagesDir
|
|
128
145
|
? [createRoutesPlugin({ instances: [{ pagesDir, prefix: basePath }], target: "client" })]
|
|
@@ -141,6 +158,14 @@ export async function buildClient(
|
|
|
141
158
|
};
|
|
142
159
|
|
|
143
160
|
const result = await runBunBuild(clientBuildConfig);
|
|
161
|
+
if (metafilePath !== undefined) {
|
|
162
|
+
if (result.metafile === undefined) {
|
|
163
|
+
throw new Error("[furin] client build did not produce the requested metafile");
|
|
164
|
+
}
|
|
165
|
+
mkdirSync(dirname(metafilePath), { recursive: true });
|
|
166
|
+
writeFileSync(metafilePath, `${JSON.stringify(result.metafile, null, 2)}\n`);
|
|
167
|
+
console.log(`[furin] Client metafile: ${metafilePath}`);
|
|
168
|
+
}
|
|
144
169
|
for (const output of result.outputs) {
|
|
145
170
|
console.log(`[furin] ${output.path} (${(output.size / 1024).toFixed(1)} KB)`);
|
|
146
171
|
}
|
|
@@ -1,104 +1,60 @@
|
|
|
1
|
-
import { existsSync
|
|
2
|
-
import {
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { basename, join } from "node:path";
|
|
3
3
|
import { buildEntrySource, type BuildEntryOptions, type EntryAppContext } from "./entry-template";
|
|
4
|
-
import {
|
|
4
|
+
import { ensureDir } from "./shared";
|
|
5
|
+
import { createVirtualBuildEntry, type VirtualBuildEntry } from "./virtual-entry.ts";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
|
-
* Builds one app's embedded
|
|
8
|
-
*
|
|
9
|
-
* strips the mount path before lookup at runtime.
|
|
8
|
+
* Builds one app's embedded directory context. Bun places each directory from
|
|
9
|
+
* `compile.assets` below `import.meta.dir` in the standalone executable.
|
|
10
10
|
*/
|
|
11
|
-
function
|
|
12
|
-
outDir: string,
|
|
11
|
+
function buildEmbeddedContext(
|
|
13
12
|
clientDir: string,
|
|
14
|
-
publicDir: string | undefined
|
|
15
|
-
|
|
16
|
-
): { extraContext: string[]; extraImports: string[] } {
|
|
13
|
+
publicDir: string | undefined
|
|
14
|
+
): string[] {
|
|
17
15
|
if (!existsSync(clientDir)) {
|
|
18
16
|
throw new Error(
|
|
19
17
|
`[furin] Client directory not found: ${clientDir}. Run the client build first.`
|
|
20
18
|
);
|
|
21
19
|
}
|
|
22
|
-
|
|
23
|
-
const assetImports: string[] = [];
|
|
24
|
-
const assetEntries: string[] = [];
|
|
25
|
-
let templateVarName: string | null = null;
|
|
26
|
-
|
|
27
|
-
let assetIndex = 0;
|
|
28
|
-
const importAsset = (file: string): string => {
|
|
29
|
-
const varName = `${varPrefix}asset${assetIndex++}`;
|
|
30
|
-
const relPath = toPosixPath(relative(outDir, file));
|
|
31
|
-
const importPath = relPath.startsWith(".") ? relPath : `./${relPath}`;
|
|
32
|
-
assetImports.push(
|
|
33
|
-
`import ${varName} from ${JSON.stringify(importPath)} with { type: "file" };`
|
|
34
|
-
);
|
|
35
|
-
return varName;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
for (const file of clientFiles) {
|
|
39
|
-
const varName = importAsset(file);
|
|
40
|
-
const clientRelativePath = toPosixPath(relative(clientDir, file));
|
|
41
|
-
if (clientRelativePath === "index.html") {
|
|
42
|
-
templateVarName = varName;
|
|
43
|
-
} else {
|
|
44
|
-
assetEntries.push(` ${JSON.stringify(`/_client/${clientRelativePath}`)}: ${varName},`);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (templateVarName === null) {
|
|
20
|
+
if (!existsSync(join(clientDir, "index.html"))) {
|
|
49
21
|
throw new Error(
|
|
50
22
|
`[furin] Embed mode requires a client index.html at ${join(clientDir, "index.html")}. Run the client build first.`
|
|
51
23
|
);
|
|
52
24
|
}
|
|
53
25
|
|
|
54
|
-
|
|
55
|
-
const publicFiles = collectFilesRecursive(publicDir);
|
|
56
|
-
for (const file of publicFiles) {
|
|
57
|
-
const varName = importAsset(file);
|
|
58
|
-
const publicRelativePath = toPosixPath(relative(publicDir, file));
|
|
59
|
-
assetEntries.push(` ${JSON.stringify(`/public/${publicRelativePath}`)}: ${varName},`);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const extraContext = [
|
|
26
|
+
return [
|
|
64
27
|
" embedded: {",
|
|
65
|
-
`
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
28
|
+
` clientDir: import.meta.dir + ${JSON.stringify(`/${basename(clientDir)}`)},`,
|
|
29
|
+
...(publicDir && existsSync(publicDir)
|
|
30
|
+
? [` publicDir: import.meta.dir + ${JSON.stringify(`/${basename(publicDir)}`)},`]
|
|
31
|
+
: []),
|
|
69
32
|
" },",
|
|
70
33
|
];
|
|
71
|
-
|
|
72
|
-
return { extraContext, extraImports: assetImports };
|
|
73
34
|
}
|
|
74
35
|
|
|
75
36
|
/**
|
|
76
|
-
* Generates a
|
|
37
|
+
* Generates a virtual `_compile-entry.ts` that:
|
|
77
38
|
* 1. Statically imports every page module of every app so Bun bundles them
|
|
78
|
-
* 2.
|
|
39
|
+
* 2. Points embed-mode contexts at Bun's `compile.assets` directories
|
|
79
40
|
* 3. Sets production mode and registers one CompileContext PER APP
|
|
80
41
|
* 4. Dynamically imports server.ts to boot the composed app
|
|
81
42
|
*/
|
|
82
|
-
export function generateCompileEntry(options: BuildEntryOptions):
|
|
43
|
+
export function generateCompileEntry(options: BuildEntryOptions): VirtualBuildEntry {
|
|
83
44
|
const { apps, outDir, serverEntry, publicDir } = options;
|
|
84
45
|
ensureDir(outDir);
|
|
85
46
|
|
|
86
|
-
const preparedApps: EntryAppContext[] = apps.map((app
|
|
47
|
+
const preparedApps: EntryAppContext[] = apps.map((app) => {
|
|
87
48
|
const { embed, ...context } = app;
|
|
88
49
|
if (!embed) {
|
|
89
50
|
return context;
|
|
90
51
|
}
|
|
91
|
-
const varPrefix = apps.length === 1 ? "_" : `_a${appIndex}_`;
|
|
92
|
-
// Every app gets the project-level public/ dir: each instance serves only
|
|
93
|
-
// from its own `embedded.assets`, so `/public/*` (and `/favicon.ico`) would
|
|
94
|
-
// 404 on non-first apps otherwise. This only duplicates the string keys —
|
|
95
|
-
// each app imports the same file via the same relative path, and Bun
|
|
96
|
-
// dedupes identical `with { type: "file" }` modules into one embedded blob.
|
|
97
|
-
const embedded = buildEmbeddedAssets(outDir, embed.clientDir, publicDir, varPrefix);
|
|
98
52
|
return {
|
|
99
53
|
...context,
|
|
100
|
-
extraContext: [
|
|
101
|
-
|
|
54
|
+
extraContext: [
|
|
55
|
+
...(context.extraContext ?? []),
|
|
56
|
+
...buildEmbeddedContext(embed.clientDir, publicDir),
|
|
57
|
+
],
|
|
102
58
|
};
|
|
103
59
|
});
|
|
104
60
|
|
|
@@ -109,6 +65,5 @@ export function generateCompileEntry(options: BuildEntryOptions): string {
|
|
|
109
65
|
});
|
|
110
66
|
|
|
111
67
|
const entryPath = join(outDir, "_compile-entry.ts");
|
|
112
|
-
|
|
113
|
-
return entryPath;
|
|
68
|
+
return createVirtualBuildEntry(entryPath, source, "ts");
|
|
114
69
|
}
|
|
@@ -24,8 +24,6 @@ export interface EntryAppContext {
|
|
|
24
24
|
clientLogging?: boolean;
|
|
25
25
|
/** Extra lines injected inside this app's `__setCompileContext({...})` call. */
|
|
26
26
|
extraContext?: string[];
|
|
27
|
-
/** Extra import lines this app needs (embedded asset imports). */
|
|
28
|
-
extraImports?: string[];
|
|
29
27
|
/** Additional route modules such as filesystem-derived `_route` layouts. */
|
|
30
28
|
modulePaths?: string[];
|
|
31
29
|
/** Virtual module specifier exporting this app's composed Elysia route tree. */
|
|
@@ -46,7 +44,11 @@ export interface EntryAppContext {
|
|
|
46
44
|
}
|
|
47
45
|
>;
|
|
48
46
|
routes: Array<{ mode: "ssr" | "ssg" | "isr"; path: string; pattern: string }>;
|
|
47
|
+
/** False when the deployment platform serves client/public assets itself. */
|
|
48
|
+
serveAssets?: boolean;
|
|
49
49
|
ssgCache?: Record<string, SsgCacheEntry>;
|
|
50
|
+
/** In-memory production document template for filesystem-free runtimes. */
|
|
51
|
+
templateHtml?: string;
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
export interface EntryTemplateOptions {
|
|
@@ -150,7 +152,11 @@ function buildAppContextBlock(
|
|
|
150
152
|
const routeMetadataLine = app.routeMetadata
|
|
151
153
|
? ` routeMetadata: ${JSON.stringify(app.routeMetadata)},`
|
|
152
154
|
: "";
|
|
155
|
+
const serveAssetsLine =
|
|
156
|
+
app.serveAssets === undefined ? "" : ` serveAssets: ${JSON.stringify(app.serveAssets)},`;
|
|
153
157
|
const ssgCacheLine = app.ssgCache ? ` ssgCache: ${JSON.stringify(app.ssgCache)},` : "";
|
|
158
|
+
const templateHtmlLine =
|
|
159
|
+
app.templateHtml === undefined ? "" : ` templateHtml: ${JSON.stringify(app.templateHtml)},`;
|
|
154
160
|
|
|
155
161
|
const contextLines = [
|
|
156
162
|
"__setCompileContext({",
|
|
@@ -167,7 +173,9 @@ function buildAppContextBlock(
|
|
|
167
173
|
...routeEntries,
|
|
168
174
|
" ],",
|
|
169
175
|
routeMetadataLine,
|
|
176
|
+
serveAssetsLine,
|
|
170
177
|
ssgCacheLine,
|
|
178
|
+
templateHtmlLine,
|
|
171
179
|
...(app.extraContext ?? []),
|
|
172
180
|
"});",
|
|
173
181
|
];
|
|
@@ -186,14 +194,11 @@ export function buildEntrySource(options: EntryTemplateOptions): string {
|
|
|
186
194
|
|
|
187
195
|
for (let appIndex = 0; appIndex < apps.length; appIndex++) {
|
|
188
196
|
const app = apps[appIndex] as EntryAppContext;
|
|
189
|
-
// Per-app variable namespace so several apps' module
|
|
190
|
-
//
|
|
197
|
+
// Per-app variable namespace so several apps' module imports never collide
|
|
198
|
+
// inside the single generated entry.
|
|
191
199
|
const varPrefix = apps.length === 1 ? "_" : `_a${appIndex}_`;
|
|
192
200
|
const block = buildAppContextBlock(app, varPrefix);
|
|
193
201
|
importLines.push(...block.importLines);
|
|
194
|
-
if (app.extraImports && app.extraImports.length > 0) {
|
|
195
|
-
importLines.push("", ...app.extraImports);
|
|
196
|
-
}
|
|
197
202
|
contextBlocks.push("", ...block.contextLines);
|
|
198
203
|
}
|
|
199
204
|
|
|
@@ -215,7 +220,25 @@ export function buildEntrySource(options: EntryTemplateOptions): string {
|
|
|
215
220
|
...contextBlocks,
|
|
216
221
|
"",
|
|
217
222
|
...(serverEntry
|
|
218
|
-
? [
|
|
223
|
+
? [
|
|
224
|
+
`const __serverModule = await import(${JSON.stringify(serverEntry.replace(/\\/g, "/"))});`,
|
|
225
|
+
"if (typeof __serverModule.startServer === \"function\") {",
|
|
226
|
+
" await __serverModule.startServer();",
|
|
227
|
+
"} else {",
|
|
228
|
+
" const __app = __serverModule.default;",
|
|
229
|
+
" if (__app && typeof __app.listen === \"function\" && !__app.server) {",
|
|
230
|
+
" const __port =",
|
|
231
|
+
" process.env.PORT === undefined",
|
|
232
|
+
" ? typeof __serverModule.port === \"number\"",
|
|
233
|
+
" ? __serverModule.port",
|
|
234
|
+
" : 3000",
|
|
235
|
+
" : Number(process.env.PORT);",
|
|
236
|
+
" __app.listen(__port);",
|
|
237
|
+
" console.log(`[furin] Server running at http://localhost:${__app.server?.port}`);",
|
|
238
|
+
" }",
|
|
239
|
+
"}",
|
|
240
|
+
"",
|
|
241
|
+
]
|
|
219
242
|
: []),
|
|
220
243
|
];
|
|
221
244
|
|
package/src/build/hydrate.ts
CHANGED
|
@@ -144,7 +144,7 @@ export function generateHydrateEntry(
|
|
|
144
144
|
: "const log = { error() {}, info() {} };";
|
|
145
145
|
|
|
146
146
|
// RouterProvider receives basePath so navigate() / Link push physical paths.
|
|
147
|
-
const routerProviderDefaults = `\n autoRefresh: true,\n basePath: ${basePathLiteral},\n defaultPreload: "intent",\n defaultPreloadDelay: 50,\n defaultPreloadStaleTime: 30000,\n prefetchCacheSize: 50,\n
|
|
147
|
+
const routerProviderDefaults = `\n autoRefresh: true,\n basePath: ${basePathLiteral},\n defaultPreload: "intent",\n defaultPreloadDelay: 50,\n defaultPreloadStaleTime: 30000,\n prefetchCacheSize: 50,\n syncPath,`;
|
|
148
148
|
|
|
149
149
|
const resolvedRootLayout = rootLayout.replace(/\\/g, "/");
|
|
150
150
|
const rootComponentKey = JSON.stringify(`root:${resolvedRootLayout}`);
|
|
@@ -161,6 +161,23 @@ import { route as __furin_root_route } from "${resolvedRootLayout}";
|
|
|
161
161
|
|
|
162
162
|
${loggerSetup}
|
|
163
163
|
|
|
164
|
+
if (import.meta.hot) {
|
|
165
|
+
const connectionState = ((window as unknown as {
|
|
166
|
+
__FURIN_HMR_CONNECTION__?: { disconnected: boolean; installed: boolean };
|
|
167
|
+
}).__FURIN_HMR_CONNECTION__ ??= { disconnected: false, installed: false });
|
|
168
|
+
if (!connectionState.installed) {
|
|
169
|
+
import.meta.hot.on("bun:ws:disconnect", () => {
|
|
170
|
+
connectionState.disconnected = true;
|
|
171
|
+
});
|
|
172
|
+
import.meta.hot.on("bun:ws:connect", () => {
|
|
173
|
+
if (connectionState.disconnected) {
|
|
174
|
+
window.location.reload();
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
connectionState.installed = true;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
164
181
|
const hotComponentRegistry = ((window as unknown as {
|
|
165
182
|
__FURIN_HOT_COMPONENTS__?: HotComponentRegistry;
|
|
166
183
|
}).__FURIN_HOT_COMPONENTS__ ??= new Map());
|
|
@@ -192,10 +209,13 @@ const dataEl = document.getElementById("__FURIN_DATA__");
|
|
|
192
209
|
let loaderData = dataEl ? JSON.parse(dataEl.textContent || "{}") : {};
|
|
193
210
|
const syncEl = document.getElementById("__FURIN_SYNC__");
|
|
194
211
|
const syncConfig = syncEl ? JSON.parse(syncEl.textContent || "{}") : {};
|
|
195
|
-
const
|
|
212
|
+
const syncPath = typeof syncConfig.path === "string" ? syncConfig.path : undefined;
|
|
196
213
|
const headEl = document.getElementById("__FURIN_HEAD__");
|
|
197
214
|
const head = headEl ? JSON.parse(headEl.textContent || "{}") : {};
|
|
198
215
|
const entryEl = document.querySelector("script[data-furin-entry][src]") as HTMLScriptElement | null;
|
|
216
|
+
const frameworkModules = Array.from(
|
|
217
|
+
document.querySelectorAll("script[data-furin-framework-module][src]")
|
|
218
|
+
).map((script) => script.getAttribute("src") ?? "").filter(Boolean);
|
|
199
219
|
const buildId = document.querySelector('meta[name="furin-build-id"]')?.getAttribute("content") ?? undefined;
|
|
200
220
|
const faviconHref = document.querySelector('link[rel="icon"]')?.getAttribute("href") ?? undefined;
|
|
201
221
|
const documentState: DocumentState = {
|
|
@@ -203,6 +223,7 @@ const documentState: DocumentState = {
|
|
|
203
223
|
buildId,
|
|
204
224
|
entryModule: entryEl?.getAttribute("src") ?? undefined,
|
|
205
225
|
faviconHref,
|
|
226
|
+
frameworkModules,
|
|
206
227
|
staticMode: document.querySelector('meta[name="furin-mode"][content="static"]') !== null,
|
|
207
228
|
stylesheets: Array.from(document.querySelectorAll('link[rel="stylesheet"]'))
|
|
208
229
|
.map((link) => link.getAttribute("href") ?? "")
|
|
@@ -313,6 +334,7 @@ if (__deferred && __deferred._chunks) {
|
|
|
313
334
|
initialMatch: match,
|
|
314
335
|
initialData: { ...loaderData, ...deferredData },
|
|
315
336
|
initialDigest: loaderData.__furinError?.digest,
|
|
337
|
+
initialError: loaderData.__furinError,
|
|
316
338
|
initialNotFound: isNotFound ? (loaderData.__furinNotFound ?? loaderData) : undefined,${routerProviderDefaults}
|
|
317
339
|
} as any);
|
|
318
340
|
} else if (loaderData.__furinStatus === 404) {
|
|
@@ -330,6 +352,7 @@ if (__deferred && __deferred._chunks) {
|
|
|
330
352
|
initialMatch: null,
|
|
331
353
|
initialData: cleanData,
|
|
332
354
|
initialDigest: loaderData.__furinError?.digest,
|
|
355
|
+
initialError: loaderData.__furinError,
|
|
333
356
|
initialNotFound: loaderData.__furinNotFound ?? {},${routerProviderDefaults}
|
|
334
357
|
} as any);
|
|
335
358
|
} else {
|
|
@@ -349,32 +372,46 @@ if (__deferred && __deferred._chunks) {
|
|
|
349
372
|
const hmrWindow = window as unknown as {
|
|
350
373
|
__FURIN_HMR_UPDATE__?: (
|
|
351
374
|
sourcePath: string,
|
|
352
|
-
component: (props: never) => ReactNode
|
|
353
|
-
|
|
375
|
+
component: (props: never) => ReactNode,
|
|
376
|
+
dataChanged: boolean
|
|
377
|
+
) => Promise<void>;
|
|
354
378
|
};
|
|
355
|
-
hmrWindow.__FURIN_HMR_UPDATE__ = (sourcePath, component) => {
|
|
356
|
-
const
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
379
|
+
hmrWindow.__FURIN_HMR_UPDATE__ = async (sourcePath, component, dataChanged) => {
|
|
380
|
+
const commitComponent = () => {
|
|
381
|
+
const componentKeySuffix = ":" + sourcePath;
|
|
382
|
+
for (const key of hotComponentRegistry.keys()) {
|
|
383
|
+
if (key.endsWith(componentKeySuffix)) {
|
|
384
|
+
updateHotComponent(hotComponentRegistry, key, component);
|
|
385
|
+
}
|
|
360
386
|
}
|
|
361
|
-
}
|
|
362
|
-
(window as
|
|
363
|
-
|
|
387
|
+
};
|
|
388
|
+
const refresh = (window as unknown as {
|
|
389
|
+
__FURIN_HMR_REFRESH__?: (
|
|
390
|
+
beforeCommit: (() => void) | undefined,
|
|
391
|
+
dataChanged: boolean
|
|
392
|
+
) => Promise<void>;
|
|
393
|
+
}).__FURIN_HMR_REFRESH__;
|
|
364
394
|
if (refresh) {
|
|
365
|
-
|
|
395
|
+
await refresh(commitComponent, dataChanged);
|
|
396
|
+
return;
|
|
366
397
|
}
|
|
398
|
+
window.location.reload();
|
|
367
399
|
};
|
|
368
400
|
if (existingRoot) {
|
|
369
|
-
// Already mounted — reconciliation, NOT hydration. React Fast Refresh
|
|
370
|
-
// patched the component in-place, now re-render with the new module.
|
|
371
|
-
existingRoot.render(app);
|
|
372
401
|
// The initialData embedded in the DOM is stale (from the original SSR).
|
|
373
|
-
//
|
|
374
|
-
//
|
|
375
|
-
|
|
402
|
+
// Prepare fresh loader data, then publish it with the new module in the
|
|
403
|
+
// same React commit. If the router effect is not installed yet, reconcile
|
|
404
|
+
// the module directly; this branch only occurs during initial boot.
|
|
405
|
+
const hmrRefresh = (window as unknown as {
|
|
406
|
+
__FURIN_HMR_REFRESH__?: (
|
|
407
|
+
beforeCommit: (() => void) | undefined,
|
|
408
|
+
dataChanged: boolean
|
|
409
|
+
) => Promise<void>;
|
|
410
|
+
}).__FURIN_HMR_REFRESH__;
|
|
376
411
|
if (hmrRefresh) {
|
|
377
|
-
|
|
412
|
+
await hmrRefresh(() => existingRoot.render(app), true);
|
|
413
|
+
} else {
|
|
414
|
+
existingRoot.render(app);
|
|
378
415
|
}
|
|
379
416
|
} else {
|
|
380
417
|
// First load — the root layout owns the server-rendered document.
|
|
@@ -389,6 +426,9 @@ if (__deferred && __deferred._chunks) {
|
|
|
389
426
|
log.info({ action: "hydrate_complete", pathname });
|
|
390
427
|
})().catch((err: unknown) => {
|
|
391
428
|
log.error({ action: "hydrate_failed", pathname, error: String(err) });
|
|
429
|
+
window.dispatchEvent(
|
|
430
|
+
new CustomEvent("furin:client-error", { detail: { error: err, phase: "hydrate" } })
|
|
431
|
+
);
|
|
392
432
|
});
|
|
393
433
|
`;
|
|
394
434
|
}
|
package/src/build/index.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// biome-ignore-all lint/performance/noAwaitInLoops: build phases run in sequence because later phases consume prior artifacts
|
|
2
2
|
import { existsSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { join, relative, resolve } from "node:path";
|
|
4
|
-
import { buildBunTarget
|
|
4
|
+
import { buildBunTarget } from "../adapter/bun";
|
|
5
5
|
import { buildPackageTarget } from "../adapter/package";
|
|
6
|
+
import type { RuntimeTargetApp } from "../adapter/runtime-build";
|
|
6
7
|
import { buildStaticTarget } from "../adapter/static";
|
|
8
|
+
import { buildVercelTarget } from "../adapter/vercel";
|
|
7
9
|
import { BUILD_TARGETS, type BuildTarget, type FurinPlugin } from "../config";
|
|
8
10
|
import { isomorphicTransformPlugin } from "../plugin/transform-isomorphic.ts";
|
|
9
11
|
import { normalizePrefix } from "../server/instance.ts";
|
|
@@ -25,11 +27,12 @@ export type {
|
|
|
25
27
|
BuildManifest,
|
|
26
28
|
BuildRouteManifestEntry,
|
|
27
29
|
TargetBuildManifest,
|
|
30
|
+
VercelTargetBuildManifest,
|
|
28
31
|
} from "./types";
|
|
29
32
|
|
|
30
33
|
// "package" is intentionally excluded from `--target all` — it is an
|
|
31
34
|
// alternative packaging of ONE app, not an additional deploy target.
|
|
32
|
-
const IMPLEMENTED_TARGETS = ["bun", "static"] as const satisfies BuildTarget[];
|
|
35
|
+
const IMPLEMENTED_TARGETS = ["bun", "vercel", "static"] as const satisfies BuildTarget[];
|
|
33
36
|
export const BUILD_OUTPUT_DIR = ".furin/build";
|
|
34
37
|
let isomorphicRuntimePluginRegistered = false;
|
|
35
38
|
|
|
@@ -147,13 +150,13 @@ export async function buildApp(options: BuildAppOptions): Promise<BuildAppResult
|
|
|
147
150
|
});
|
|
148
151
|
|
|
149
152
|
// scanPages throws if root.tsx is missing, so root is always defined per app.
|
|
150
|
-
const apps:
|
|
153
|
+
const apps: RuntimeTargetApp[] = [];
|
|
151
154
|
for (const spec of appSpecs) {
|
|
152
155
|
const { root, routes } = await scanPages(spec.pagesDir);
|
|
153
156
|
apps.push({ pagesDir: spec.pagesDir, prefix: spec.prefix, root, routes });
|
|
154
157
|
}
|
|
155
158
|
// The root-mounted app drives single-app manifest fields and the static target.
|
|
156
|
-
const primaryApp = (apps.find((app) => app.prefix === "") ?? apps[0]) as
|
|
159
|
+
const primaryApp = (apps.find((app) => app.prefix === "") ?? apps[0]) as RuntimeTargetApp;
|
|
157
160
|
|
|
158
161
|
ensureDir(buildRoot);
|
|
159
162
|
|
|
@@ -215,8 +218,19 @@ export async function buildApp(options: BuildAppOptions): Promise<BuildAppResult
|
|
|
215
218
|
options
|
|
216
219
|
);
|
|
217
220
|
break;
|
|
218
|
-
case "node":
|
|
219
221
|
case "vercel":
|
|
222
|
+
if (!serverEntry) {
|
|
223
|
+
throw new Error("[furin] `--target vercel` requires a server entry point.");
|
|
224
|
+
}
|
|
225
|
+
manifest.targets.vercel = await buildVercelTarget(
|
|
226
|
+
apps,
|
|
227
|
+
rootDir,
|
|
228
|
+
buildRoot,
|
|
229
|
+
serverEntry,
|
|
230
|
+
options
|
|
231
|
+
);
|
|
232
|
+
break;
|
|
233
|
+
case "node":
|
|
220
234
|
case "cloudflare":
|
|
221
235
|
throw new Error(
|
|
222
236
|
`[furin] \`--target ${target}\` is planned but not implemented yet in this branch.`
|
|
@@ -1,14 +1,66 @@
|
|
|
1
|
-
import { resolve } from "node:path";
|
|
1
|
+
import { dirname, relative, resolve } from "node:path";
|
|
2
2
|
|
|
3
3
|
const INSTRUMENTATION_IMPORT = /(?:^|[/\\])devtools[/\\]instrumentation(?:\.ts|\.js)?$/;
|
|
4
|
+
const DEV_PAGE_PLUGIN_IMPORT = /(?:^|[/\\])server[/\\]dev-page-plugin(?:\.ts|\.js)?$/;
|
|
5
|
+
const DEV_RUNTIME_IMPORT =
|
|
6
|
+
/(?:^|[/\\])server[/\\]dev[/\\](?:browser-events|diagnostics|plugin)(?:\.ts|\.js)?$/;
|
|
7
|
+
const DEV_BUILD_IMPORT =
|
|
8
|
+
/(?:^|[/\\])(?:build[/\\]hydrate|plugin[/\\]route-config-autofix)(?:\.ts|\.js)?$/;
|
|
9
|
+
const HMR_IMPORT = /(?:^|[/\\])server[/\\]router[/\\]hmr(?:\.ts|\.js)?$/;
|
|
10
|
+
const PRODUCTION_BOUNDARY_IMPORT =
|
|
11
|
+
/(?:browser-events|instrumentation|dev-page-plugin|diagnostics|plugin|hmr|hydrate|route-config-autofix)(?:\.ts|\.js)?$/;
|
|
12
|
+
const PRODUCTION_STUB_NAMESPACE = "furin-production-runtime-stub";
|
|
13
|
+
const FURIN_RUNTIME_ROOT = resolve(import.meta.dir, "..");
|
|
14
|
+
|
|
15
|
+
function isFurinRuntimePath(path: string): boolean {
|
|
16
|
+
const fromRuntimeRoot = relative(FURIN_RUNTIME_ROOT, path);
|
|
17
|
+
return (
|
|
18
|
+
fromRuntimeRoot !== ".." &&
|
|
19
|
+
!fromRuntimeRoot.startsWith("../") &&
|
|
20
|
+
!fromRuntimeRoot.startsWith("..\\")
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function devBuildExport(path: string): "fixRouteConfigLayout" | "writeDevFiles" {
|
|
25
|
+
return path.includes("route-config-autofix") ? "fixRouteConfigLayout" : "writeDevFiles";
|
|
26
|
+
}
|
|
4
27
|
|
|
5
28
|
export function productionInstrumentationPlugin(): Bun.BunPlugin {
|
|
6
29
|
return {
|
|
7
30
|
name: "furin-production-instrumentation",
|
|
8
31
|
setup(build) {
|
|
9
|
-
build.onResolve({ filter:
|
|
10
|
-
|
|
11
|
-
|
|
32
|
+
build.onResolve({ filter: PRODUCTION_BOUNDARY_IMPORT }, (args) => {
|
|
33
|
+
const importPath = resolve(dirname(args.importer), args.path);
|
|
34
|
+
if (!isFurinRuntimePath(importPath)) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (INSTRUMENTATION_IMPORT.test(importPath)) {
|
|
38
|
+
return {
|
|
39
|
+
path: resolve(import.meta.dir, "../server/devtools/instrumentation.production.ts"),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
if (DEV_PAGE_PLUGIN_IMPORT.test(importPath)) {
|
|
43
|
+
return { path: resolve(import.meta.dir, "../server/dev-page-plugin.production.ts") };
|
|
44
|
+
}
|
|
45
|
+
if (DEV_RUNTIME_IMPORT.test(importPath)) {
|
|
46
|
+
return { path: resolve(import.meta.dir, "../server/dev/runtime.production.ts") };
|
|
47
|
+
}
|
|
48
|
+
if (HMR_IMPORT.test(importPath)) {
|
|
49
|
+
return { path: resolve(import.meta.dir, "../server/router/hmr.production.ts") };
|
|
50
|
+
}
|
|
51
|
+
if (DEV_BUILD_IMPORT.test(importPath)) {
|
|
52
|
+
return { namespace: PRODUCTION_STUB_NAMESPACE, path: importPath };
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
build.onLoad(
|
|
56
|
+
{ filter: /.*/, namespace: PRODUCTION_STUB_NAMESPACE },
|
|
57
|
+
({ path }) => ({
|
|
58
|
+
contents: `export function ${devBuildExport(path)}() {
|
|
59
|
+
throw new Error("[furin] Development-only module reached a production bundle.");
|
|
60
|
+
}`,
|
|
61
|
+
loader: "js",
|
|
62
|
+
})
|
|
63
|
+
);
|
|
12
64
|
},
|
|
13
65
|
};
|
|
14
66
|
}
|
package/src/build/shared.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { cpSync, existsSync, mkdirSync, readdirSync, rmSync } from "node:fs";
|
|
|
2
2
|
import { join, relative } from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import type { BuildTarget } from "../config";
|
|
5
|
+
import { resolveRouteRevalidate } from "../server/router/patterns.ts";
|
|
5
6
|
import type { ResolvedRoute } from "../server/router/types.ts";
|
|
6
7
|
import type { BuildRouteManifestEntry, TargetBuildManifest } from "./types";
|
|
7
8
|
|
|
@@ -56,7 +57,7 @@ export function toBuildRouteManifestEntry(
|
|
|
56
57
|
pagePath: toPosixPath(relative(rootDir, route.path)),
|
|
57
58
|
hasLayout: route.routeChain.some((entry) => !!entry.layout),
|
|
58
59
|
hasStaticParams: !!route.page?.staticParams,
|
|
59
|
-
revalidate: route.page
|
|
60
|
+
revalidate: resolveRouteRevalidate(route.page) ?? null,
|
|
60
61
|
};
|
|
61
62
|
}
|
|
62
63
|
|