@teyik0/furin 0.6.0-alpha.1 → 0.7.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/runtime-build.d.ts +1 -1
- package/dist/build/client.d.ts +4 -1
- package/dist/build/elysia-aot-worker.d.ts +22 -0
- package/dist/build/elysia-aot.d.ts +1 -1
- package/dist/build/entry-template.d.ts +3 -0
- package/dist/build/entry-template.ts +7 -0
- package/dist/build/hydrate.d.ts +1 -1
- package/dist/build/index.js +1880 -401
- package/dist/build/preload-manifest.d.ts +17 -0
- package/dist/build/types.d.ts +6 -0
- package/dist/cli/index.js +1878 -408
- package/dist/client/client-module.d.ts +26 -0
- package/dist/client/define-route.d.ts +9 -0
- package/dist/client/document.d.ts +2 -0
- package/dist/client/internal/runtime-types.d.ts +2 -0
- package/dist/client/link.js +942 -122
- package/dist/client/mutation.d.ts +38 -0
- package/dist/client/query-store.d.ts +85 -0
- package/dist/client/query.d.ts +14 -0
- package/dist/client/route-api.d.ts +11 -0
- package/dist/client/router/context.d.ts +3 -2
- package/dist/client/router/index.d.ts +1 -1
- package/dist/client/router/link-utils.d.ts +8 -1
- package/dist/client/router/navigation.d.ts +2 -9
- package/dist/client/router/optimistic.d.ts +41 -0
- package/dist/client/router/search/index.d.ts +3 -3
- package/dist/client/router/search-store.d.ts +1 -0
- package/dist/client/router/sync-catch-up.d.ts +3 -0
- package/dist/client/router/types.d.ts +51 -7
- package/dist/client/sync.d.ts +39 -22
- package/dist/client.d.ts +11 -33
- package/dist/client.js +1219 -59
- package/dist/config.d.ts +7 -0
- package/dist/config.js +1 -0
- package/dist/define-route.d.ts +78 -32
- package/dist/env.d.ts +2 -2
- package/dist/furin.d.ts +1 -2
- package/dist/furin.js +2484 -708
- package/dist/plugin/hmr-dependencies.d.ts +2 -0
- package/dist/plugin/index.js +349 -18
- package/dist/plugin/transform-client-module.d.ts +16 -0
- package/dist/plugin/transform-client.d.ts +2 -0
- package/dist/plugin/transform-isomorphic.d.ts +1 -1
- package/dist/routes.d.ts +6 -0
- package/dist/rsc-client.js +87 -16
- package/dist/rsc.js +87 -16
- package/dist/server/auto-invalidate/registry.d.ts +1 -0
- package/dist/server/auto-invalidate/types.d.ts +2 -0
- package/dist/server/cache/isr.d.ts +2 -4
- package/dist/server/cache/route-cache.d.ts +5 -0
- package/dist/server/dev/graph.d.ts +1 -0
- package/dist/server/dev-page-plugin.d.ts +5 -19
- package/dist/server/internal.d.ts +3 -0
- package/dist/server/internal.js +55 -35
- package/dist/server/production-server.js +54 -34
- package/dist/server/render/loaders.d.ts +4 -2
- package/dist/server/render/react-stream.d.ts +3 -0
- package/dist/server/render/ssr.d.ts +2 -1
- package/dist/server/render/template.d.ts +4 -0
- package/dist/server/router/defined-route.d.ts +2 -0
- package/dist/server/router/hmr.d.ts +1 -1
- package/dist/server/router/patterns.d.ts +2 -0
- package/dist/server/router/types.d.ts +1 -1
- package/dist/server/sync/adapter.d.ts +25 -4
- package/dist/server/sync/atomic.d.ts +25 -0
- package/dist/server/sync/drizzle/index.d.ts +45 -0
- package/dist/server/sync/drizzle/index.js +540 -0
- package/dist/server/sync/execution-error.d.ts +2 -0
- package/dist/server/sync/index.d.ts +2 -1
- package/dist/server/sync/index.js +533 -105
- package/dist/server/sync/mutation-handler.d.ts +4 -0
- package/dist/server/sync/plugin.d.ts +34 -11
- package/dist/server/sync/postgres/execute.d.ts +3 -0
- package/dist/server/sync/postgres/index.d.ts +12 -1
- package/dist/server/sync/postgres/index.js +34 -13
- package/dist/server/sync/postgres/sql.d.ts +8 -0
- package/dist/server/sync/prisma/index.d.ts +24 -0
- package/dist/server/sync/prisma/index.js +340 -0
- package/dist/server/sync/queries.d.ts +21 -0
- package/dist/server/sync/query-context.d.ts +5 -0
- package/dist/server/sync/redis/index.js +3 -3
- package/dist/server/sync/redis/scripts.d.ts +1 -1
- package/dist/server/sync/response.d.ts +1 -0
- package/dist/server/sync/sqlite/index.d.ts +3 -0
- package/dist/server/sync/sqlite/index.js +10 -4
- package/dist/server/sync/stream.d.ts +2 -5
- package/dist/server/sync/validation.d.ts +4 -0
- package/dist/shared/defer.d.ts +31 -0
- package/dist/shared/error.d.ts +2 -2
- package/dist/shared/page-key.d.ts +7 -0
- package/dist/shared/query-bindings.d.ts +12 -0
- package/dist/shared/route-frame.d.ts +1 -0
- package/dist/shared/sync-query.d.ts +40 -0
- package/package.json +29 -6
- package/src/adapter/package.ts +12 -2
- package/src/adapter/runtime-build.ts +63 -12
- package/src/adapter/static.ts +7 -2
- package/src/adapter/vercel.ts +15 -13
- package/src/build/client.ts +23 -5
- package/src/build/elysia-aot-worker.ts +51 -0
- package/src/build/elysia-aot.ts +83 -19
- package/src/build/entry-template.ts +7 -0
- package/src/build/hydrate.ts +21 -3
- package/src/build/preload-manifest.ts +100 -0
- package/src/build/production-instrumentation.ts +6 -3
- package/src/build/types.ts +4 -0
- package/src/cli/index.ts +1 -0
- package/src/client/browser-events-runtime.ts +4 -0
- package/src/client/client-module.ts +57 -0
- package/src/client/define-route.ts +11 -1
- package/src/client/document.tsx +28 -18
- package/src/client/hmr.ts +2 -1
- package/src/client/internal/runtime-types.ts +2 -0
- package/src/client/link.tsx +8 -8
- package/src/client/mutation.ts +136 -0
- package/src/client/query-store.ts +418 -0
- package/src/client/query.tsx +67 -0
- package/src/client/route-api.tsx +75 -0
- package/src/client/router/boundary-tree.tsx +19 -12
- package/src/client/router/context.ts +57 -4
- package/src/client/router/index.ts +3 -0
- package/src/client/router/link-utils.ts +29 -1
- package/src/client/router/navigation.ts +3 -50
- package/src/client/router/optimistic.ts +233 -0
- package/src/client/router/provider.tsx +306 -46
- package/src/client/router/search/index.ts +37 -17
- package/src/client/router/search-store.ts +4 -0
- package/src/client/router/sync-catch-up.ts +7 -0
- package/src/client/router/types.ts +73 -9
- package/src/client/sync.ts +438 -65
- package/src/client.ts +20 -60
- package/src/config.ts +5 -0
- package/src/define-route.ts +113 -55
- package/src/env.d.ts +2 -2
- package/src/furin.ts +75 -13
- package/src/plugin/hmr-dependencies.ts +58 -0
- package/src/plugin/index.ts +38 -2
- package/src/plugin/routes.ts +28 -16
- package/src/plugin/transform-client-module.ts +123 -0
- package/src/plugin/transform-client.ts +293 -13
- package/src/plugin/transform-isomorphic.ts +11 -5
- package/src/routes.ts +8 -0
- package/src/rsc/shared.tsx +104 -18
- package/src/server/auto-invalidate/registry.ts +4 -0
- package/src/server/auto-invalidate/runtime.ts +17 -0
- package/src/server/auto-invalidate/types.ts +6 -0
- package/src/server/cache/isr.ts +6 -34
- package/src/server/cache/route-cache.ts +40 -4
- package/src/server/dev/graph.ts +16 -2
- package/src/server/dev-page-plugin.ts +93 -59
- package/src/server/internal.ts +3 -0
- package/src/server/render/document.tsx +10 -1
- package/src/server/render/element.tsx +21 -11
- package/src/server/render/isr.ts +61 -29
- package/src/server/render/loaders.ts +118 -47
- package/src/server/render/mixed-cache.ts +33 -4
- package/src/server/render/not-found.ts +4 -7
- package/src/server/render/ppr-document.ts +2 -1
- package/src/server/render/ppr-route.ts +30 -10
- package/src/server/render/react-stream.ts +17 -0
- package/src/server/render/route-frame-transport.ts +3 -0
- package/src/server/render/ssg.ts +51 -18
- package/src/server/render/ssr.ts +53 -8
- package/src/server/render/template.ts +23 -0
- package/src/server/router/defined-route.ts +3 -0
- package/src/server/router/discovery.ts +25 -9
- package/src/server/router/hmr.ts +3 -2
- package/src/server/router/patterns.ts +16 -0
- package/src/server/router/plugin.ts +27 -12
- package/src/server/router/types.ts +1 -1
- package/src/server/sync/adapter.ts +41 -4
- package/src/server/sync/atomic.ts +303 -0
- package/src/server/sync/drizzle/index.ts +145 -0
- package/src/server/sync/execution-error.ts +1 -0
- package/src/server/sync/fingerprint.ts +2 -6
- package/src/server/sync/index.ts +6 -0
- package/src/server/sync/mutation-handler.ts +69 -0
- package/src/server/sync/plugin.ts +177 -60
- package/src/server/sync/postgres/execute.ts +20 -0
- package/src/server/sync/postgres/index.ts +52 -16
- package/src/server/sync/postgres/sql.ts +20 -0
- package/src/server/sync/prisma/index.ts +70 -0
- package/src/server/sync/queries.ts +75 -0
- package/src/server/sync/query-context.ts +85 -0
- package/src/server/sync/redis/index.ts +7 -3
- package/src/server/sync/redis/scripts.ts +1 -1
- package/src/server/sync/response.ts +21 -0
- package/src/server/sync/sqlite/index.ts +19 -8
- package/src/server/sync/stream.ts +14 -22
- package/src/server/sync/validation.ts +34 -0
- package/src/shared/defer.ts +48 -0
- package/src/shared/error.ts +2 -2
- package/src/shared/page-key.ts +36 -0
- package/src/shared/query-bindings.ts +138 -0
- package/src/shared/route-frame.ts +13 -1
- package/src/shared/route-map.ts +12 -2
- package/src/shared/sync-query.ts +138 -0
|
@@ -11,7 +11,10 @@ export declare class SqliteSyncAdapter implements SyncAdapter {
|
|
|
11
11
|
private readonly namespace;
|
|
12
12
|
constructor(options: SqliteSyncAdapterOptions);
|
|
13
13
|
beginMutation(input: BeginMutationInput): Promise<BeginMutationResult>;
|
|
14
|
+
protected beginMutationSync(input: BeginMutationInput): BeginMutationResult;
|
|
14
15
|
completeMutation(input: CompleteMutationInput): Promise<CompleteMutationResult>;
|
|
16
|
+
protected completeMutationSync(input: CompleteMutationInput): CompleteMutationResult;
|
|
17
|
+
protected hasMutationLeaseSync(lease: MutationLease): boolean;
|
|
15
18
|
abortMutation(lease: MutationLease): Promise<void>;
|
|
16
19
|
currentCursor(): Promise<string>;
|
|
17
20
|
readChanges(input: ReadChangesInput): Promise<ChangePage>;
|
|
@@ -107,6 +107,9 @@ class SqliteSyncAdapter {
|
|
|
107
107
|
this.scope = options.database.filename === "" || options.database.filename === ":memory:" ? "process-local" : "host-local";
|
|
108
108
|
}
|
|
109
109
|
async beginMutation(input) {
|
|
110
|
+
return this.beginMutationSync(input);
|
|
111
|
+
}
|
|
112
|
+
beginMutationSync(input) {
|
|
110
113
|
const transaction = this.database.transaction((mutation) => {
|
|
111
114
|
const now = Date.now();
|
|
112
115
|
const key = mutationKey(mutation);
|
|
@@ -156,13 +159,13 @@ class SqliteSyncAdapter {
|
|
|
156
159
|
return transaction.immediate(input);
|
|
157
160
|
}
|
|
158
161
|
async completeMutation(input) {
|
|
162
|
+
return this.completeMutationSync(input);
|
|
163
|
+
}
|
|
164
|
+
completeMutationSync(input) {
|
|
159
165
|
const transaction = this.database.transaction((completion) => {
|
|
160
166
|
const now = Date.now();
|
|
161
167
|
const key = mutationKey(completion.lease);
|
|
162
|
-
|
|
163
|
-
WHERE namespace = ? AND mutation_key = ? AND mutation_id = ?
|
|
164
|
-
AND state = 'in-progress' AND lease_expires_at > ?`).get(this.namespace, key, completion.lease.id, now);
|
|
165
|
-
if (!active) {
|
|
168
|
+
if (!this.hasMutationLeaseSync(completion.lease)) {
|
|
166
169
|
return { kind: "lost" };
|
|
167
170
|
}
|
|
168
171
|
let cursor;
|
|
@@ -195,6 +198,9 @@ class SqliteSyncAdapter {
|
|
|
195
198
|
});
|
|
196
199
|
return transaction.immediate(input);
|
|
197
200
|
}
|
|
201
|
+
hasMutationLeaseSync(lease) {
|
|
202
|
+
return this.database.query(`SELECT mutation_id FROM furin_sync_mutations WHERE namespace = ? AND mutation_key = ? AND mutation_id = ? AND state = 'in-progress' AND lease_expires_at > ?`).get(this.namespace, mutationKey(lease), lease.id, Date.now()) !== null;
|
|
203
|
+
}
|
|
198
204
|
async abortMutation(lease) {
|
|
199
205
|
this.database.query(`DELETE FROM furin_sync_mutations
|
|
200
206
|
WHERE namespace = ? AND mutation_key = ? AND mutation_id = ? AND state = 'in-progress'`).run(this.namespace, mutationKey(lease), lease.id);
|
|
@@ -6,7 +6,7 @@ export declare function subscribeSyncCursor(options: FurinSyncOptions, listener:
|
|
|
6
6
|
export declare function createSyncChangesPlugin(options: FurinSyncOptions): import("elysia/types").AddRoute<"", "local", import("elysia").DefaultSingleton, {
|
|
7
7
|
typebox: {};
|
|
8
8
|
error: [];
|
|
9
|
-
}, import("elysia").DefaultMetadata, {}, import("elysia").DefaultEphemeral, import("elysia").DefaultEphemeral, "get", `${string}/changes`, import("elysia/types").IntersectIfObjectSchema<import("elysia").UnwrapRoute<{}, {}, `/${string}/changes`>, import("elysia/types").MergeScopedSchemas<{}, {}, {}>>, {}, (
|
|
9
|
+
}, import("elysia").DefaultMetadata, {}, import("elysia").DefaultEphemeral, import("elysia").DefaultEphemeral, "get", `${string}/changes`, import("elysia/types").IntersectIfObjectSchema<import("elysia").UnwrapRoute<{}, {}, `/${string}/changes`>, import("elysia/types").MergeScopedSchemas<{}, {}, {}>>, {}, (context: {
|
|
10
10
|
server: import("elysia").Server | null;
|
|
11
11
|
redirect: import("elysia").redirect;
|
|
12
12
|
set: {
|
|
@@ -31,13 +31,10 @@ export declare function createSyncChangesPlugin(options: FurinSyncOptions): impo
|
|
|
31
31
|
headers: Record<string, string | undefined>;
|
|
32
32
|
cookie: Record<string, import("elysia").Cookie<unknown>>;
|
|
33
33
|
}) => Promise<Response | {
|
|
34
|
+
changes: never[];
|
|
34
35
|
cursor: string;
|
|
35
36
|
hasMore: boolean;
|
|
36
37
|
reset: boolean;
|
|
37
|
-
changes: {
|
|
38
|
-
cursor: string;
|
|
39
|
-
invalidations: string[];
|
|
40
|
-
}[];
|
|
41
38
|
}>>;
|
|
42
39
|
/** @internal — closes process-local stream state between tests. */
|
|
43
40
|
export declare function __resetSyncState(): void;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Context, Elysia } from "elysia";
|
|
2
|
+
/** Bind the final application's models, guards and normalization to native request contexts. */
|
|
3
|
+
export declare function bindSyncValidation(app: Elysia): void;
|
|
4
|
+
export declare function syncValidationApp(context: Context): Elysia;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
declare const DEFERRED_BRAND: unique symbol;
|
|
2
|
+
/**
|
|
3
|
+
* A loader return value that contains a mix of synchronous scalar fields and
|
|
4
|
+
* lazy `Promise<T>` fields. Scalar fields are serialised into the initial HTML
|
|
5
|
+
* shell; Promise fields are streamed as late `<script>` resolution chunks.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* loader: () => defer({
|
|
9
|
+
* title: "My Board", // synchronous — available immediately
|
|
10
|
+
* stats: fetchStats(), // Promise — streamed when it resolves
|
|
11
|
+
* })
|
|
12
|
+
*/
|
|
13
|
+
export type DeferredData<T extends object> = T & {
|
|
14
|
+
readonly [DEFERRED_BRAND]: true;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Wraps loader data so that Promise-valued fields are streamed lazily while
|
|
18
|
+
* scalar fields are embedded in the initial HTML shell immediately.
|
|
19
|
+
*
|
|
20
|
+
* Use in any `defineRoute().loader()`. Promise-valued fields are streamed lazily;
|
|
21
|
+
* scalar fields are embedded in the initial HTML shell.
|
|
22
|
+
*/
|
|
23
|
+
export declare function defer<T extends object>(data: T & {
|
|
24
|
+
readonly [DEFERRED_BRAND]?: never;
|
|
25
|
+
}): DeferredData<T>;
|
|
26
|
+
/**
|
|
27
|
+
* Type guard for DeferredData. Used by the render pipeline to distinguish a
|
|
28
|
+
* plain loader return from a deferred one.
|
|
29
|
+
*/
|
|
30
|
+
export declare function isDeferred(value: unknown): value is DeferredData<object>;
|
|
31
|
+
export {};
|
package/dist/shared/error.d.ts
CHANGED
|
@@ -12,9 +12,9 @@ export interface ErrorProps {
|
|
|
12
12
|
digest: string;
|
|
13
13
|
/**
|
|
14
14
|
* HTTP status associated with the error.
|
|
15
|
-
* - For thrown `Response` objects
|
|
15
|
+
* - For thrown `Response` objects and Eden problem errors: their HTTP
|
|
16
16
|
* status (e.g. 401, 403, 404, 500).
|
|
17
|
-
* - For
|
|
17
|
+
* - For other errors (thrown `Error`, non-Error throws, shell-render
|
|
18
18
|
* crashes): always `500`.
|
|
19
19
|
*
|
|
20
20
|
* Always present so consumers never need a `?? 500` fallback. Note that
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type RemountDependency = string | number | boolean | null | undefined;
|
|
2
|
+
export type RemountDeps<Params, Query> = (context: {
|
|
3
|
+
readonly params: Params;
|
|
4
|
+
readonly query: Query;
|
|
5
|
+
}) => readonly RemountDependency[];
|
|
6
|
+
/** Shared by SSR and navigation; loader data never participates in page identity. */
|
|
7
|
+
export declare function pageKey(pattern: string, data: object, remountDeps: RemountDeps<object, object> | undefined): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { QuerySeed } from "./sync-query.ts";
|
|
2
|
+
export interface DeferredQueryValue {
|
|
3
|
+
projection?: {
|
|
4
|
+
value: unknown;
|
|
5
|
+
promise: Promise<unknown>;
|
|
6
|
+
};
|
|
7
|
+
value: unknown;
|
|
8
|
+
}
|
|
9
|
+
/** Track returned objects by reference; computed scalars have no reliable provenance. */
|
|
10
|
+
export declare function bindQueryData(data: object, seeds: readonly QuerySeed[]): QuerySeed[];
|
|
11
|
+
export declare function projectQueryData<Data extends object>(data: Data, seeds: readonly QuerySeed[], read: (seed: QuerySeed) => unknown): Data;
|
|
12
|
+
export declare function projectDeferredQueryData<Data extends object>(data: Data, seeds: readonly QuerySeed[], read: (seed: QuerySeed) => unknown, resolved: WeakMap<Promise<unknown>, DeferredQueryValue>): Data;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface QueryScope {
|
|
2
|
+
readonly [key: string]: string | number | boolean | null | undefined;
|
|
3
|
+
}
|
|
4
|
+
export interface QueryIdentity {
|
|
5
|
+
id: string;
|
|
6
|
+
scope: QueryScope;
|
|
7
|
+
}
|
|
8
|
+
type RegisteredScope<Id extends keyof SyncQueryMap> = keyof SyncQueryMap[Id] extends never ? {
|
|
9
|
+
readonly [key: string]: never;
|
|
10
|
+
} : {
|
|
11
|
+
readonly [Key in keyof SyncQueryMap[Id]]: Extract<SyncQueryMap[Id][Key], QueryScope[string]>;
|
|
12
|
+
};
|
|
13
|
+
export type SyncQueryIdentity = keyof SyncQueryMap extends never ? QueryIdentity : {
|
|
14
|
+
[Id in keyof SyncQueryMap & string]: {
|
|
15
|
+
id: Id;
|
|
16
|
+
scope: RegisteredScope<Id>;
|
|
17
|
+
};
|
|
18
|
+
}[keyof SyncQueryMap & string];
|
|
19
|
+
export interface QueryReadIdentity extends QueryIdentity {
|
|
20
|
+
session: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function serializeQueryHeader(identity: QueryIdentity | readonly QueryIdentity[]): string;
|
|
23
|
+
export interface QuerySeed {
|
|
24
|
+
bindings?: QueryBinding[];
|
|
25
|
+
data: unknown;
|
|
26
|
+
identity: QueryReadIdentity;
|
|
27
|
+
local?: boolean;
|
|
28
|
+
url: string;
|
|
29
|
+
}
|
|
30
|
+
export interface QueryBinding {
|
|
31
|
+
source: string[];
|
|
32
|
+
target: string[];
|
|
33
|
+
}
|
|
34
|
+
export declare function mergeQuerySeeds(target: QuerySeed[], incoming: readonly QuerySeed[]): void;
|
|
35
|
+
export declare function queryTagsFromData(data: object): string[];
|
|
36
|
+
export declare function queryTag(identity: QueryIdentity): string;
|
|
37
|
+
export declare function queryFromTag(tag: string): QueryIdentity | undefined;
|
|
38
|
+
export declare function queryUrl(url: string, origin: string | undefined): string;
|
|
39
|
+
import type { SyncQueryMap } from "@teyik0/furin/routes";
|
|
40
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teyik0/furin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0-alpha.2",
|
|
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",
|
|
@@ -127,6 +127,16 @@
|
|
|
127
127
|
"types": "./dist/client-only.d.ts",
|
|
128
128
|
"bun": "./src/client-only.ts",
|
|
129
129
|
"import": "./dist/client-only.js"
|
|
130
|
+
},
|
|
131
|
+
"./sync/drizzle": {
|
|
132
|
+
"types": "./dist/server/sync/drizzle/index.d.ts",
|
|
133
|
+
"bun": "./src/server/sync/drizzle/index.ts",
|
|
134
|
+
"import": "./dist/server/sync/drizzle/index.js"
|
|
135
|
+
},
|
|
136
|
+
"./sync/prisma": {
|
|
137
|
+
"types": "./dist/server/sync/prisma/index.d.ts",
|
|
138
|
+
"bun": "./src/server/sync/prisma/index.ts",
|
|
139
|
+
"import": "./dist/server/sync/prisma/index.js"
|
|
130
140
|
}
|
|
131
141
|
},
|
|
132
142
|
"main": "./dist/furin.js",
|
|
@@ -147,13 +157,15 @@
|
|
|
147
157
|
"benchmark:rsc": "bun scripts/benchmark-rsc-transport.ts",
|
|
148
158
|
"build": "bun run build.ts",
|
|
149
159
|
"fix": "ultracite fix",
|
|
150
|
-
"
|
|
151
|
-
"test
|
|
160
|
+
"generate:sync-prisma": "bun --bun node_modules/prisma/build/index.js generate --schema tests/fixtures/sync-prisma/schema.prisma",
|
|
161
|
+
"test": "bun run generate:sync-prisma && bun test --parallel=2 --isolate --max-concurrency 4 --bail --timeout 15000",
|
|
162
|
+
"test:dev": "bun run generate:sync-prisma && bun test --changed --parallel --isolate --max-concurrency 4 --bail --timeout 15000",
|
|
152
163
|
"test:hmr:soak": "FURIN_WEBVIEW_TESTS=1 FURIN_HMR_SOAK_TESTS=1 bun test tests/browser/hmr-conformance.webview.test.ts -t 'tracks memory' --timeout 3600000",
|
|
153
164
|
"test:webview": "FURIN_WEBVIEW_TESTS=1 bun test tests/browser/hmr-conformance.webview.test.ts --timeout 60000",
|
|
154
|
-
"tscheck": "tsc --noEmit"
|
|
165
|
+
"tscheck": "bun run generate:sync-prisma && tsc --noEmit"
|
|
155
166
|
},
|
|
156
167
|
"dependencies": {
|
|
168
|
+
"@elysia/eden": "^2.0.0-beta.5",
|
|
157
169
|
"@elysia/static": "2.0.0-beta.2",
|
|
158
170
|
"@jridgewell/trace-mapping": "^0.3.31",
|
|
159
171
|
"@vercel/functions": "^3.9.9",
|
|
@@ -167,17 +179,28 @@
|
|
|
167
179
|
"yuku-parser": "0.12.0"
|
|
168
180
|
},
|
|
169
181
|
"devDependencies": {
|
|
182
|
+
"@prisma/adapter-pg": "7.10.0",
|
|
183
|
+
"@prisma/client": "7.10.0",
|
|
184
|
+
"@prisma/client-runtime-utils": "7.10.0",
|
|
170
185
|
"@types/react": "^19.3.0",
|
|
171
186
|
"@types/react-dom": "^19.3.0",
|
|
172
|
-
"
|
|
187
|
+
"drizzle-orm": "0.45.3",
|
|
188
|
+
"expect-type": "^1.4.0",
|
|
189
|
+
"prisma": "7.10.0"
|
|
173
190
|
},
|
|
174
191
|
"peerDependencies": {
|
|
175
|
-
"
|
|
192
|
+
"drizzle-orm": "^0.45.3",
|
|
193
|
+
"elysia": "2.0.0-beta.21",
|
|
176
194
|
"evlog": "^2.29.0",
|
|
177
195
|
"react": "19.3.0",
|
|
178
196
|
"react-dom": "19.3.0",
|
|
179
197
|
"typebox": "1.3.34"
|
|
180
198
|
},
|
|
199
|
+
"peerDependenciesMeta": {
|
|
200
|
+
"drizzle-orm": {
|
|
201
|
+
"optional": true
|
|
202
|
+
}
|
|
203
|
+
},
|
|
181
204
|
"engines": {
|
|
182
205
|
"bun": ">=1.4.0"
|
|
183
206
|
}
|
package/src/adapter/package.ts
CHANGED
|
@@ -13,9 +13,14 @@ import {
|
|
|
13
13
|
createRoutesPlugin,
|
|
14
14
|
routeSourcePaths,
|
|
15
15
|
} from "../plugin/routes.ts";
|
|
16
|
+
import { isomorphicTransformPlugin } from "../plugin/transform-isomorphic.ts";
|
|
17
|
+
import { environmentGuardPlugin } from "../rsc/build/environment.ts";
|
|
16
18
|
import { ssgRouteCache } from "../server/cache/ssg.ts";
|
|
17
19
|
import { generateProdIndexHtml } from "../server/render/shell.ts";
|
|
18
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
setProductionPreloadManifest,
|
|
22
|
+
setProductionTemplateContent,
|
|
23
|
+
} from "../server/render/template.ts";
|
|
19
24
|
|
|
20
25
|
/**
|
|
21
26
|
* `--target package` — builds a furin app as a PUBLISHABLE Elysia plugin
|
|
@@ -53,7 +58,7 @@ export async function buildPackageTarget(
|
|
|
53
58
|
rmSync(targetDir, { force: true, recursive: true });
|
|
54
59
|
ensureDir(targetDir);
|
|
55
60
|
|
|
56
|
-
const { entryChunk, cssChunks } = await buildClient(routes, {
|
|
61
|
+
const { entryChunk, cssChunks, preloadManifest } = await buildClient(routes, {
|
|
57
62
|
basePath: prefix,
|
|
58
63
|
clientLogging: options.clientLogging ?? false,
|
|
59
64
|
metafilePath: options.analyze ? join(buildRoot, "analysis", "package-client.json") : undefined,
|
|
@@ -61,6 +66,7 @@ export async function buildPackageTarget(
|
|
|
61
66
|
outDir: targetDir,
|
|
62
67
|
pagesDir,
|
|
63
68
|
plugins: options.plugins,
|
|
69
|
+
preloadRouteChunks: options.preload?.routeChunks,
|
|
64
70
|
publicPath: `${prefix}/_client/`,
|
|
65
71
|
reactCompiler: options.reactCompiler,
|
|
66
72
|
rootLayout: root.path,
|
|
@@ -97,6 +103,7 @@ export async function buildPackageTarget(
|
|
|
97
103
|
// SSG snapshot renders through the build-time default state bucket. The
|
|
98
104
|
// mount prefix is passed explicitly — no instance scope exists at build time.
|
|
99
105
|
setProductionTemplateContent(indexHtml);
|
|
106
|
+
setProductionPreloadManifest(preloadManifest);
|
|
100
107
|
ssgRouteCache().clear();
|
|
101
108
|
const ssgCache = await buildSSGCacheSnapshot(routes, root, "http://localhost", prefix);
|
|
102
109
|
|
|
@@ -142,6 +149,7 @@ export async function buildPackageTarget(
|
|
|
142
149
|
modulePaths,
|
|
143
150
|
nativeRoutes: composableRouteModuleSpecifier(app),
|
|
144
151
|
prefix,
|
|
152
|
+
preloadManifest,
|
|
145
153
|
rootConventions,
|
|
146
154
|
rootPath: root.path,
|
|
147
155
|
routeMetadata,
|
|
@@ -169,6 +177,8 @@ export async function buildPackageTarget(
|
|
|
169
177
|
register.plugin,
|
|
170
178
|
...(options.plugins ?? []),
|
|
171
179
|
createRoutesPlugin({ instances: [app], target: "server" }),
|
|
180
|
+
isomorphicTransformPlugin("server"),
|
|
181
|
+
environmentGuardPlugin("ssr"),
|
|
172
182
|
],
|
|
173
183
|
sourcemap: "none",
|
|
174
184
|
target: "bun",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { existsSync, writeFileSync } from "node:fs";
|
|
1
|
+
import { existsSync, realpathSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { buildClient } from "../build/client.ts";
|
|
@@ -16,7 +16,10 @@ import { buildRscGraph } from "../rsc/build/index.ts";
|
|
|
16
16
|
import { ssgRouteCache } from "../server/cache/ssg.ts";
|
|
17
17
|
import { hasMixedLoaderModes, hasRequestLoader } from "../server/render/loaders.ts";
|
|
18
18
|
import { generateProdIndexHtml } from "../server/render/shell.ts";
|
|
19
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
setProductionPreloadManifest,
|
|
21
|
+
setProductionTemplateContent,
|
|
22
|
+
} from "../server/render/template.ts";
|
|
20
23
|
import { resolveDocumentMode } from "../server/router/patterns.ts";
|
|
21
24
|
import type { ResolvedRoute, RootLayout } from "../server/router/types.ts";
|
|
22
25
|
import { clientDirNameForPrefix } from "../shared/prefix.ts";
|
|
@@ -40,6 +43,7 @@ const MIXED_CACHE_IMPORT_RE = /mixed-cache(?:\.ts)?$/;
|
|
|
40
43
|
const ANY_MODULE_RE = /.*/;
|
|
41
44
|
const REACT_SERVER_IMPORT_RE = /^react-dom\/server(?:\.edge)?$/;
|
|
42
45
|
const REACT_STATIC_IMPORT_RE = /^react-dom\/static\.edge$/;
|
|
46
|
+
const SCRIPT_FILE_RE = /\.[cm]?[jt]sx?$/;
|
|
43
47
|
const BUILD_ID_INPUT_PATHS = [
|
|
44
48
|
`${_pkgSrcDir}/build/compile-entry${_ext}`,
|
|
45
49
|
`${_pkgSrcDir}/build/entry-template${_ext}`,
|
|
@@ -75,7 +79,7 @@ function compareCodeUnits(a: string, b: string): number {
|
|
|
75
79
|
/**
|
|
76
80
|
* Deterministic build-ID input covering everything that can change rendered
|
|
77
81
|
* output: client chunks, route shape, route/root/error/not-found source
|
|
78
|
-
* contents and the framework's own render pipeline sources.
|
|
82
|
+
* contents, their application dependencies and the framework's own render pipeline sources.
|
|
79
83
|
*/
|
|
80
84
|
export async function createBuildFingerprint(
|
|
81
85
|
entryChunk: string,
|
|
@@ -110,6 +114,47 @@ export async function createBuildFingerprint(
|
|
|
110
114
|
}
|
|
111
115
|
}
|
|
112
116
|
}
|
|
117
|
+
const sources = new Map<string, string>();
|
|
118
|
+
const visit = async (inputPath: string): Promise<void> => {
|
|
119
|
+
const path = existsSync(inputPath) ? realpathSync(inputPath) : inputPath;
|
|
120
|
+
fingerprintPaths.delete(inputPath);
|
|
121
|
+
fingerprintPaths.add(path);
|
|
122
|
+
if (sources.has(path)) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
sources.set(path, "");
|
|
126
|
+
const content = existsSync(path) ? await Bun.file(path).text() : "";
|
|
127
|
+
sources.set(path, content);
|
|
128
|
+
if (!SCRIPT_FILE_RE.test(path)) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const transpiler = new Bun.Transpiler({ loader: path.endsWith("x") ? "tsx" : "ts" });
|
|
132
|
+
await Promise.all(
|
|
133
|
+
transpiler.scanImports(content).flatMap(({ path: specifier }) => {
|
|
134
|
+
if (
|
|
135
|
+
specifier === "furin" ||
|
|
136
|
+
specifier.startsWith("furin/") ||
|
|
137
|
+
specifier === "@teyik0/furin" ||
|
|
138
|
+
specifier.startsWith("@teyik0/furin/")
|
|
139
|
+
) {
|
|
140
|
+
return [];
|
|
141
|
+
}
|
|
142
|
+
let dependency: string;
|
|
143
|
+
try {
|
|
144
|
+
dependency = Bun.resolveSync(specifier, dirname(path));
|
|
145
|
+
} catch {
|
|
146
|
+
// Build plugins can supply imports that have no filesystem path.
|
|
147
|
+
return [];
|
|
148
|
+
}
|
|
149
|
+
if (!isAbsolute(dependency) || toPosixPath(dependency).includes("/node_modules/")) {
|
|
150
|
+
return [];
|
|
151
|
+
}
|
|
152
|
+
fingerprintPaths.add(dependency);
|
|
153
|
+
return [visit(dependency)];
|
|
154
|
+
})
|
|
155
|
+
);
|
|
156
|
+
};
|
|
157
|
+
await Promise.all([...fingerprintPaths].map(visit));
|
|
113
158
|
for (const path of BUILD_ID_INPUT_PATHS) {
|
|
114
159
|
if (!existsSync(path)) {
|
|
115
160
|
console.warn(
|
|
@@ -120,12 +165,14 @@ export async function createBuildFingerprint(
|
|
|
120
165
|
fingerprintPaths.add(path);
|
|
121
166
|
}
|
|
122
167
|
|
|
123
|
-
const fileParts =
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
168
|
+
const fileParts = (
|
|
169
|
+
await Promise.all(
|
|
170
|
+
[...fingerprintPaths].map(async (path) => {
|
|
171
|
+
const content = sources.get(path) ?? (existsSync(path) ? await Bun.file(path).text() : "");
|
|
172
|
+
return `${stableFingerprintPath(path, projectRoot)}:${content}`;
|
|
173
|
+
})
|
|
174
|
+
)
|
|
175
|
+
).sort(compareCodeUnits);
|
|
129
176
|
|
|
130
177
|
const routeParts = routes
|
|
131
178
|
.map((route) =>
|
|
@@ -143,7 +190,8 @@ export async function createBuildFingerprint(
|
|
|
143
190
|
}
|
|
144
191
|
|
|
145
192
|
function stableFingerprintPath(path: string, projectRoot: string): string {
|
|
146
|
-
const
|
|
193
|
+
const absolutePath = existsSync(path) ? realpathSync(path) : path;
|
|
194
|
+
const projectPath = relative(realpathSync(projectRoot), absolutePath);
|
|
147
195
|
if (
|
|
148
196
|
!isAbsolute(projectPath) &&
|
|
149
197
|
projectPath !== ".." &&
|
|
@@ -152,7 +200,7 @@ function stableFingerprintPath(path: string, projectRoot: string): string {
|
|
|
152
200
|
) {
|
|
153
201
|
return `app/${toPosixPath(projectPath)}`;
|
|
154
202
|
}
|
|
155
|
-
const frameworkPath = relative(_pkgRoot,
|
|
203
|
+
const frameworkPath = relative(_pkgRoot, absolutePath);
|
|
156
204
|
if (
|
|
157
205
|
!isAbsolute(frameworkPath) &&
|
|
158
206
|
frameworkPath !== ".." &&
|
|
@@ -304,7 +352,7 @@ export async function buildRuntimeApp(
|
|
|
304
352
|
const clientDirName = clientDirNameForPrefix(prefix);
|
|
305
353
|
const label = prefix === "" ? "root app" : `app "${prefix}"`;
|
|
306
354
|
|
|
307
|
-
const { entryChunk, cssChunks } = await buildClient(routes, {
|
|
355
|
+
const { entryChunk, cssChunks, preloadManifest } = await buildClient(routes, {
|
|
308
356
|
basePath: prefix,
|
|
309
357
|
clientDirName,
|
|
310
358
|
clientLogging: options.clientLogging ?? false,
|
|
@@ -315,6 +363,7 @@ export async function buildRuntimeApp(
|
|
|
315
363
|
outDir: targetDir,
|
|
316
364
|
pagesDir: app.pagesDir,
|
|
317
365
|
plugins: options.plugins,
|
|
366
|
+
preloadRouteChunks: options.preload?.routeChunks,
|
|
318
367
|
publicPath: `${prefix}/_client/`,
|
|
319
368
|
reactCompiler: options.reactCompiler,
|
|
320
369
|
rootLayout: root.path,
|
|
@@ -336,6 +385,7 @@ export async function buildRuntimeApp(
|
|
|
336
385
|
writeFileSync(join(clientDir, "index.html"), indexHtml);
|
|
337
386
|
|
|
338
387
|
setProductionTemplateContent(indexHtml);
|
|
388
|
+
setProductionPreloadManifest(preloadManifest);
|
|
339
389
|
ssgRouteCache().clear();
|
|
340
390
|
let ssgCache: SSGCacheSnapshot | undefined;
|
|
341
391
|
let prerenders: RoutePrerender[] = [];
|
|
@@ -361,6 +411,7 @@ export async function buildRuntimeApp(
|
|
|
361
411
|
modulePaths,
|
|
362
412
|
nativeRoutes: composableRouteModuleSpecifier(app),
|
|
363
413
|
prefix,
|
|
414
|
+
preloadManifest,
|
|
364
415
|
rootConventions,
|
|
365
416
|
rootPath: root.path,
|
|
366
417
|
routeMetadata,
|
package/src/adapter/static.ts
CHANGED
|
@@ -11,7 +11,10 @@ import { resolvePath } from "../server/render/assemble.ts";
|
|
|
11
11
|
import { generateProdIndexHtml } from "../server/render/shell.ts";
|
|
12
12
|
import { prerenderSSG } from "../server/render/ssg.ts";
|
|
13
13
|
import { hasStaticParams, resolveStaticParams } from "../server/render/static-params.ts";
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
setProductionPreloadManifest,
|
|
16
|
+
setProductionTemplateContent,
|
|
17
|
+
} from "../server/render/template.ts";
|
|
15
18
|
import { resolveDocumentMode } from "../server/router/patterns.ts";
|
|
16
19
|
import { createSearchRouteMetadata } from "../server/router/schemas.ts";
|
|
17
20
|
import type { ResolvedRoute, RootLayout } from "../server/router/types.ts";
|
|
@@ -467,7 +470,7 @@ export async function buildStaticTarget(
|
|
|
467
470
|
ensureDir(targetDir);
|
|
468
471
|
|
|
469
472
|
// ── 4. Build client bundle ────────────────────────────────────────────────
|
|
470
|
-
const { entryChunk, cssChunks } = await buildClient(ssgRoutes, {
|
|
473
|
+
const { entryChunk, cssChunks, preloadManifest } = await buildClient(ssgRoutes, {
|
|
471
474
|
basePath,
|
|
472
475
|
clientLogging: Boolean(options.clientLogging),
|
|
473
476
|
metafilePath: options.analyze ? join(buildRoot, "analysis", "static-client.json") : undefined,
|
|
@@ -475,6 +478,7 @@ export async function buildStaticTarget(
|
|
|
475
478
|
outDir: targetDir,
|
|
476
479
|
pagesDir: dirname(root.path),
|
|
477
480
|
plugins: options.plugins,
|
|
481
|
+
preloadRouteChunks: options.preload?.routeChunks,
|
|
478
482
|
publicPath,
|
|
479
483
|
reactCompiler: options.reactCompiler,
|
|
480
484
|
rootLayout: root.path,
|
|
@@ -492,6 +496,7 @@ export async function buildStaticTarget(
|
|
|
492
496
|
// prepareRender() checks getProductionTemplate() first (before IS_DEV), so
|
|
493
497
|
// setting the content here is sufficient — no need to flip IS_DEV globally.
|
|
494
498
|
setProductionTemplateContent(shellHtml);
|
|
499
|
+
setProductionPreloadManifest(preloadManifest);
|
|
495
500
|
|
|
496
501
|
// ── 7. Copy public/ → outDir/ ─────────────────────────────────────────────
|
|
497
502
|
const publicSrcDir = join(rootDir, "public");
|
package/src/adapter/vercel.ts
CHANGED
|
@@ -744,19 +744,21 @@ export async function buildVercelTarget(
|
|
|
744
744
|
}
|
|
745
745
|
|
|
746
746
|
const pprResumeKey = crypto.randomUUID();
|
|
747
|
-
const prerenderSpecs = await
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
747
|
+
const [prerenderSpecs, appEntry] = await Promise.all([
|
|
748
|
+
createPrerenderSpecs(apps, builds, functionsDir, pprResumeKey),
|
|
749
|
+
materializeServerAppEntry({
|
|
750
|
+
apps: builds.map(({ entryApp, indexHtml }) => ({
|
|
751
|
+
...entryApp,
|
|
752
|
+
embed: undefined,
|
|
753
|
+
serveAssets: false,
|
|
754
|
+
templateHtml: indexHtml,
|
|
755
|
+
})),
|
|
756
|
+
headerComment: "// Auto-generated by `furin build --target vercel` — do not edit",
|
|
757
|
+
instances: apps,
|
|
758
|
+
outDir: serverFunctionDir,
|
|
759
|
+
serverEntry,
|
|
760
|
+
}),
|
|
761
|
+
]);
|
|
760
762
|
const entryPath = join(serverFunctionDir, "_vercel-handler.ts");
|
|
761
763
|
const entry = createVirtualBuildEntry(
|
|
762
764
|
entryPath,
|
package/src/build/client.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { detectLoaderFromPath } from "../server/lang-detect.ts";
|
|
|
7
7
|
import type { ResolvedRoute } from "../server/router/types.ts";
|
|
8
8
|
import { runBunBuild } from "./bun-build.ts";
|
|
9
9
|
import { generateHydrateEntry } from "./hydrate";
|
|
10
|
+
import { type ClientPreloadManifest, writeClientPreloadManifest } from "./preload-manifest.ts";
|
|
10
11
|
import { CLIENT_MODULE_PATH, LINK_MODULE_PATH, SEARCH_MODULE_PATH } from "./shared";
|
|
11
12
|
import type { BuildClientOptions, BunBuildAliasConfig } from "./types";
|
|
12
13
|
import { createVirtualBuildEntry } from "./virtual-entry.ts";
|
|
@@ -29,6 +30,8 @@ export interface BuildClientResult {
|
|
|
29
30
|
cssChunks: string[];
|
|
30
31
|
/** Public path of the JS entry chunk, e.g. `/_client/chunk-abc.js` */
|
|
31
32
|
entryChunk: string;
|
|
33
|
+
/** Chunk URLs to modulepreload per route and per `clientModule()`. */
|
|
34
|
+
preloadManifest: ClientPreloadManifest;
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
/**
|
|
@@ -53,6 +56,7 @@ export async function buildClient(
|
|
|
53
56
|
outDir,
|
|
54
57
|
rootLayout,
|
|
55
58
|
plugins,
|
|
59
|
+
preloadRouteChunks,
|
|
56
60
|
publicPath,
|
|
57
61
|
basePath,
|
|
58
62
|
clientLogging,
|
|
@@ -134,6 +138,7 @@ export async function buildClient(
|
|
|
134
138
|
files: hydrateEntry.files,
|
|
135
139
|
outdir: clientDir,
|
|
136
140
|
target: "browser",
|
|
141
|
+
env: "FURIN_PUBLIC_*",
|
|
137
142
|
format: "esm",
|
|
138
143
|
splitting: true,
|
|
139
144
|
optimizeImports,
|
|
@@ -141,7 +146,8 @@ export async function buildClient(
|
|
|
141
146
|
reactCompilerOutputMode: "client",
|
|
142
147
|
minify: true,
|
|
143
148
|
sourcemap: "none",
|
|
144
|
-
|
|
149
|
+
// Always on: the preload manifest is derived from the chunk graph.
|
|
150
|
+
metafile: true,
|
|
145
151
|
// Hash the entry point name so it gets immutable caching like chunks.
|
|
146
152
|
// Without this, _hydrate.js keeps the same name across builds and browsers
|
|
147
153
|
// serve stale versions that reference old chunk hashes → dynamic import 404.
|
|
@@ -170,15 +176,20 @@ export async function buildClient(
|
|
|
170
176
|
"@teyik0/furin/search": SEARCH_MODULE_PATH,
|
|
171
177
|
},
|
|
172
178
|
define: {
|
|
179
|
+
...Object.fromEntries(
|
|
180
|
+
Object.entries(process.env)
|
|
181
|
+
.filter(([name, value]) => name.startsWith("FURIN_PUBLIC_") && value !== undefined)
|
|
182
|
+
.map(([name, value]) => [`process.env.${name}`, JSON.stringify(value)])
|
|
183
|
+
),
|
|
173
184
|
"process.env.NODE_ENV": JSON.stringify("production"),
|
|
174
185
|
},
|
|
175
186
|
};
|
|
176
187
|
|
|
177
188
|
const result = await runBunBuild(clientBuildConfig);
|
|
189
|
+
if (result.metafile === undefined) {
|
|
190
|
+
throw new Error("[furin] client build did not produce the requested metafile");
|
|
191
|
+
}
|
|
178
192
|
if (metafilePath !== undefined) {
|
|
179
|
-
if (result.metafile === undefined) {
|
|
180
|
-
throw new Error("[furin] client build did not produce the requested metafile");
|
|
181
|
-
}
|
|
182
193
|
mkdirSync(dirname(metafilePath), { recursive: true });
|
|
183
194
|
writeFileSync(metafilePath, `${JSON.stringify(result.metafile, null, 2)}\n`);
|
|
184
195
|
console.log(`[furin] Client metafile: ${metafilePath}`);
|
|
@@ -209,7 +220,14 @@ export async function buildClient(
|
|
|
209
220
|
}
|
|
210
221
|
const entryChunk = `${publicPrefix}${basename(entryOutput.path)}`;
|
|
211
222
|
const cssChunks = cssOutputs.map((o) => `${publicPrefix}${basename(o.path)}`);
|
|
223
|
+
const preloadManifest = writeClientPreloadManifest(
|
|
224
|
+
result.metafile,
|
|
225
|
+
result.outputs.map((output) => output.path),
|
|
226
|
+
entryOutput.path,
|
|
227
|
+
preloadRouteChunks === false ? [] : routes,
|
|
228
|
+
publicPrefix
|
|
229
|
+
);
|
|
212
230
|
|
|
213
231
|
console.log("[furin] Production client build complete");
|
|
214
|
-
return { entryChunk, cssChunks };
|
|
232
|
+
return { entryChunk, cssChunks, preloadManifest };
|
|
215
233
|
}
|