@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/dist/adapter/bun.d.ts
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
1
|
import type { BuildAppOptions, TargetBuildManifest } from "../build/types.ts";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
* Deterministic build-ID input covering everything that can change rendered
|
|
5
|
-
* output: client chunks, route shape, route/root/error/not-found source
|
|
6
|
-
* contents and the framework's own render pipeline sources. Shared with the
|
|
7
|
-
* package target so packaged apps get the same stale-deploy detection —
|
|
8
|
-
* SSR-only changes (loader/page code that never reaches the client bundle)
|
|
9
|
-
* must still produce a new build ID.
|
|
10
|
-
*/
|
|
11
|
-
export declare function createBuildFingerprint(entryChunk: string, cssChunks: string[], routes: ResolvedRoute[], root: RootLayout, serverEntry: string | null): Promise<string>;
|
|
12
|
-
/** One mounted app's build input (root + routes scanned from its pagesDir). */
|
|
13
|
-
export interface BunTargetApp {
|
|
14
|
-
pagesDir: string;
|
|
15
|
-
prefix: string;
|
|
16
|
-
root: RootLayout;
|
|
17
|
-
routes: ResolvedRoute[];
|
|
18
|
-
}
|
|
19
|
-
export declare function buildBunTarget(apps: BunTargetApp[], rootDir: string, buildRoot: string, serverEntry: string | null, options: BuildAppOptions): Promise<TargetBuildManifest>;
|
|
2
|
+
import { type RuntimeTargetApp } from "./runtime-build.ts";
|
|
3
|
+
export declare function buildBunTarget(apps: RuntimeTargetApp[], rootDir: string, buildRoot: string, serverEntry: string | null, options: BuildAppOptions): Promise<TargetBuildManifest>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type RuntimeTargetApp } from "../adapter/runtime-build.ts";
|
|
2
2
|
import type { BuildAppOptions, PackageTargetBuildManifest } from "../build/types.ts";
|
|
3
3
|
/**
|
|
4
4
|
* `--target package` — builds a furin app as a PUBLISHABLE Elysia plugin
|
|
@@ -23,4 +23,4 @@ import type { BuildAppOptions, PackageTargetBuildManifest } from "../build/types
|
|
|
23
23
|
* so the same factory works under `bun --hot` (dev scans live). A published
|
|
24
24
|
* package without sources is production-only; its context is found by prefix.
|
|
25
25
|
*/
|
|
26
|
-
export declare function buildPackageTarget(app:
|
|
26
|
+
export declare function buildPackageTarget(app: RuntimeTargetApp, rootDir: string, buildRoot: string, options: BuildAppOptions): Promise<PackageTargetBuildManifest>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { BuildEntryOptions } from "../build/entry-template.ts";
|
|
2
|
+
import { type RoutePrerender } from "../build/ssg-cache.ts";
|
|
3
|
+
import type { BuildAppOptions } from "../build/types.ts";
|
|
4
|
+
import type { ResolvedRoute, RootLayout } from "../server/router/types.ts";
|
|
5
|
+
/**
|
|
6
|
+
* Deterministic build-ID input covering everything that can change rendered
|
|
7
|
+
* output: client chunks, route shape, route/root/error/not-found source
|
|
8
|
+
* contents and the framework's own render pipeline sources.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createBuildFingerprint(entryChunk: string, cssChunks: string[], routes: ResolvedRoute[], root: RootLayout, serverEntry: string | null, routeSources: string[], projectRoot: string): Promise<string>;
|
|
11
|
+
/** One mounted app's build input (root + routes scanned from its pagesDir). */
|
|
12
|
+
export interface RuntimeTargetApp {
|
|
13
|
+
pagesDir: string;
|
|
14
|
+
prefix: string;
|
|
15
|
+
root: RootLayout;
|
|
16
|
+
routes: ResolvedRoute[];
|
|
17
|
+
}
|
|
18
|
+
/** Avoid loading React's resumable renderer in applications without PPR routes. */
|
|
19
|
+
export declare function pprRuntimePlugin(apps: RuntimeTargetApp[]): Bun.BunPlugin;
|
|
20
|
+
export interface RuntimeAppBuild {
|
|
21
|
+
buildId: string;
|
|
22
|
+
clientDir: string;
|
|
23
|
+
entryApp: BuildEntryOptions["apps"][number];
|
|
24
|
+
indexHtml: string;
|
|
25
|
+
prerenders: RoutePrerender[];
|
|
26
|
+
}
|
|
27
|
+
/** Builds one app's client bundle and compile-context payload. */
|
|
28
|
+
export declare function buildRuntimeApp(app: RuntimeTargetApp, projectRoot: string, targetDir: string, serverEntry: string | null, options: BuildAppOptions, targetName: "bun" | "vercel"): Promise<RuntimeAppBuild>;
|
|
29
|
+
export declare function buildRuntimeAppsSequentially(apps: RuntimeTargetApp[], projectRoot: string, targetDir: string, serverEntry: string | null, options: BuildAppOptions, targetName: "bun" | "vercel"): Promise<{
|
|
30
|
+
builds: RuntimeAppBuild[];
|
|
31
|
+
entryApps: BuildEntryOptions["apps"];
|
|
32
|
+
headlineBuildId: string;
|
|
33
|
+
}>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { BuildAppOptions, VercelTargetBuildManifest } from "../build/types.ts";
|
|
2
|
+
import { type RuntimeTargetApp } from "./runtime-build.ts";
|
|
3
|
+
export declare function buildVercelTarget(apps: RuntimeTargetApp[], rootDir: string, buildRoot: string, serverEntry: string, options: BuildAppOptions): Promise<VercelTargetBuildManifest>;
|
package/dist/build/client.d.ts
CHANGED
|
@@ -22,4 +22,4 @@ export interface BuildClientResult {
|
|
|
22
22
|
* it as an SSR template, injects the pre-rendered React HTML into
|
|
23
23
|
* <!--ssr-outlet-->, and sends the complete page.
|
|
24
24
|
*/
|
|
25
|
-
export declare function buildClient(routes: ResolvedRoute[], { outDir, rootLayout, plugins, publicPath, basePath, clientLogging, clientDirName, pagesDir, }: BuildClientOptions): Promise<BuildClientResult>;
|
|
25
|
+
export declare function buildClient(routes: ResolvedRoute[], { outDir, rootLayout, plugins, publicPath, basePath, clientLogging, clientDirName, metafilePath, optimizeImports, reactCompiler, pagesDir, }: BuildClientOptions): Promise<BuildClientResult>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { type BuildEntryOptions } from "./entry-template";
|
|
2
|
+
import { type VirtualBuildEntry } from "./virtual-entry.ts";
|
|
2
3
|
/**
|
|
3
|
-
* Generates a
|
|
4
|
+
* Generates a virtual `_compile-entry.ts` that:
|
|
4
5
|
* 1. Statically imports every page module of every app so Bun bundles them
|
|
5
|
-
* 2.
|
|
6
|
+
* 2. Points embed-mode contexts at Bun's `compile.assets` directories
|
|
6
7
|
* 3. Sets production mode and registers one CompileContext PER APP
|
|
7
8
|
* 4. Dynamically imports server.ts to boot the composed app
|
|
8
9
|
*/
|
|
9
|
-
export declare function generateCompileEntry(options: BuildEntryOptions):
|
|
10
|
+
export declare function generateCompileEntry(options: BuildEntryOptions): VirtualBuildEntry;
|
|
@@ -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
|
}
|
|
@@ -6,8 +6,6 @@ export interface EntryAppContext {
|
|
|
6
6
|
clientLogging?: boolean;
|
|
7
7
|
/** Extra lines injected inside this app's `__setCompileContext({...})` call. */
|
|
8
8
|
extraContext?: string[];
|
|
9
|
-
/** Extra import lines this app needs (embedded asset imports). */
|
|
10
|
-
extraImports?: string[];
|
|
11
9
|
/** Additional route modules such as filesystem-derived `_route` layouts. */
|
|
12
10
|
modulePaths?: string[];
|
|
13
11
|
/** Virtual module specifier exporting this app's composed Elysia route tree. */
|
|
@@ -32,7 +30,11 @@ export interface EntryAppContext {
|
|
|
32
30
|
path: string;
|
|
33
31
|
pattern: string;
|
|
34
32
|
}>;
|
|
33
|
+
/** False when the deployment platform serves client/public assets itself. */
|
|
34
|
+
serveAssets?: boolean;
|
|
35
35
|
ssgCache?: Record<string, SsgCacheEntry>;
|
|
36
|
+
/** In-memory production document template for filesystem-free runtimes. */
|
|
37
|
+
templateHtml?: string;
|
|
36
38
|
}
|
|
37
39
|
export interface EntryTemplateOptions {
|
|
38
40
|
apps: EntryAppContext[];
|
|
@@ -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/dist/build/index.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ export { buildClient } from "./client";
|
|
|
3
3
|
export { writeDevFiles } from "./hydrate";
|
|
4
4
|
export { writeRouteTypes } from "./route-types";
|
|
5
5
|
export { buildSSGCacheSnapshot, type SSGCacheSnapshot } from "./ssg-cache";
|
|
6
|
-
export type { BuildAppOptions, BuildAppResult, BuildClientOptions, BuildManifest, BuildRouteManifestEntry, TargetBuildManifest, } from "./types";
|
|
6
|
+
export type { BuildAppOptions, BuildAppResult, BuildClientOptions, BuildManifest, BuildRouteManifestEntry, TargetBuildManifest, VercelTargetBuildManifest, } from "./types";
|
|
7
7
|
export declare const BUILD_OUTPUT_DIR = ".furin/build";
|
|
8
8
|
export declare function buildApp(options: BuildAppOptions): Promise<BuildAppResult>;
|