@teyik0/furin 0.2.0-alpha.3 → 0.2.0-alpha.5
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/LICENSE +21 -21
- package/README.md +37 -33
- package/dist/adapter/bun.d.ts +17 -1
- package/dist/adapter/package.d.ts +26 -0
- package/dist/build/client.d.ts +1 -1
- package/dist/build/compile-entry.d.ts +3 -3
- package/dist/build/compile-entry.ts +114 -109
- package/dist/build/entry-template.d.ts +35 -9
- package/dist/build/entry-template.ts +206 -156
- package/dist/build/hydrate.d.ts +1 -1
- package/dist/build/index.js +643 -247
- package/dist/build/scan-server.d.ts +10 -4
- package/dist/build/server-routes-entry.d.ts +3 -3
- package/dist/build/server-routes-entry.ts +30 -36
- package/dist/build/ssg-cache.d.ts +1 -1
- package/dist/build/types.d.ts +36 -1
- package/dist/cli/config.d.ts +6 -1
- package/dist/cli/index.js +662 -260
- package/dist/client/link.js +163 -16
- package/dist/client/router/abort.d.ts +1 -0
- package/dist/client/router/sync-catch-up.d.ts +29 -0
- package/dist/config.d.ts +11 -2
- package/dist/config.js +5 -1
- package/dist/furin.d.ts +37 -19
- package/dist/furin.js +982 -378
- package/dist/server/auto-invalidate/registry.d.ts +8 -1
- package/dist/server/cache/dev-loader.d.ts +3 -2
- package/dist/server/cache/invalidation.d.ts +19 -0
- package/dist/server/cache/isr.d.ts +6 -2
- package/dist/server/cache/registry.d.ts +3 -3
- package/dist/server/cache/ssg.d.ts +6 -2
- package/dist/server/cache/store-view.d.ts +11 -0
- package/dist/server/instance.d.ts +86 -0
- package/dist/server/internal.d.ts +16 -1
- package/dist/server/internal.js +72 -5
- package/dist/server/render/template.d.ts +3 -2
- package/dist/server/sync/adapter.d.ts +62 -0
- package/dist/server/sync/config.d.ts +11 -0
- package/dist/server/sync/fingerprint.d.ts +6 -0
- package/dist/server/sync/index.d.ts +2 -2
- package/dist/server/sync/memory-adapter.d.ts +17 -0
- package/dist/server/sync/plugin.d.ts +12 -195
- package/dist/server/sync/response.d.ts +4 -0
- package/dist/server/sync/stream.d.ts +24 -5
- package/dist/shared/prefix.d.ts +15 -0
- package/package.json +6 -1
- package/src/adapter/README.md +13 -13
- package/src/adapter/bun.ts +113 -50
- package/src/adapter/package.ts +206 -0
- package/src/build/client.ts +158 -152
- package/src/build/compile-entry.ts +114 -109
- package/src/build/entry-template.ts +206 -156
- package/src/build/hydrate.ts +342 -340
- package/src/build/index.ts +223 -152
- package/src/build/route-types.ts +145 -145
- package/src/build/scan-server.ts +111 -95
- package/src/build/server-routes-entry.ts +30 -36
- package/src/build/shared.ts +80 -80
- package/src/build/ssg-cache.ts +36 -32
- package/src/build/types.ts +125 -89
- package/src/cli/config.ts +9 -3
- package/src/cli/index.ts +21 -3
- package/src/client/router/abort.ts +5 -0
- package/src/client/router/link-utils.ts +184 -184
- package/src/client/router/provider.tsx +883 -804
- package/src/client/router/sync-catch-up.ts +113 -0
- package/src/client/router/types.ts +276 -276
- package/src/client/sync.ts +98 -98
- package/src/client.ts +369 -369
- package/src/config.ts +14 -1
- package/src/furin.ts +619 -465
- package/src/server/auto-invalidate/registry.ts +23 -1
- package/src/server/auto-invalidate/runtime.ts +159 -134
- package/src/server/cache/dev-loader.ts +77 -38
- package/src/server/cache/invalidation.ts +71 -30
- package/src/server/cache/isr.ts +20 -5
- package/src/server/cache/registry.ts +17 -20
- package/src/server/cache/ssg.ts +19 -4
- package/src/server/cache/store-view.ts +30 -0
- package/src/server/dev-page-plugin.ts +454 -454
- package/src/server/instance.ts +252 -0
- package/src/server/internal.ts +100 -5
- package/src/server/render/assemble.ts +160 -160
- package/src/server/render/isr.ts +323 -323
- package/src/server/render/not-found.ts +9 -3
- package/src/server/render/ssr.ts +603 -585
- package/src/server/render/template.ts +57 -24
- package/src/server/router/plugin.ts +384 -384
- package/src/server/sync/adapter.ts +65 -0
- package/src/server/sync/config.ts +60 -29
- package/src/server/sync/fingerprint.ts +44 -0
- package/src/server/sync/index.ts +15 -14
- package/src/server/sync/memory-adapter.ts +196 -0
- package/src/server/sync/plugin.ts +199 -108
- package/src/server/sync/response.ts +77 -0
- package/src/server/sync/stream.ts +162 -144
- package/src/shared/deferred-ndjson.ts +7 -0
- package/src/shared/prefix.ts +38 -0
package/src/build/shared.ts
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
import { cpSync, existsSync, mkdirSync, readdirSync, rmSync } from "node:fs";
|
|
2
|
-
import { join, relative } from "node:path";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
|
-
import type { BuildTarget } from "../config";
|
|
5
|
-
import type { ResolvedRoute } from "../server/router/index.ts";
|
|
6
|
-
import type { BuildRouteManifestEntry, TargetBuildManifest } from "./types";
|
|
7
|
-
|
|
8
|
-
// import.meta.dir/path/url are inlined at bundle time to the OUTPUT file's
|
|
9
|
-
// location — so relative paths break when bundled. import.meta.resolve() is a
|
|
10
|
-
// function call (not inlined), runs at runtime, and resolves through package
|
|
11
|
-
// exports. This is the Web-standard approach (Bun, Node 20.6+, browsers).
|
|
12
|
-
export const CLIENT_MODULE_PATH = fileURLToPath(import.meta.resolve("@teyik0/furin/client"));
|
|
13
|
-
export const LINK_MODULE_PATH = fileURLToPath(import.meta.resolve("@teyik0/furin/link"));
|
|
14
|
-
export const SEARCH_MODULE_PATH = fileURLToPath(import.meta.resolve("@teyik0/furin/search"));
|
|
15
|
-
|
|
16
|
-
export function ensureDir(path: string): void {
|
|
17
|
-
if (!existsSync(path)) {
|
|
18
|
-
mkdirSync(path, { recursive: true });
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function toPosixPath(path: string): string {
|
|
23
|
-
return path.replace(/\\/g, "/");
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function collectFilesRecursive(dir: string): string[] {
|
|
27
|
-
const files: string[] = [];
|
|
28
|
-
const entries = readdirSync(dir, { withFileTypes: true });
|
|
29
|
-
|
|
30
|
-
for (const entry of entries) {
|
|
31
|
-
const absolutePath = join(dir, entry.name);
|
|
32
|
-
if (entry.isDirectory()) {
|
|
33
|
-
files.push(...collectFilesRecursive(absolutePath));
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
if (entry.isFile()) {
|
|
37
|
-
files.push(absolutePath);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return files.sort();
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function copyDirRecursive(sourceDir: string, targetDir: string): void {
|
|
45
|
-
rmSync(targetDir, { force: true, recursive: true });
|
|
46
|
-
cpSync(sourceDir, targetDir, { recursive: true });
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function toBuildRouteManifestEntry(
|
|
50
|
-
route: ResolvedRoute,
|
|
51
|
-
rootDir: string
|
|
52
|
-
): BuildRouteManifestEntry {
|
|
53
|
-
return {
|
|
54
|
-
pattern: route.pattern,
|
|
55
|
-
mode: route.mode,
|
|
56
|
-
pagePath: toPosixPath(relative(rootDir, route.path)),
|
|
57
|
-
hasLayout: route.routeChain.some((entry) => !!entry.layout),
|
|
58
|
-
hasStaticParams: !!route.page?.staticParams,
|
|
59
|
-
revalidate: route.page?._route.revalidate ?? null,
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export function buildTargetManifest(
|
|
64
|
-
rootDir: string,
|
|
65
|
-
buildRoot: string,
|
|
66
|
-
target: BuildTarget,
|
|
67
|
-
serverEntry: string | null
|
|
68
|
-
): TargetBuildManifest {
|
|
69
|
-
const targetDir = join(buildRoot, target);
|
|
70
|
-
|
|
71
|
-
return {
|
|
72
|
-
buildId: "", // populated by adapter after buildClient() completes
|
|
73
|
-
generatedAt: new Date().toISOString(),
|
|
74
|
-
targetDir: toPosixPath(relative(rootDir, targetDir)),
|
|
75
|
-
clientDir: toPosixPath(relative(rootDir, join(targetDir, "client"))),
|
|
76
|
-
templatePath: toPosixPath(relative(rootDir, join(targetDir, "client", "index.html"))),
|
|
77
|
-
serverPath: null,
|
|
78
|
-
serverEntry: serverEntry ? toPosixPath(relative(rootDir, serverEntry)) : null,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
1
|
+
import { cpSync, existsSync, mkdirSync, readdirSync, rmSync } from "node:fs";
|
|
2
|
+
import { join, relative } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import type { BuildTarget } from "../config";
|
|
5
|
+
import type { ResolvedRoute } from "../server/router/index.ts";
|
|
6
|
+
import type { BuildRouteManifestEntry, TargetBuildManifest } from "./types";
|
|
7
|
+
|
|
8
|
+
// import.meta.dir/path/url are inlined at bundle time to the OUTPUT file's
|
|
9
|
+
// location — so relative paths break when bundled. import.meta.resolve() is a
|
|
10
|
+
// function call (not inlined), runs at runtime, and resolves through package
|
|
11
|
+
// exports. This is the Web-standard approach (Bun, Node 20.6+, browsers).
|
|
12
|
+
export const CLIENT_MODULE_PATH = fileURLToPath(import.meta.resolve("@teyik0/furin/client"));
|
|
13
|
+
export const LINK_MODULE_PATH = fileURLToPath(import.meta.resolve("@teyik0/furin/link"));
|
|
14
|
+
export const SEARCH_MODULE_PATH = fileURLToPath(import.meta.resolve("@teyik0/furin/search"));
|
|
15
|
+
|
|
16
|
+
export function ensureDir(path: string): void {
|
|
17
|
+
if (!existsSync(path)) {
|
|
18
|
+
mkdirSync(path, { recursive: true });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function toPosixPath(path: string): string {
|
|
23
|
+
return path.replace(/\\/g, "/");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function collectFilesRecursive(dir: string): string[] {
|
|
27
|
+
const files: string[] = [];
|
|
28
|
+
const entries = readdirSync(dir, { withFileTypes: true });
|
|
29
|
+
|
|
30
|
+
for (const entry of entries) {
|
|
31
|
+
const absolutePath = join(dir, entry.name);
|
|
32
|
+
if (entry.isDirectory()) {
|
|
33
|
+
files.push(...collectFilesRecursive(absolutePath));
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (entry.isFile()) {
|
|
37
|
+
files.push(absolutePath);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return files.sort();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function copyDirRecursive(sourceDir: string, targetDir: string): void {
|
|
45
|
+
rmSync(targetDir, { force: true, recursive: true });
|
|
46
|
+
cpSync(sourceDir, targetDir, { recursive: true });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function toBuildRouteManifestEntry(
|
|
50
|
+
route: ResolvedRoute,
|
|
51
|
+
rootDir: string
|
|
52
|
+
): BuildRouteManifestEntry {
|
|
53
|
+
return {
|
|
54
|
+
pattern: route.pattern,
|
|
55
|
+
mode: route.mode,
|
|
56
|
+
pagePath: toPosixPath(relative(rootDir, route.path)),
|
|
57
|
+
hasLayout: route.routeChain.some((entry) => !!entry.layout),
|
|
58
|
+
hasStaticParams: !!route.page?.staticParams,
|
|
59
|
+
revalidate: route.page?._route.revalidate ?? null,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function buildTargetManifest(
|
|
64
|
+
rootDir: string,
|
|
65
|
+
buildRoot: string,
|
|
66
|
+
target: BuildTarget,
|
|
67
|
+
serverEntry: string | null
|
|
68
|
+
): TargetBuildManifest {
|
|
69
|
+
const targetDir = join(buildRoot, target);
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
buildId: "", // populated by adapter after buildClient() completes
|
|
73
|
+
generatedAt: new Date().toISOString(),
|
|
74
|
+
targetDir: toPosixPath(relative(rootDir, targetDir)),
|
|
75
|
+
clientDir: toPosixPath(relative(rootDir, join(targetDir, "client"))),
|
|
76
|
+
templatePath: toPosixPath(relative(rootDir, join(targetDir, "client", "index.html"))),
|
|
77
|
+
serverPath: null,
|
|
78
|
+
serverEntry: serverEntry ? toPosixPath(relative(rootDir, serverEntry)) : null,
|
|
79
|
+
};
|
|
80
|
+
}
|
package/src/build/ssg-cache.ts
CHANGED
|
@@ -1,32 +1,36 @@
|
|
|
1
|
-
import type { SsgCacheEntry } from "../server/cache/index.ts";
|
|
2
|
-
import { prerenderSSG } from "../server/render/index.ts";
|
|
3
|
-
import { createSearchRouteMetadata, type ResolvedRoute, type RootLayout } from "../server/router/index.ts";
|
|
4
|
-
import { resolvePath } from "../server/render/assemble.ts";
|
|
5
|
-
|
|
6
|
-
export type SSGCacheSnapshot = Record<string, SsgCacheEntry>;
|
|
7
|
-
|
|
8
|
-
export async function buildSSGCacheSnapshot(
|
|
9
|
-
routes: ResolvedRoute[],
|
|
10
|
-
root: RootLayout,
|
|
11
|
-
origin: string
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
1
|
+
import type { SsgCacheEntry } from "../server/cache/index.ts";
|
|
2
|
+
import { prerenderSSG } from "../server/render/index.ts";
|
|
3
|
+
import { createSearchRouteMetadata, type ResolvedRoute, type RootLayout } from "../server/router/index.ts";
|
|
4
|
+
import { resolvePath } from "../server/render/assemble.ts";
|
|
5
|
+
|
|
6
|
+
export type SSGCacheSnapshot = Record<string, SsgCacheEntry>;
|
|
7
|
+
|
|
8
|
+
export async function buildSSGCacheSnapshot(
|
|
9
|
+
routes: ResolvedRoute[],
|
|
10
|
+
root: RootLayout,
|
|
11
|
+
origin: string,
|
|
12
|
+
// Build-time renders run OUTSIDE any instance scope (default bucket), so a
|
|
13
|
+
// prefixed app's mount prefix must be passed explicitly — otherwise the
|
|
14
|
+
// snapshot HTML bakes in basePath "" and prerendered <Link> hrefs lose it.
|
|
15
|
+
basePath?: string
|
|
16
|
+
): Promise<SSGCacheSnapshot> {
|
|
17
|
+
const snapshot: SSGCacheSnapshot = {};
|
|
18
|
+
const searchRoutes = createSearchRouteMetadata(routes);
|
|
19
|
+
|
|
20
|
+
for (const route of routes) {
|
|
21
|
+
if (route.mode !== "ssg" || !route.page.staticParams) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const paramSets = await route.page.staticParams();
|
|
26
|
+
for (const params of paramSets) {
|
|
27
|
+
const entry = await prerenderSSG(route, params, root, origin, basePath, searchRoutes);
|
|
28
|
+
if (entry instanceof Response) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
snapshot[resolvePath(route.pattern, params)] = entry;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return snapshot;
|
|
36
|
+
}
|
package/src/build/types.ts
CHANGED
|
@@ -1,89 +1,125 @@
|
|
|
1
|
-
import type { BuildTarget, StaticExportConfig } from "../config";
|
|
2
|
-
import type { ResolvedRoute } from "../server/router/index.ts";
|
|
3
|
-
|
|
4
|
-
export interface BuildClientOptions {
|
|
5
|
-
/**
|
|
6
|
-
* Sub-path prefix for the deployment (e.g. "/furin" for GitHub Pages).
|
|
7
|
-
* Passed through to the generated hydrate entry so SPA navigation uses
|
|
8
|
-
* correct physical URLs. Pass "" for root deployments.
|
|
9
|
-
*/
|
|
10
|
-
basePath: string;
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
1
|
+
import type { BuildTarget, StaticExportConfig } from "../config";
|
|
2
|
+
import type { ResolvedRoute } from "../server/router/index.ts";
|
|
3
|
+
|
|
4
|
+
export interface BuildClientOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Sub-path prefix for the deployment (e.g. "/furin" for GitHub Pages).
|
|
7
|
+
* Passed through to the generated hydrate entry so SPA navigation uses
|
|
8
|
+
* correct physical URLs. Pass "" for root deployments.
|
|
9
|
+
*/
|
|
10
|
+
basePath: string;
|
|
11
|
+
/**
|
|
12
|
+
* On-disk client dir name under outDir (default "client"). Multi-instance
|
|
13
|
+
* builds pass "client-<slug>" per mounted app.
|
|
14
|
+
*/
|
|
15
|
+
clientDirName?: string;
|
|
16
|
+
/** Inject the evlog client logger into the hydrate entry. Off by default. */
|
|
17
|
+
clientLogging: boolean;
|
|
18
|
+
outDir: string;
|
|
19
|
+
pagesDir?: string;
|
|
20
|
+
plugins?: Bun.BunPlugin[];
|
|
21
|
+
/**
|
|
22
|
+
* Public path prefix for all emitted JS/CSS chunks.
|
|
23
|
+
* Pass "/_client/" for root deployments; override for basePath deployments,
|
|
24
|
+
* e.g. "/furin/_client/".
|
|
25
|
+
*/
|
|
26
|
+
publicPath: string;
|
|
27
|
+
rootLayout: string;
|
|
28
|
+
/**
|
|
29
|
+
* Skip furin-env.d.ts generation. Set for non-root instances in
|
|
30
|
+
* multi-instance dev — the file lives at the project root and only the root
|
|
31
|
+
* app owns it.
|
|
32
|
+
*/
|
|
33
|
+
skipRouteTypes?: boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface BuildRouteManifestEntry {
|
|
37
|
+
hasLayout: boolean;
|
|
38
|
+
hasStaticParams: boolean;
|
|
39
|
+
mode: ResolvedRoute["mode"];
|
|
40
|
+
pagePath: string;
|
|
41
|
+
pattern: string;
|
|
42
|
+
revalidate: number | null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface TargetBuildManifest {
|
|
46
|
+
buildId: string;
|
|
47
|
+
clientDir: string | null;
|
|
48
|
+
generatedAt: string;
|
|
49
|
+
serverEntry: string | null;
|
|
50
|
+
serverPath: string | null;
|
|
51
|
+
targetDir: string;
|
|
52
|
+
templatePath: string | null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Build manifest entry produced by the `package` adapter. */
|
|
56
|
+
export interface PackageTargetBuildManifest {
|
|
57
|
+
buildId: string;
|
|
58
|
+
generatedAt: string;
|
|
59
|
+
prefix: string;
|
|
60
|
+
targetDir: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export type AnyTargetManifest =
|
|
64
|
+
| TargetBuildManifest
|
|
65
|
+
| StaticTargetBuildManifest
|
|
66
|
+
| PackageTargetBuildManifest;
|
|
67
|
+
|
|
68
|
+
/** One mounted app in a multi-instance build. */
|
|
69
|
+
export interface BuildAppSpec {
|
|
70
|
+
pagesDir: string;
|
|
71
|
+
/** Mount prefix (`""` or absent = root). */
|
|
72
|
+
prefix?: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface BuildManifest {
|
|
76
|
+
/** Every mounted app built into this artifact (multi-instance). */
|
|
77
|
+
apps?: Array<{ pagesDir: string; prefix: string; routes: BuildRouteManifestEntry[] }>;
|
|
78
|
+
generatedAt: string;
|
|
79
|
+
pagesDir: string;
|
|
80
|
+
rootDir: string;
|
|
81
|
+
rootPath: string;
|
|
82
|
+
routes: BuildRouteManifestEntry[];
|
|
83
|
+
serverEntry: string | null;
|
|
84
|
+
targets: Partial<Record<BuildTarget, AnyTargetManifest>>;
|
|
85
|
+
version: 1;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface BuildAppOptions {
|
|
89
|
+
/**
|
|
90
|
+
* Explicit multi-app build (furin.config.ts `apps`). Overrides `pagesDir`
|
|
91
|
+
* and server-entry auto-detection.
|
|
92
|
+
*/
|
|
93
|
+
apps?: BuildAppSpec[];
|
|
94
|
+
/** Inject the evlog client logger into the hydrate entry. Defaults to false. */
|
|
95
|
+
clientLogging?: boolean;
|
|
96
|
+
compile?: "server" | "embed";
|
|
97
|
+
pagesDir?: string;
|
|
98
|
+
plugins?: Bun.BunPlugin[];
|
|
99
|
+
rootDir?: string;
|
|
100
|
+
serverEntry?: string;
|
|
101
|
+
/** Configuration for the `static` build target. */
|
|
102
|
+
staticConfig?: StaticExportConfig;
|
|
103
|
+
target: BuildTarget | "all";
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Build manifest entry produced by the `static` adapter. */
|
|
107
|
+
export interface StaticTargetBuildManifest {
|
|
108
|
+
basePath: string;
|
|
109
|
+
generatedAt: string;
|
|
110
|
+
outDir: string;
|
|
111
|
+
renderedRoutes: string[];
|
|
112
|
+
skippedRoutes: string[];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface BuildAppResult {
|
|
116
|
+
manifest: BuildManifest;
|
|
117
|
+
targets: Partial<Record<BuildTarget, AnyTargetManifest>>;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export type BunBuildAliasConfig = Bun.BuildConfig & {
|
|
121
|
+
alias?: Record<string, string>;
|
|
122
|
+
outfile?: string;
|
|
123
|
+
packages?: "bundle" | "external";
|
|
124
|
+
write?: boolean;
|
|
125
|
+
};
|
package/src/cli/config.ts
CHANGED
|
@@ -14,7 +14,12 @@ const DEFAULT_CONFIG_FILENAMES = [
|
|
|
14
14
|
|
|
15
15
|
interface ResolvedCliConfig extends FurinConfig {
|
|
16
16
|
configPath: string | null;
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Only set when the config file declares one — leaving it undefined lets
|
|
19
|
+
* buildApp fall back to scanning server.ts for `furin({ pagesDir, prefix })`
|
|
20
|
+
* calls (multi-instance detection).
|
|
21
|
+
*/
|
|
22
|
+
pagesDir?: string;
|
|
18
23
|
plugins?: Bun.BunPlugin[];
|
|
19
24
|
rootDir: string;
|
|
20
25
|
}
|
|
@@ -34,7 +39,6 @@ export async function loadCliConfig(
|
|
|
34
39
|
return {
|
|
35
40
|
configPath: null,
|
|
36
41
|
rootDir,
|
|
37
|
-
pagesDir: resolve(rootDir, "src/pages"),
|
|
38
42
|
};
|
|
39
43
|
}
|
|
40
44
|
|
|
@@ -63,6 +67,8 @@ export async function loadCliConfig(
|
|
|
63
67
|
plugins,
|
|
64
68
|
configPath,
|
|
65
69
|
rootDir: resolvedRootDir,
|
|
66
|
-
pagesDir:
|
|
70
|
+
pagesDir: configToValidate.pagesDir
|
|
71
|
+
? resolve(resolvedRootDir, configToValidate.pagesDir)
|
|
72
|
+
: undefined,
|
|
67
73
|
};
|
|
68
74
|
}
|
package/src/cli/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { resolve } from "node:path";
|
|
|
4
4
|
import { parseArgs } from "node:util";
|
|
5
5
|
import { buildApp } from "../build/index.ts";
|
|
6
6
|
import { BUILD_TARGETS, type BuildTarget } from "../config.ts";
|
|
7
|
+
import { normalizePrefix } from "../server/instance.ts";
|
|
7
8
|
import { loadCliConfig } from "./config.ts";
|
|
8
9
|
|
|
9
10
|
const argv = process.argv.slice(2);
|
|
@@ -40,6 +41,7 @@ if (command === "build") {
|
|
|
40
41
|
options: {
|
|
41
42
|
target: { type: "string" },
|
|
42
43
|
pagesDir: { type: "string" },
|
|
44
|
+
prefix: { type: "string" },
|
|
43
45
|
config: { type: "string" },
|
|
44
46
|
},
|
|
45
47
|
strict: false,
|
|
@@ -48,6 +50,7 @@ if (command === "build") {
|
|
|
48
50
|
const values = rawValues as {
|
|
49
51
|
target?: string;
|
|
50
52
|
pagesDir?: string;
|
|
53
|
+
prefix?: string;
|
|
51
54
|
config?: string;
|
|
52
55
|
};
|
|
53
56
|
|
|
@@ -70,9 +73,9 @@ if (command === "build") {
|
|
|
70
73
|
|
|
71
74
|
const config = await loadCliConfig(process.cwd(), values.config);
|
|
72
75
|
|
|
73
|
-
const
|
|
76
|
+
const isServerlessTarget = target === "static" || target === "package";
|
|
74
77
|
|
|
75
|
-
const resolvedServerEntry =
|
|
78
|
+
const resolvedServerEntry = isServerlessTarget
|
|
76
79
|
? undefined
|
|
77
80
|
: (() => {
|
|
78
81
|
const entry = resolve(config.rootDir, config.serverEntry ?? "src/server.ts");
|
|
@@ -89,7 +92,20 @@ if (command === "build") {
|
|
|
89
92
|
target: target as BuildTarget | "all",
|
|
90
93
|
compile: resolveCompileMode(compileFlag, config.bun?.compile),
|
|
91
94
|
rootDir: config.rootDir,
|
|
92
|
-
|
|
95
|
+
// --pagesDir/--prefix build a single explicit app; otherwise fall back to
|
|
96
|
+
// the config's `apps` list (then to server.ts scanning inside buildApp).
|
|
97
|
+
// normalizePrefix here so a bad --prefix fails before buildApp starts
|
|
98
|
+
// (resolveAppSpecs normalizes config-provided prefixes the same way).
|
|
99
|
+
apps:
|
|
100
|
+
(values.pagesDir ?? config.pagesDir)
|
|
101
|
+
? [
|
|
102
|
+
{
|
|
103
|
+
pagesDir: values.pagesDir ?? (config.pagesDir as string),
|
|
104
|
+
prefix: normalizePrefix(values.prefix),
|
|
105
|
+
},
|
|
106
|
+
]
|
|
107
|
+
: config.apps,
|
|
108
|
+
pagesDir: undefined,
|
|
93
109
|
serverEntry: resolvedServerEntry,
|
|
94
110
|
plugins: config.plugins,
|
|
95
111
|
staticConfig: config.static,
|
|
@@ -106,7 +122,9 @@ USAGE furin build [options]
|
|
|
106
122
|
|
|
107
123
|
OPTIONS
|
|
108
124
|
--target ${BUILD_TARGETS.join(" | ")} | all (default: bun)
|
|
125
|
+
"package" builds a publishable Elysia-plugin artifact (register.js + factory + client assets)
|
|
109
126
|
--pagesDir Pages directory
|
|
127
|
+
--prefix Mount prefix for the built app (e.g. /admin) — pairs with --pagesDir
|
|
110
128
|
--config Config file path
|
|
111
129
|
--compile server | embed Compile to binary: "server" keeps client on disk, "embed" is self-contained
|
|
112
130
|
`
|