@teyik0/furin 0.8.0-alpha.0 → 0.9.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -0
- package/dist/adapter/bun/app.d.ts +1 -0
- package/dist/adapter/bun.d.ts +3 -1
- package/dist/adapter/runtime-build.d.ts +8 -5
- package/dist/adapter/vercel.js +8 -8
- package/dist/build/client.d.ts +2 -2
- package/dist/build/discover-mounts-process.d.ts +1 -1
- package/dist/build/discover-pages-process.d.ts +1 -0
- package/dist/build/discover-pages.d.ts +11 -0
- package/dist/build/discovery-module.d.ts +3 -0
- package/dist/build/discovery-plugins.d.ts +34 -0
- package/dist/build/elysia-aot.d.ts +1 -1
- package/dist/build/entry-template.ts +6 -1
- package/dist/build/hydrate.d.ts +3 -2
- package/dist/build/index.js +7688 -8458
- package/dist/build/preload-manifest.d.ts +2 -2
- package/dist/build/route-metadata.d.ts +31 -0
- package/dist/build/route-types.d.ts +1 -1
- package/dist/build/shared.d.ts +2 -2
- package/dist/build/types.d.ts +11 -0
- package/dist/cli/dev-worker.d.ts +1 -0
- package/dist/cli/dev-worker.ts +123 -0
- package/dist/cli/dev.d.ts +1 -0
- package/dist/cli/index.js +7811 -8477
- package/dist/client/browser-events-runtime.d.ts +2 -2
- package/dist/client/browser-events.d.ts +2 -0
- package/dist/client/chunks/{client-brdfd773.js → client-rjhxgt64.js} +187 -4
- package/dist/client/dev-error-overlay.ts +18 -1
- package/dist/client/link.js +110 -156
- package/dist/client/query-store.d.ts +5 -0
- package/dist/client/router/navigation-controller.d.ts +2 -0
- package/dist/client/router/use-fetch-interception.d.ts +1 -1
- package/dist/client/router/use-sync-stream.d.ts +1 -1
- package/dist/client/{router/sync-catch-up.d.ts → sync-catch-up.d.ts} +5 -3
- package/dist/client/sync-client.d.ts +74 -0
- package/dist/client.d.ts +1 -0
- package/dist/client.js +533 -145
- package/dist/config.d.ts +6 -1
- package/dist/config.js +3 -1
- package/dist/define-route.d.ts +3 -3
- package/dist/furin.d.ts +2 -1
- package/dist/furin.js +1119 -346
- package/dist/plugin/index.js +5 -5
- package/dist/plugin/route-registry.d.ts +22 -2
- package/dist/rsc/build/index.d.ts +4 -3
- package/dist/server/dev/server-only-module.d.ts +5 -0
- package/dist/server/internal.js +201 -91
- package/dist/server/logging/ingest-plugin.d.ts +1 -2
- package/dist/server/production-server.js +36 -33
- package/dist/server/server-entry.d.ts +5 -0
- package/dist/server/server-entry.js +36 -0
- package/dist/server/static-export.js +201 -91
- package/dist/server/sync/adapter.d.ts +4 -3
- package/dist/server/sync/config.d.ts +7 -0
- package/dist/server/sync/connection.d.ts +13 -0
- package/dist/server/sync/drizzle/index.js +5 -4
- package/dist/server/sync/index.d.ts +3 -0
- package/dist/server/sync/index.js +1361 -243
- package/dist/server/sync/invalidate-sync.d.ts +6 -2
- package/dist/server/sync/local-client.d.ts +9 -0
- package/dist/server/sync/postgres/index.d.ts +1 -1
- package/dist/server/sync/postgres/index.js +2 -2
- package/dist/server/sync/prisma/index.js +2 -2
- package/dist/server/sync/redis/index.d.ts +1 -1
- package/dist/server/sync/redis/index.js +4 -3
- package/dist/server/sync/redis/scripts.d.ts +1 -1
- package/dist/server/sync/runtime.d.ts +3 -0
- package/dist/server/sync/sqlite/index.d.ts +1 -1
- package/dist/server/sync/sqlite/index.js +3 -2
- package/dist/shared/browser-events.d.ts +4 -0
- package/dist/sync-client.d.ts +3 -0
- package/dist/sync-client.js +1600 -0
- package/package.json +12 -7
- package/src/adapter/README.md +7 -0
- package/src/adapter/build.ts +34 -33
- package/src/adapter/bun/app.ts +5 -0
- package/src/adapter/bun/server.ts +2 -2
- package/src/adapter/bun.ts +18 -2
- package/src/adapter/furin-app.d.ts +1 -0
- package/src/adapter/package.ts +1 -0
- package/src/adapter/runtime-build.ts +18 -12
- package/src/adapter/static.ts +17 -13
- package/src/build/client.ts +7 -5
- package/src/build/discover-mounts-process.ts +5 -1
- package/src/build/discover-pages-process.ts +151 -0
- package/src/build/discover-pages.ts +69 -0
- package/src/build/discovery-module.ts +70 -0
- package/src/build/discovery-plugins.ts +101 -0
- package/src/build/elysia-aot-worker.ts +9 -8
- package/src/build/elysia-aot.ts +110 -75
- package/src/build/entry-template.ts +6 -1
- package/src/build/hydrate.ts +11 -8
- package/src/build/index.ts +6 -50
- package/src/build/preload-manifest.ts +3 -3
- package/src/build/route-metadata.ts +90 -0
- package/src/build/route-types.ts +1 -1
- package/src/build/shared.ts +6 -8
- package/src/build/types.ts +9 -0
- package/src/cli/config.ts +4 -0
- package/src/cli/dev-worker.ts +123 -0
- package/src/cli/dev.ts +91 -0
- package/src/cli/index.ts +24 -1
- package/src/client/browser-events-runtime.ts +97 -23
- package/src/client/browser-events.ts +8 -0
- package/src/client/dev-error-overlay.ts +18 -1
- package/src/client/query-store.ts +54 -3
- package/src/client/router/navigation-controller.ts +45 -12
- package/src/client/router/provider.tsx +6 -2
- package/src/client/router/use-fetch-interception.ts +1 -1
- package/src/client/router/use-sync-stream.ts +96 -44
- package/src/client/{router/sync-catch-up.ts → sync-catch-up.ts} +28 -12
- package/src/client/sync-client.ts +528 -0
- package/src/client/sync.ts +11 -4
- package/src/client.ts +10 -0
- package/src/config.ts +17 -10
- package/src/furin.ts +5 -0
- package/src/plugin/route-registry.ts +53 -7
- package/src/rsc/build/index.ts +6 -3
- package/src/server/browser-events/plugin.ts +79 -25
- package/src/server/dev/rewrite-module-specifiers.ts +2 -1
- package/src/server/dev/server-only-module.ts +23 -0
- package/src/server/dev/symbolicate.ts +4 -3
- package/src/server/dev-page-imports.ts +3 -1
- package/src/server/dev-page-plugin.ts +18 -1
- package/src/server/logging/ingest-plugin.ts +3 -9
- package/src/server/server-entry.ts +39 -0
- package/src/server/sync/adapter.ts +7 -3
- package/src/server/sync/config.ts +12 -6
- package/src/server/sync/connection.ts +71 -0
- package/src/server/sync/index.ts +3 -0
- package/src/server/sync/invalidate-sync.ts +30 -5
- package/src/server/sync/local-client.ts +84 -0
- package/src/server/sync/plugin.ts +27 -20
- package/src/server/sync/postgres/index.ts +9 -2
- package/src/server/sync/redis/index.ts +5 -1
- package/src/server/sync/redis/scripts.ts +1 -1
- package/src/server/sync/runtime.ts +56 -18
- package/src/server/sync/sqlite/index.ts +6 -2
- package/src/server/sync/stream.ts +17 -5
- package/src/shared/browser-events.ts +1 -1
- package/src/sync-client.ts +14 -0
- package/dist/server/logger.d.ts +0 -10
- package/src/server/logger.ts +0 -34
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teyik0/furin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0-alpha.0",
|
|
4
4
|
"description": "React meta-framework powered by Elysia and Bun with file-based routing, SSR, SSG, and ISR.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -77,6 +77,11 @@
|
|
|
77
77
|
"bun": "./src/server/sync/index.ts",
|
|
78
78
|
"import": "./dist/server/sync/index.js"
|
|
79
79
|
},
|
|
80
|
+
"./sync/client": {
|
|
81
|
+
"types": "./dist/sync-client.d.ts",
|
|
82
|
+
"bun": "./src/sync-client.ts",
|
|
83
|
+
"import": "./dist/sync-client.js"
|
|
84
|
+
},
|
|
80
85
|
"./sync/postgres": {
|
|
81
86
|
"types": "./dist/server/sync/postgres/index.d.ts",
|
|
82
87
|
"bun": "./src/server/sync/postgres/index.ts",
|
|
@@ -171,8 +176,8 @@
|
|
|
171
176
|
"tscheck": "bun run generate:sync-prisma && tsc --noEmit"
|
|
172
177
|
},
|
|
173
178
|
"dependencies": {
|
|
174
|
-
"@elysia/eden": "2.0.0-
|
|
175
|
-
"@elysia/static": "2.0.0-
|
|
179
|
+
"@elysia/eden": "2.0.0-rc.1",
|
|
180
|
+
"@elysia/static": "2.0.0-rc.0",
|
|
176
181
|
"@jridgewell/trace-mapping": "^0.3.31",
|
|
177
182
|
"@vercel/functions": "^3.10.1",
|
|
178
183
|
"cjs-module-lexer": "^2.3.0",
|
|
@@ -180,8 +185,8 @@
|
|
|
180
185
|
"react-server-dom-webpack": "~19.3.1",
|
|
181
186
|
"seroval": "^1.6.11",
|
|
182
187
|
"typescript": "7.0.2",
|
|
183
|
-
"yuku-ast": "0.
|
|
184
|
-
"yuku-parser": "0.
|
|
188
|
+
"yuku-ast": "0.13.0",
|
|
189
|
+
"yuku-parser": "0.13.0"
|
|
185
190
|
},
|
|
186
191
|
"devDependencies": {
|
|
187
192
|
"@prisma/adapter-pg": "7.10.1",
|
|
@@ -197,8 +202,8 @@
|
|
|
197
202
|
"peerDependencies": {
|
|
198
203
|
"@types/bun": ">=1.4.0",
|
|
199
204
|
"drizzle-orm": "^0.45.4",
|
|
200
|
-
"elysia": "2.0.0-
|
|
201
|
-
"evlog": "^2.33.
|
|
205
|
+
"elysia": "2.0.0-rc.1",
|
|
206
|
+
"evlog": "^2.33.1",
|
|
202
207
|
"exact-mirror": ">=1.2.6",
|
|
203
208
|
"react": "^19.3.1",
|
|
204
209
|
"react-dom": "^19.3.1",
|
package/src/adapter/README.md
CHANGED
|
@@ -32,6 +32,13 @@ Compiling re-bundles the finished JavaScript, so the executable carries the
|
|
|
32
32
|
snapshot the bundle rendered. Elysia AOT evaluates the listener-free
|
|
33
33
|
application entry; `adapter/bun/server.ts` owns the listener.
|
|
34
34
|
|
|
35
|
+
Mount discovery and AOT compilation expose Elysia's `inAotBuild()` guard to
|
|
36
|
+
application modules. Sync adapter factories are skipped in those phases and
|
|
37
|
+
prepared once during real application composition, before listening. The
|
|
38
|
+
application must guard its own service acquisition and keep route declarations
|
|
39
|
+
independent of runtime resources. Prerendering is separate: SSG/ISR loaders
|
|
40
|
+
execute normally and still need their resources.
|
|
41
|
+
|
|
35
42
|
## Vercel adapter
|
|
36
43
|
|
|
37
44
|
The Vercel target emits Build Output API v3 directly to `.vercel/output`:
|
package/src/adapter/build.ts
CHANGED
|
@@ -7,16 +7,16 @@ import {
|
|
|
7
7
|
movePrivateServerSourceMaps,
|
|
8
8
|
privateServerSourceMapDir,
|
|
9
9
|
} from "../build/private-server-sourcemaps.ts";
|
|
10
|
+
import {
|
|
11
|
+
type BuildRouteInput,
|
|
12
|
+
rootHasRequestLoader,
|
|
13
|
+
routeBuildInfo,
|
|
14
|
+
} from "../build/route-metadata.ts";
|
|
10
15
|
import { materializeServerAppEntry } from "../build/server-app-entry.ts";
|
|
11
16
|
import { copyDirRecursive, ensureDir, toPosixPath, writeBuildMetafile } from "../build/shared.ts";
|
|
12
17
|
import type { BuildAppOptions } from "../build/types.ts";
|
|
13
18
|
import { buildRscGraph, type ClientReference } from "../rsc/build/index.ts";
|
|
14
19
|
import type { AppPrerender } from "../server/prerender.ts";
|
|
15
|
-
import { hasRequestLoader } from "../server/render/request-loaders.ts";
|
|
16
|
-
import { resolveDocumentMode, resolveDocumentRevalidate } from "../server/router/patterns.ts";
|
|
17
|
-
import { mergeRouteSchemas } from "../server/router/schema-merge.ts";
|
|
18
|
-
import type { ResolvedRoute } from "../server/router/types.ts";
|
|
19
|
-
import { isTypeBoxObjectSchema } from "../shared/elysia-contract.ts";
|
|
20
20
|
import { clientDirNameForPrefix } from "../shared/prefix.ts";
|
|
21
21
|
import { prerenderFromBundle } from "./prerender.ts";
|
|
22
22
|
import { buildRuntimeApp, type RuntimeAppBuild, type RuntimeTargetApp } from "./runtime-build.ts";
|
|
@@ -40,19 +40,12 @@ function serverEntryLoader(serverEntry: string): "js" | "jsx" | "ts" | "tsx" {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* application static mount would read.
|
|
43
|
+
* A platform serving assets never deploys the files an application static
|
|
44
|
+
* mount would read. The generated entry normalizes the application for AOT.
|
|
46
45
|
*/
|
|
47
46
|
function assertServerEntry(serverEntry: string, adapter: FurinAdapter): void {
|
|
48
47
|
const transpiler = new Bun.Transpiler({ loader: serverEntryLoader(serverEntry) });
|
|
49
|
-
const {
|
|
50
|
-
if (!exports.includes("default")) {
|
|
51
|
-
throw new Error(
|
|
52
|
-
`[furin] Server entry "${toPosixPath(serverEntry)}" must export the Elysia app as default. ` +
|
|
53
|
-
"Guard app.listen() with `if (import.meta.main)` so the same entry also runs locally."
|
|
54
|
-
);
|
|
55
|
-
}
|
|
48
|
+
const { imports } = transpiler.scan(readFileSync(serverEntry, "utf8"));
|
|
56
49
|
if (
|
|
57
50
|
adapter.capabilities.assets === "platform" &&
|
|
58
51
|
imports.some(({ path }) => path === "@elysia/static")
|
|
@@ -103,22 +96,15 @@ function withAssetContexts(
|
|
|
103
96
|
});
|
|
104
97
|
}
|
|
105
98
|
|
|
106
|
-
function
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
return [];
|
|
110
|
-
}
|
|
111
|
-
return isTypeBoxObjectSchema(schema) ? Object.keys(schema.properties).toSorted() : null;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function adapterRoute(app: RuntimeTargetApp, route: ResolvedRoute): AdapterRoute {
|
|
115
|
-
const mode = resolveDocumentMode(route);
|
|
99
|
+
function adapterRoute(app: RuntimeTargetApp, route: BuildRouteInput): AdapterRoute {
|
|
100
|
+
const info = routeBuildInfo(route);
|
|
101
|
+
const mode = info.documentMode;
|
|
116
102
|
return {
|
|
117
103
|
mode,
|
|
118
104
|
pattern: route.pattern,
|
|
119
|
-
ppr: mode !== "ssr" && (app.root
|
|
120
|
-
queryKeys: queryKeys
|
|
121
|
-
revalidate:
|
|
105
|
+
ppr: mode !== "ssr" && (rootHasRequestLoader(app.root) || info.hasRequestLoader),
|
|
106
|
+
queryKeys: info.queryKeys,
|
|
107
|
+
revalidate: info.documentRevalidate,
|
|
122
108
|
tags: route.tags ?? [],
|
|
123
109
|
};
|
|
124
110
|
}
|
|
@@ -136,6 +122,7 @@ async function bundleServer(
|
|
|
136
122
|
const build = await runBunBuild({
|
|
137
123
|
define: PRODUCTION_DEFINE,
|
|
138
124
|
entrypoints: [adapter.runtimeModule, appEntry],
|
|
125
|
+
external: options.serverExternalPackages,
|
|
139
126
|
format: "esm",
|
|
140
127
|
metafile: options.analyze,
|
|
141
128
|
minify: true,
|
|
@@ -211,7 +198,13 @@ export async function buildAdapterTarget(
|
|
|
211
198
|
);
|
|
212
199
|
const rootIndex = apps.findIndex((app) => app.prefix === "");
|
|
213
200
|
const { buildId } = builds[rootIndex === -1 ? 0 : rootIndex] as RuntimeAppBuild;
|
|
214
|
-
const rscManifest = await buildRscGraph(
|
|
201
|
+
const rscManifest = await buildRscGraph(
|
|
202
|
+
apps,
|
|
203
|
+
targetDir,
|
|
204
|
+
buildId,
|
|
205
|
+
options.plugins,
|
|
206
|
+
options.serverExternalPackages
|
|
207
|
+
);
|
|
215
208
|
|
|
216
209
|
const projectPublicDir = join(rootDir, "public");
|
|
217
210
|
const publicDir = existsSync(projectPublicDir) ? projectPublicDir : undefined;
|
|
@@ -241,11 +234,19 @@ export async function buildAdapterTarget(
|
|
|
241
234
|
buildRoot,
|
|
242
235
|
options
|
|
243
236
|
);
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
237
|
+
const needsPrerender = apps.some((app) =>
|
|
238
|
+
app.routes.some((route) => {
|
|
239
|
+
const info = routeBuildInfo(route);
|
|
240
|
+
return info.documentMode !== "ssr" && (info.queryKeys?.length ?? 0) === 0;
|
|
241
|
+
})
|
|
248
242
|
);
|
|
243
|
+
const prerenders = needsPrerender
|
|
244
|
+
? await prerenderFromBundle(
|
|
245
|
+
{ kind: "app", path: join(targetDir, APP_MODULE) },
|
|
246
|
+
rootDir,
|
|
247
|
+
frameworkCache
|
|
248
|
+
)
|
|
249
|
+
: [];
|
|
249
250
|
if (frameworkCache) {
|
|
250
251
|
writePrerenderSnapshot(targetDir, prerenders);
|
|
251
252
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Runtime module of `furin build --target bun --output app`: the entry of
|
|
2
|
+
// `.furin/build/bun/app.js`. It re-exports the listener-free application so a
|
|
3
|
+
// host can import it into its own Bun process and own startup and shutdown.
|
|
4
|
+
// biome-ignore lint/performance/noBarrelFile: the bundle entry of app.js, not a barrel
|
|
5
|
+
export { default, idleTimeout, onShutdown, onStartup, port, startServer } from "furin:app";
|
|
@@ -7,8 +7,8 @@ import { startProductionServer } from "../../server/production-server.ts";
|
|
|
7
7
|
if (typeof startServer === "function") {
|
|
8
8
|
await startServer();
|
|
9
9
|
} else if (app && typeof app.listen === "function" && !app.server) {
|
|
10
|
-
const declaredPort = typeof port === "number" ? port : 3000;
|
|
11
|
-
const serverPort = process.env.PORT
|
|
10
|
+
const declaredPort = app["~config"]?.serve?.port ?? (typeof port === "number" ? port : 3000);
|
|
11
|
+
const serverPort = Number(process.env.PORT ?? declaredPort);
|
|
12
12
|
const { server } = startProductionServer({ app, idleTimeout, onShutdown, port: serverPort });
|
|
13
13
|
console.log(`[furin] Server running at http://localhost:${server.port}`);
|
|
14
14
|
}
|
package/src/adapter/bun.ts
CHANGED
|
@@ -13,8 +13,11 @@ import { frameworkSourceModule } from "./runtime-build.ts";
|
|
|
13
13
|
import type { AdapterBuildOutput, FurinAdapter } from "./types.ts";
|
|
14
14
|
|
|
15
15
|
const RUNTIME_MODULE = frameworkSourceModule("adapter/bun/server.ts");
|
|
16
|
+
const APP_RUNTIME_MODULE = frameworkSourceModule("adapter/bun/app.ts");
|
|
16
17
|
|
|
17
18
|
export type BunCompileMode = "server" | "embed";
|
|
19
|
+
/** `server` emits a listening `server.js`, `app` an importable, inert `app.js`. */
|
|
20
|
+
export type BunOutput = "app" | "server";
|
|
18
21
|
|
|
19
22
|
function compiledServerFilename(platform: NodeJS.Platform): string {
|
|
20
23
|
return platform === "win32" ? "server.exe" : "server";
|
|
@@ -75,7 +78,14 @@ async function compileExecutable(
|
|
|
75
78
|
* Bun server bundle, optionally compiled into an executable. Requests reach
|
|
76
79
|
* `Bun.serve()`, Furin serves assets and caches public pages itself.
|
|
77
80
|
*/
|
|
78
|
-
export function bun(
|
|
81
|
+
export function bun(
|
|
82
|
+
compile: BunCompileMode | undefined,
|
|
83
|
+
bunOutput: BunOutput | undefined
|
|
84
|
+
): FurinAdapter {
|
|
85
|
+
const isApp = bunOutput === "app";
|
|
86
|
+
if (isApp && compile !== undefined) {
|
|
87
|
+
throw new Error("[furin] Bun app output cannot be combined with compile.");
|
|
88
|
+
}
|
|
79
89
|
return {
|
|
80
90
|
capabilities: {
|
|
81
91
|
assets: compile === "embed" ? "embedded" : "filesystem",
|
|
@@ -94,6 +104,12 @@ export function bun(compile: BunCompileMode | undefined): FurinAdapter {
|
|
|
94
104
|
targetDir,
|
|
95
105
|
templatePath: toPosixPath(join(targetDir, "client", "index.html")),
|
|
96
106
|
};
|
|
107
|
+
if (isApp) {
|
|
108
|
+
manifest.appPath = manifest.serverPath as string;
|
|
109
|
+
manifest.serverPath = null;
|
|
110
|
+
console.log(`[furin] Application bundle: ${manifest.appPath}`);
|
|
111
|
+
return manifest;
|
|
112
|
+
}
|
|
97
113
|
if (compile === undefined) {
|
|
98
114
|
console.log(`[furin] Server bundle: ${manifest.serverPath}`);
|
|
99
115
|
return manifest;
|
|
@@ -101,6 +117,6 @@ export function bun(compile: BunCompileMode | undefined): FurinAdapter {
|
|
|
101
117
|
await compileExecutable(output, compile, manifest);
|
|
102
118
|
return manifest;
|
|
103
119
|
},
|
|
104
|
-
runtimeModule: RUNTIME_MODULE,
|
|
120
|
+
runtimeModule: isApp ? APP_RUNTIME_MODULE : RUNTIME_MODULE,
|
|
105
121
|
};
|
|
106
122
|
}
|
|
@@ -9,6 +9,7 @@ declare module "furin:app" {
|
|
|
9
9
|
export default app;
|
|
10
10
|
export const idleTimeout: number | undefined;
|
|
11
11
|
export const onShutdown: (() => Promise<void> | void) | undefined;
|
|
12
|
+
export const onStartup: ((signal: AbortSignal) => Promise<void> | void) | undefined;
|
|
12
13
|
export const port: number | undefined;
|
|
13
14
|
export const startServer: (() => Promise<void> | void) | undefined;
|
|
14
15
|
}
|
package/src/adapter/package.ts
CHANGED
|
@@ -57,6 +57,7 @@ export async function buildPackageTarget(
|
|
|
57
57
|
optimizeImports: options.optimizeImports,
|
|
58
58
|
outDir: targetDir,
|
|
59
59
|
pagesDir,
|
|
60
|
+
routeRegistry: app.routeRegistry,
|
|
60
61
|
plugins: options.plugins,
|
|
61
62
|
preloadRouteChunks: options.preload?.routeChunks,
|
|
62
63
|
publicPath: `${prefix}/_client/`,
|
|
@@ -4,15 +4,19 @@ import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
import { buildClient } from "../build/client.ts";
|
|
6
6
|
import type { EntryAppContext } from "../build/entry-template.ts";
|
|
7
|
+
import {
|
|
8
|
+
type BuildRoot,
|
|
9
|
+
type BuildRouteInput,
|
|
10
|
+
rootHasRequestLoader,
|
|
11
|
+
routeBuildInfo,
|
|
12
|
+
} from "../build/route-metadata.ts";
|
|
7
13
|
import { toPosixPath } from "../build/shared.ts";
|
|
8
14
|
import type { BuildAppOptions } from "../build/types.ts";
|
|
15
|
+
import type { RouteRegistrySnapshot } from "../plugin/route-registry.ts";
|
|
9
16
|
import { composableRouteModuleSpecifier } from "../plugin/route-registry.ts";
|
|
10
17
|
import { routeSourcePaths } from "../plugin/route-tree.ts";
|
|
11
|
-
import { hasMixedLoaderModes } from "../server/render/loaders.ts";
|
|
12
|
-
import { hasRequestLoader } from "../server/render/request-loaders.ts";
|
|
13
18
|
import { generateProdIndexHtml } from "../server/render/shell.ts";
|
|
14
|
-
import {
|
|
15
|
-
import type { ResolvedRoute, RootLayout } from "../server/router/types.ts";
|
|
19
|
+
import type { RootLayout } from "../server/router/types.ts";
|
|
16
20
|
import { clientDirNameForPrefix } from "../shared/prefix.ts";
|
|
17
21
|
|
|
18
22
|
// import.meta.resolve() runs at runtime (not inlined at bundle time), resolves
|
|
@@ -113,8 +117,8 @@ function nearestFingerprintFile(
|
|
|
113
117
|
export async function createBuildFingerprint(
|
|
114
118
|
entryChunk: string,
|
|
115
119
|
cssChunks: string[],
|
|
116
|
-
routes:
|
|
117
|
-
root: RootLayout,
|
|
120
|
+
routes: BuildRouteInput[],
|
|
121
|
+
root: BuildRoot | RootLayout,
|
|
118
122
|
serverEntry: string | null,
|
|
119
123
|
routeSources: string[],
|
|
120
124
|
projectRoot: string
|
|
@@ -259,7 +263,7 @@ function stableFingerprintPath(path: string, projectRoot: string): string {
|
|
|
259
263
|
return `external/${toPosixPath(projectPath)}`;
|
|
260
264
|
}
|
|
261
265
|
|
|
262
|
-
export function buildCompileMetadata(root: RootLayout, routes:
|
|
266
|
+
export function buildCompileMetadata(root: BuildRoot | RootLayout, routes: BuildRouteInput[]) {
|
|
263
267
|
const rootConventions =
|
|
264
268
|
root.errorPath || root.notFoundPath
|
|
265
269
|
? {
|
|
@@ -289,8 +293,9 @@ export function buildCompileMetadata(root: RootLayout, routes: ResolvedRoute[])
|
|
|
289
293
|
export interface RuntimeTargetApp {
|
|
290
294
|
pagesDir: string;
|
|
291
295
|
prefix: string;
|
|
292
|
-
root: RootLayout;
|
|
293
|
-
|
|
296
|
+
root: BuildRoot | RootLayout;
|
|
297
|
+
routeRegistry?: RouteRegistrySnapshot;
|
|
298
|
+
routes: BuildRouteInput[];
|
|
294
299
|
}
|
|
295
300
|
|
|
296
301
|
/** Avoid loading React's resumable renderer in applications without PPR routes. */
|
|
@@ -298,8 +303,8 @@ export function pprRuntimePlugin(apps: RuntimeTargetApp[]): Bun.BunPlugin {
|
|
|
298
303
|
const enabled = apps.some((app) =>
|
|
299
304
|
app.routes.some(
|
|
300
305
|
(route) =>
|
|
301
|
-
|
|
302
|
-
(app.root
|
|
306
|
+
routeBuildInfo(route).documentMode !== "ssr" &&
|
|
307
|
+
(rootHasRequestLoader(app.root) || routeBuildInfo(route).hasRequestLoader)
|
|
303
308
|
)
|
|
304
309
|
);
|
|
305
310
|
const pprPath = resolve(_pkgSrcDir, "server/render/ppr-route.ts");
|
|
@@ -341,7 +346,7 @@ export const runPprPublicLoaders = renderPprRoute;`,
|
|
|
341
346
|
|
|
342
347
|
/** Keep mixed-mode cache code out of builds whose route graph cannot use it. */
|
|
343
348
|
export function mixedRuntimePlugin(apps: RuntimeTargetApp[]): Bun.BunPlugin {
|
|
344
|
-
const enabled = apps.some((app) => app.routes.some(
|
|
349
|
+
const enabled = apps.some((app) => app.routes.some((route) => routeBuildInfo(route).mixed));
|
|
345
350
|
const mixedPath = resolve(_pkgSrcDir, "server/render/mixed-cache.ts");
|
|
346
351
|
return {
|
|
347
352
|
name: "furin-mixed-runtime",
|
|
@@ -408,6 +413,7 @@ export async function buildRuntimeApp(
|
|
|
408
413
|
optimizeImports: options.optimizeImports,
|
|
409
414
|
outDir: targetDir,
|
|
410
415
|
pagesDir: app.pagesDir,
|
|
416
|
+
routeRegistry: app.routeRegistry,
|
|
411
417
|
plugins: options.plugins,
|
|
412
418
|
preloadRouteChunks: options.preload?.routeChunks,
|
|
413
419
|
publicPath: `${prefix}/_client/`,
|
package/src/adapter/static.ts
CHANGED
|
@@ -6,6 +6,12 @@ import { PRODUCTION_DEFINE, runBunBuild } from "../build/bun-build.ts";
|
|
|
6
6
|
import { buildClient } from "../build/client.ts";
|
|
7
7
|
import { buildEntrySource } from "../build/entry-template.ts";
|
|
8
8
|
import type { ClientPreloadManifest } from "../build/preload-manifest.ts";
|
|
9
|
+
import {
|
|
10
|
+
type BuildRoot,
|
|
11
|
+
type BuildRouteInput,
|
|
12
|
+
rootHasRequestLoader,
|
|
13
|
+
routeBuildInfo,
|
|
14
|
+
} from "../build/route-metadata.ts";
|
|
9
15
|
import { ensureDir, toPosixPath } from "../build/shared.ts";
|
|
10
16
|
import type { BuildAppOptions, StaticTargetBuildManifest } from "../build/types.ts";
|
|
11
17
|
import { createVirtualBuildEntry } from "../build/virtual-entry.ts";
|
|
@@ -14,8 +20,7 @@ import type { StaticExportConfig } from "../config.ts";
|
|
|
14
20
|
import { routeSourcePaths } from "../plugin/route-tree.ts";
|
|
15
21
|
import { buildFlightCodec } from "../rsc/build/index.ts";
|
|
16
22
|
import { generateProdIndexHtml } from "../server/render/shell.ts";
|
|
17
|
-
import {
|
|
18
|
-
import type { ResolvedRoute, RootLayout } from "../server/router/types.ts";
|
|
23
|
+
import type { RootLayout } from "../server/router/types.ts";
|
|
19
24
|
import type {
|
|
20
25
|
StaticExportFailure,
|
|
21
26
|
StaticExportPage,
|
|
@@ -285,11 +290,11 @@ function logRenderFailure(
|
|
|
285
290
|
* Pushes skipped patterns into `skippedRoutes`.
|
|
286
291
|
*/
|
|
287
292
|
function collectSsgRoutes(
|
|
288
|
-
routes:
|
|
293
|
+
routes: BuildRouteInput[],
|
|
289
294
|
onSSR: "error" | "skip",
|
|
290
295
|
skippedRoutes: string[]
|
|
291
|
-
):
|
|
292
|
-
const nonSsg = routes.filter((r) =>
|
|
296
|
+
): BuildRouteInput[] {
|
|
297
|
+
const nonSsg = routes.filter((r) => routeBuildInfo(r).documentMode !== "ssg");
|
|
293
298
|
|
|
294
299
|
if (nonSsg.length === 0) {
|
|
295
300
|
return routes;
|
|
@@ -299,7 +304,7 @@ function collectSsgRoutes(
|
|
|
299
304
|
const list = nonSsg
|
|
300
305
|
.map(
|
|
301
306
|
(r) =>
|
|
302
|
-
` • ${r.pattern} (mode: ${
|
|
307
|
+
` • ${r.pattern} (mode: ${routeBuildInfo(r).documentMode === "ssr" && r.mode !== "ssr" ? "ssr layout" : routeBuildInfo(r).documentMode})`
|
|
303
308
|
)
|
|
304
309
|
.join("\n");
|
|
305
310
|
throw new Error(
|
|
@@ -312,12 +317,12 @@ function collectSsgRoutes(
|
|
|
312
317
|
// onSSR === "skip"
|
|
313
318
|
for (const r of nonSsg) {
|
|
314
319
|
console.warn(
|
|
315
|
-
`[furin] static: skipping route "${r.pattern}" (mode=${
|
|
320
|
+
`[furin] static: skipping route "${r.pattern}" (mode=${routeBuildInfo(r).documentMode === "ssr" && r.mode !== "ssr" ? "ssr layout" : routeBuildInfo(r).documentMode}) — not statically exportable.`
|
|
316
321
|
);
|
|
317
322
|
skippedRoutes.push(r.pattern);
|
|
318
323
|
}
|
|
319
324
|
|
|
320
|
-
return routes.filter((r) =>
|
|
325
|
+
return routes.filter((r) => routeBuildInfo(r).documentMode === "ssg");
|
|
321
326
|
}
|
|
322
327
|
|
|
323
328
|
// ── Export bundle ─────────────────────────────────────────────────────────────
|
|
@@ -396,14 +401,12 @@ async function bundleStaticExport(
|
|
|
396
401
|
|
|
397
402
|
// ── Main adapter ──────────────────────────────────────────────────────────────
|
|
398
403
|
|
|
399
|
-
function assertNoRequestLoaders(routes:
|
|
404
|
+
function assertNoRequestLoaders(routes: BuildRouteInput[], root: BuildRoot | RootLayout): void {
|
|
400
405
|
const offenders: string[] = [];
|
|
401
|
-
if (root
|
|
406
|
+
if (rootHasRequestLoader(root)) {
|
|
402
407
|
offenders.push(" • <root layout>");
|
|
403
408
|
}
|
|
404
|
-
const requestScopedRoutes = routes.filter((route) =>
|
|
405
|
-
route.routeChain.some((entry) => entry.requestLoader !== undefined)
|
|
406
|
-
);
|
|
409
|
+
const requestScopedRoutes = routes.filter((route) => routeBuildInfo(route).hasRequestLoader);
|
|
407
410
|
offenders.push(...requestScopedRoutes.map((route) => ` • ${route.pattern}`));
|
|
408
411
|
if (offenders.length === 0) {
|
|
409
412
|
return;
|
|
@@ -496,6 +499,7 @@ export async function buildStaticTarget(
|
|
|
496
499
|
optimizeImports: options.optimizeImports,
|
|
497
500
|
outDir: targetDir,
|
|
498
501
|
pagesDir: dirname(root.path),
|
|
502
|
+
routeRegistry: app.routeRegistry,
|
|
499
503
|
plugins: options.plugins,
|
|
500
504
|
preloadRouteChunks: options.preload?.routeChunks,
|
|
501
505
|
publicPath,
|
package/src/build/client.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { basename, dirname, join, sep } from "node:path";
|
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { createClientStripPlugin } from "../plugin/client-plugin.ts";
|
|
5
5
|
import { createRoutesPlugin } from "../plugin/route-registry.ts";
|
|
6
|
-
import { discoverClientBoundaries
|
|
7
|
-
import type {
|
|
6
|
+
import { discoverClientBoundaries } from "../rsc/build/discover.ts";
|
|
7
|
+
import type { BuildRouteInput } from "./route-metadata.ts";
|
|
8
8
|
import { PRODUCTION_DEFINE, runBunBuild } from "./bun-build.ts";
|
|
9
9
|
import { generateClientReferenceEntry, generateProductionHydrateEntry } from "./hydrate";
|
|
10
10
|
import { type ClientPreloadManifest, writeClientPreloadManifest } from "./preload-manifest.ts";
|
|
@@ -41,7 +41,7 @@ export interface BuildClientResult {
|
|
|
41
41
|
* <!--ssr-outlet-->, and sends the complete page.
|
|
42
42
|
*/
|
|
43
43
|
export async function buildClient(
|
|
44
|
-
routes:
|
|
44
|
+
routes: BuildRouteInput[],
|
|
45
45
|
{
|
|
46
46
|
outDir,
|
|
47
47
|
rootLayout,
|
|
@@ -55,6 +55,7 @@ export async function buildClient(
|
|
|
55
55
|
optimizeImports,
|
|
56
56
|
reactCompiler,
|
|
57
57
|
pagesDir,
|
|
58
|
+
routeRegistry,
|
|
58
59
|
}: BuildClientOptions
|
|
59
60
|
): Promise<BuildClientResult> {
|
|
60
61
|
// Per-app client dir so several mounted apps build side by side
|
|
@@ -72,7 +73,8 @@ export async function buildClient(
|
|
|
72
73
|
const boundaries = await discoverClientBoundaries(
|
|
73
74
|
[...new Set([rootLayout, ...routes.flatMap(route => [route.path, ...route.routeChain.flatMap(entry => entry.sourcePath ? [entry.sourcePath] : [])])])], plugins
|
|
74
75
|
);
|
|
75
|
-
|
|
76
|
+
// The production bundle registers these exports. Importing them here would
|
|
77
|
+
// reopen application resources in the parent before AOT.
|
|
76
78
|
const hydrateCode =
|
|
77
79
|
generateClientReferenceEntry(boundaries) + generateProductionHydrateEntry(routes, rootLayout, basePath, clientLogging);
|
|
78
80
|
const hydratePath = join(
|
|
@@ -135,7 +137,7 @@ export async function buildClient(
|
|
|
135
137
|
...(plugins ?? []),
|
|
136
138
|
...(!clientLogging ? [routerLoggerPlugin] : []),
|
|
137
139
|
...(pagesDir
|
|
138
|
-
? [createRoutesPlugin({ instances: [{ pagesDir, prefix: basePath }], target: "client" })]
|
|
140
|
+
? [createRoutesPlugin({ instances: [{ pagesDir, prefix: basePath, routeRegistry }], target: "client" })]
|
|
139
141
|
: []),
|
|
140
142
|
createClientStripPlugin({ mode: "build" }),
|
|
141
143
|
],
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
// Child process of `furin build`: evaluates the server entry with furin() in
|
|
2
2
|
// discovery mode and writes the mounts it registers as JSON.
|
|
3
3
|
// Usage: bun discover-mounts-process.ts <serverEntry> <resultPath>
|
|
4
|
+
// Elysia requires its capture implementation before inAotBuild() can return true.
|
|
5
|
+
import "elysia/plugin/aot/unplugin";
|
|
4
6
|
import { isomorphicTransformPlugin } from "../plugin/transform-isomorphic.ts";
|
|
5
7
|
import { collectFurinRegistrations } from "../server/registrations.ts";
|
|
8
|
+
import { loadServerEntry } from "../server/server-entry.ts";
|
|
6
9
|
|
|
7
10
|
const [serverEntry, resultPath] = process.argv.slice(2) as [string, string];
|
|
8
11
|
// Same module transforms as the Elysia AOT evaluation of the built entry.
|
|
9
12
|
Bun.plugin(isomorphicTransformPlugin("server"));
|
|
10
13
|
const registrations = collectFurinRegistrations(true);
|
|
11
|
-
|
|
14
|
+
process.env.ELYSIA_AOT_BUILD = "1";
|
|
15
|
+
await loadServerEntry(() => import(serverEntry));
|
|
12
16
|
await Bun.write(resultPath, JSON.stringify(registrations));
|
|
13
17
|
process.exit(0);
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// biome-ignore-all lint/performance/noAwaitInLoops: share one module graph across mounts, then exit before AOT
|
|
2
|
+
// Discovery observes the same resource guard as AOT, without capturing handlers.
|
|
3
|
+
import "elysia/plugin/aot/unplugin";
|
|
4
|
+
import { existsSync, readFileSync, unlinkSync } from "node:fs";
|
|
5
|
+
import { dirname, join } from "node:path";
|
|
6
|
+
import { deserialize } from "node:v8";
|
|
7
|
+
import { snapshotRouteRegistry } from "../plugin/route-registry.ts";
|
|
8
|
+
import type { RouteInstanceSpec } from "../plugin/route-tree.ts";
|
|
9
|
+
import {
|
|
10
|
+
isomorphicTransformPlugin,
|
|
11
|
+
transformIsomorphicFunctions,
|
|
12
|
+
} from "../plugin/transform-isomorphic.ts";
|
|
13
|
+
import { detectLoaderFromPath } from "../server/lang-detect.ts";
|
|
14
|
+
import { scanPages } from "../server/router/discovery.ts";
|
|
15
|
+
import type { DiscoveredApp } from "./discover-pages.ts";
|
|
16
|
+
import { discoveryModule, discoveryModuleFilter } from "./discovery-module.ts";
|
|
17
|
+
import type {
|
|
18
|
+
DiscoveryHook,
|
|
19
|
+
DiscoveryPluginRequest,
|
|
20
|
+
DiscoveryPluginResponse,
|
|
21
|
+
} from "./discovery-plugins.ts";
|
|
22
|
+
import { buildRouteMetadata, rootHasRequestLoader } from "./route-metadata.ts";
|
|
23
|
+
|
|
24
|
+
const { apps, hooks, resultPath } = JSON.parse(process.argv[2] as string) as {
|
|
25
|
+
apps: RouteInstanceSpec[];
|
|
26
|
+
hooks: DiscoveryHook[];
|
|
27
|
+
resultPath: string;
|
|
28
|
+
};
|
|
29
|
+
let nextId = 0;
|
|
30
|
+
const pending = new Map<
|
|
31
|
+
number,
|
|
32
|
+
{
|
|
33
|
+
resolve: (value: Bun.OnLoadResult | Bun.OnResolveResult | null) => void;
|
|
34
|
+
reject: (error: Error) => void;
|
|
35
|
+
}
|
|
36
|
+
>();
|
|
37
|
+
process.on("message", (response: DiscoveryPluginResponse) => {
|
|
38
|
+
const request = pending.get(response.id);
|
|
39
|
+
pending.delete(response.id);
|
|
40
|
+
if (response.ok) {
|
|
41
|
+
request?.resolve(response.value);
|
|
42
|
+
} else {
|
|
43
|
+
request?.reject(new Error(response.error));
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
function invoke(hook: number, args: DiscoveryPluginRequest["args"]) {
|
|
47
|
+
const id = nextId;
|
|
48
|
+
nextId += 1;
|
|
49
|
+
return new Promise<Bun.OnLoadResult | Bun.OnResolveResult | null>((resolve, reject) => {
|
|
50
|
+
pending.set(id, { resolve, reject });
|
|
51
|
+
// Runtime callbacks have no bundler defer function; copy only IPC-safe arguments.
|
|
52
|
+
const payload = args && "defer" in args ? { ...args, defer: undefined } : args;
|
|
53
|
+
process.send?.({ hook, id, args: payload } satisfies DiscoveryPluginRequest);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
// Bun's runtime onResolve cannot return a pending promise. Keep that callback
|
|
57
|
+
// synchronous while the parent executes the original closure in its own heap.
|
|
58
|
+
function resolveImport(hook: number, args: Bun.OnResolveArgs): Bun.OnResolveResult | undefined {
|
|
59
|
+
const id = nextId;
|
|
60
|
+
nextId += 1;
|
|
61
|
+
const syncPath = join(dirname(resultPath), `resolve-${id}.bin`);
|
|
62
|
+
process.send?.({ hook, id, args, syncPath } satisfies DiscoveryPluginRequest);
|
|
63
|
+
const wait = new Int32Array(new SharedArrayBuffer(4));
|
|
64
|
+
const deadline = Date.now() + 30_000;
|
|
65
|
+
while (!existsSync(syncPath)) {
|
|
66
|
+
if (Date.now() >= deadline) {
|
|
67
|
+
throw new Error(`[furin] Discovery plugin timed out resolving ${args.path}.`);
|
|
68
|
+
}
|
|
69
|
+
Atomics.wait(wait, 0, 0, 1);
|
|
70
|
+
}
|
|
71
|
+
const response = deserialize(readFileSync(syncPath)) as DiscoveryPluginResponse;
|
|
72
|
+
unlinkSync(syncPath);
|
|
73
|
+
if (!response.ok) {
|
|
74
|
+
throw new Error(response.error);
|
|
75
|
+
}
|
|
76
|
+
return response.value as Bun.OnResolveResult | undefined;
|
|
77
|
+
}
|
|
78
|
+
const metadataFilter = discoveryModuleFilter(apps.map((app) => app.pagesDir));
|
|
79
|
+
|
|
80
|
+
function isolateModule(result: Bun.OnLoadResult, path: string): Bun.OnLoadResult {
|
|
81
|
+
if (!result || result.loader === "object" || !metadataFilter.test(path)) {
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
const loader = result.loader ?? detectLoaderFromPath(path);
|
|
85
|
+
if (!(loader === "js" || loader === "jsx" || loader === "ts" || loader === "tsx")) {
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
const code =
|
|
89
|
+
typeof result.contents === "string"
|
|
90
|
+
? result.contents
|
|
91
|
+
: new TextDecoder().decode(result.contents);
|
|
92
|
+
const sourcePath = `${path}.${loader}`;
|
|
93
|
+
const contents = discoveryModule(code, path, loader);
|
|
94
|
+
return { ...result, contents: transformIsomorphicFunctions(contents, sourcePath, "server").code };
|
|
95
|
+
}
|
|
96
|
+
Bun.plugin({
|
|
97
|
+
name: "furin-discovery-plugins",
|
|
98
|
+
setup(builder) {
|
|
99
|
+
for (const hook of hooks) {
|
|
100
|
+
if (hook.method === "module") {
|
|
101
|
+
builder.module(
|
|
102
|
+
hook.specifier,
|
|
103
|
+
() => invoke(hook.id, undefined) as Promise<Bun.OnLoadResult>
|
|
104
|
+
);
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
const constraints = {
|
|
108
|
+
filter: new RegExp(hook.filter.source, hook.filter.flags),
|
|
109
|
+
namespace: hook.namespace,
|
|
110
|
+
};
|
|
111
|
+
if (hook.method === "onLoad") {
|
|
112
|
+
builder.onLoad(constraints, async (args) =>
|
|
113
|
+
isolateModule((await invoke(hook.id, args)) as Bun.OnLoadResult, args.path)
|
|
114
|
+
);
|
|
115
|
+
} else {
|
|
116
|
+
builder.onResolve(constraints, (args) => resolveImport(hook.id, args));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
Bun.plugin({
|
|
122
|
+
name: "furin-route-metadata",
|
|
123
|
+
setup(builder) {
|
|
124
|
+
builder.onLoad({ filter: metadataFilter }, async ({ path }) =>
|
|
125
|
+
isolateModule(
|
|
126
|
+
{ contents: await Bun.file(path).text(), loader: detectLoaderFromPath(path) },
|
|
127
|
+
path
|
|
128
|
+
)
|
|
129
|
+
);
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
Bun.plugin(isomorphicTransformPlugin("server"));
|
|
133
|
+
|
|
134
|
+
const discovered: DiscoveredApp[] = [];
|
|
135
|
+
process.env.ELYSIA_AOT_BUILD = "1";
|
|
136
|
+
for (const spec of apps) {
|
|
137
|
+
const { root, routes } = await scanPages(spec.pagesDir);
|
|
138
|
+
discovered.push({
|
|
139
|
+
...spec,
|
|
140
|
+
routeRegistry: await snapshotRouteRegistry(spec),
|
|
141
|
+
root: {
|
|
142
|
+
path: root.path,
|
|
143
|
+
errorPath: root.errorPath,
|
|
144
|
+
notFoundPath: root.notFoundPath,
|
|
145
|
+
hasRequestLoader: rootHasRequestLoader(root),
|
|
146
|
+
},
|
|
147
|
+
routes: routes.map(buildRouteMetadata),
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
await Bun.write(resultPath, JSON.stringify(discovered));
|
|
151
|
+
process.exit(0);
|