@teyik0/furin 0.4.0-alpha.1 → 0.5.0-alpha.1
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 +6 -4
- package/dist/build/compile-entry.ts +36 -77
- package/dist/build/elysia-aot.d.ts +9 -0
- package/dist/build/entry-template.d.ts +9 -3
- package/dist/build/entry-template.ts +55 -13
- package/dist/build/index.d.ts +1 -1
- package/dist/build/index.js +8912 -6391
- package/dist/build/server-app-entry.d.ts +12 -0
- 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 +6 -0
- package/dist/cache.js +282 -0
- package/dist/cli/index.js +8936 -6308
- 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/internal/runtime-types.d.ts +8 -1
- package/dist/client/link.js +465 -86
- 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/sync.d.ts +1 -0
- package/dist/client.js +37 -23
- package/dist/config.d.ts +35 -17
- package/dist/config.js +10 -2
- package/dist/define-route.d.ts +282 -1015
- package/dist/devtools/protocol.d.ts +2 -2
- package/dist/furin.d.ts +21 -6
- package/dist/furin.js +12823 -8484
- package/dist/plugin/index.js +476 -7
- package/dist/plugin/routes.d.ts +10 -3
- package/dist/rsc/build/index.d.ts +5 -1
- package/dist/server/assets/production.d.ts +3 -0
- package/dist/server/auto-invalidate/plugin.d.ts +8 -24
- package/dist/server/auto-invalidate/runtime.d.ts +2 -2
- 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 +2 -3
- package/dist/server/cache/isr.d.ts +1 -0
- package/dist/server/cache/page-cache-state.d.ts +5 -0
- package/dist/server/cache/page-cache.d.ts +53 -0
- package/dist/server/cache/purger.d.ts +7 -0
- package/dist/server/cache/redis/index.d.ts +39 -0
- package/dist/server/cache/redis/index.js +396 -0
- package/dist/server/cache/redis/scripts.d.ts +6 -0
- package/dist/server/cache/runtime-cache.d.ts +21 -0
- package/dist/server/context-logger.d.ts +2 -2
- 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 +6 -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.d.ts +7 -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/evlog.d.ts +14 -0
- package/dist/server/external-prerender.d.ts +2 -0
- package/dist/server/instance.d.ts +2 -2
- package/dist/server/internal.d.ts +20 -2
- package/dist/server/internal.js +2973 -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/not-found.d.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 +7 -0
- package/dist/server/render/ssr.d.ts +17 -6
- package/dist/server/render/static-params.d.ts +4 -0
- package/dist/server/router/defined-route.d.ts +1 -1
- 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/router/schemas.d.ts +1 -0
- 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 +1252 -599
- package/dist/server/sync/notifier.d.ts +1 -0
- package/dist/server/sync/plugin.d.ts +31 -158
- 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 +37 -61
- 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/elysia-contract.d.ts +8 -14
- package/dist/shared/prefix.d.ts +2 -0
- package/package.json +26 -11
- package/src/adapter/README.md +53 -1
- package/src/adapter/bun.ts +106 -283
- package/src/adapter/package.ts +21 -11
- package/src/adapter/runtime-build.ts +382 -0
- package/src/adapter/static.ts +87 -8
- package/src/adapter/vercel.ts +876 -0
- package/src/build/client.ts +55 -13
- package/src/build/compile-entry.ts +36 -77
- package/src/build/elysia-aot.ts +102 -0
- package/src/build/entry-template.ts +55 -13
- package/src/build/hydrate.ts +60 -20
- package/src/build/index.ts +17 -8
- package/src/build/production-instrumentation.ts +56 -4
- package/src/build/server-app-entry.ts +60 -0
- package/src/build/shared.ts +5 -2
- package/src/build/ssg-cache.ts +93 -12
- package/src/build/types.ts +31 -2
- package/src/build/virtual-entry.ts +28 -0
- package/src/cache.ts +26 -0
- package/src/cli/config.ts +3 -3
- package/src/cli/index.ts +58 -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/internal/runtime-types.ts +10 -1
- 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/client/sync.ts +1 -0
- package/src/config.ts +28 -2
- package/src/define-route.ts +285 -134
- package/src/devtools/devtools-element.js +56 -77
- package/src/devtools/protocol.ts +2 -2
- package/src/furin.ts +272 -203
- package/src/plugin/route-config-autofix.ts +11 -2
- package/src/plugin/routes.ts +291 -65
- 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/assets/production.ts +99 -0
- package/src/server/auto-invalidate/plugin.ts +4 -4
- package/src/server/auto-invalidate/runtime.ts +76 -41
- package/src/server/browser-events/plugin.ts +173 -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 +67 -35
- package/src/server/cache/isr.ts +9 -0
- package/src/server/cache/page-cache-state.ts +22 -0
- package/src/server/cache/page-cache.ts +300 -0
- package/src/server/cache/purger.ts +41 -0
- package/src/server/cache/redis/index.ts +350 -0
- package/src/server/cache/redis/scripts.ts +160 -0
- package/src/server/cache/runtime-cache.ts +137 -0
- package/src/server/context-logger.ts +5 -5
- 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 +28 -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 +136 -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/evlog.ts +99 -0
- package/src/server/external-prerender.ts +10 -0
- package/src/server/instance.ts +3 -3
- package/src/server/internal.ts +46 -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 +509 -136
- package/src/server/render/loaders.ts +31 -15
- package/src/server/render/not-found.ts +32 -8
- 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 +335 -28
- package/src/server/render/shell.ts +0 -12
- package/src/server/render/ssg.ts +186 -24
- package/src/server/render/ssr.ts +215 -89
- package/src/server/render/static-params.ts +174 -0
- package/src/server/render/template.ts +47 -11
- package/src/server/router/defined-route.ts +9 -40
- package/src/server/router/hmr.production.ts +7 -0
- package/src/server/router/hmr.ts +108 -67
- package/src/server/router/patterns.ts +5 -1
- package/src/server/router/plugin.ts +164 -66
- package/src/server/router/schema-merge.ts +1 -1
- package/src/server/router/schemas.ts +174 -61
- 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 +18 -11
- package/src/server/sync/postgres/index.ts +111 -5
- package/src/server/sync/response.ts +3 -3
- 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/elysia-contract.ts +23 -25
- package/src/shared/prefix.ts +8 -0
- package/src/shared/route-map.ts +10 -1
package/src/build/hydrate.ts
CHANGED
|
@@ -144,7 +144,7 @@ export function generateHydrateEntry(
|
|
|
144
144
|
: "const log = { error() {}, info() {} };";
|
|
145
145
|
|
|
146
146
|
// RouterProvider receives basePath so navigate() / Link push physical paths.
|
|
147
|
-
const routerProviderDefaults = `\n autoRefresh: true,\n basePath: ${basePathLiteral},\n defaultPreload: "intent",\n defaultPreloadDelay: 50,\n defaultPreloadStaleTime: 30000,\n prefetchCacheSize: 50,\n
|
|
147
|
+
const routerProviderDefaults = `\n autoRefresh: true,\n basePath: ${basePathLiteral},\n defaultPreload: "intent",\n defaultPreloadDelay: 50,\n defaultPreloadStaleTime: 30000,\n prefetchCacheSize: 50,\n syncPath,`;
|
|
148
148
|
|
|
149
149
|
const resolvedRootLayout = rootLayout.replace(/\\/g, "/");
|
|
150
150
|
const rootComponentKey = JSON.stringify(`root:${resolvedRootLayout}`);
|
|
@@ -161,6 +161,23 @@ import { route as __furin_root_route } from "${resolvedRootLayout}";
|
|
|
161
161
|
|
|
162
162
|
${loggerSetup}
|
|
163
163
|
|
|
164
|
+
if (import.meta.hot) {
|
|
165
|
+
const connectionState = ((window as unknown as {
|
|
166
|
+
__FURIN_HMR_CONNECTION__?: { disconnected: boolean; installed: boolean };
|
|
167
|
+
}).__FURIN_HMR_CONNECTION__ ??= { disconnected: false, installed: false });
|
|
168
|
+
if (!connectionState.installed) {
|
|
169
|
+
import.meta.hot.on("bun:ws:disconnect", () => {
|
|
170
|
+
connectionState.disconnected = true;
|
|
171
|
+
});
|
|
172
|
+
import.meta.hot.on("bun:ws:connect", () => {
|
|
173
|
+
if (connectionState.disconnected) {
|
|
174
|
+
window.location.reload();
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
connectionState.installed = true;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
164
181
|
const hotComponentRegistry = ((window as unknown as {
|
|
165
182
|
__FURIN_HOT_COMPONENTS__?: HotComponentRegistry;
|
|
166
183
|
}).__FURIN_HOT_COMPONENTS__ ??= new Map());
|
|
@@ -192,10 +209,13 @@ const dataEl = document.getElementById("__FURIN_DATA__");
|
|
|
192
209
|
let loaderData = dataEl ? JSON.parse(dataEl.textContent || "{}") : {};
|
|
193
210
|
const syncEl = document.getElementById("__FURIN_SYNC__");
|
|
194
211
|
const syncConfig = syncEl ? JSON.parse(syncEl.textContent || "{}") : {};
|
|
195
|
-
const
|
|
212
|
+
const syncPath = typeof syncConfig.path === "string" ? syncConfig.path : undefined;
|
|
196
213
|
const headEl = document.getElementById("__FURIN_HEAD__");
|
|
197
214
|
const head = headEl ? JSON.parse(headEl.textContent || "{}") : {};
|
|
198
215
|
const entryEl = document.querySelector("script[data-furin-entry][src]") as HTMLScriptElement | null;
|
|
216
|
+
const frameworkModules = Array.from(
|
|
217
|
+
document.querySelectorAll("script[data-furin-framework-module][src]")
|
|
218
|
+
).map((script) => script.getAttribute("src") ?? "").filter(Boolean);
|
|
199
219
|
const buildId = document.querySelector('meta[name="furin-build-id"]')?.getAttribute("content") ?? undefined;
|
|
200
220
|
const faviconHref = document.querySelector('link[rel="icon"]')?.getAttribute("href") ?? undefined;
|
|
201
221
|
const documentState: DocumentState = {
|
|
@@ -203,6 +223,7 @@ const documentState: DocumentState = {
|
|
|
203
223
|
buildId,
|
|
204
224
|
entryModule: entryEl?.getAttribute("src") ?? undefined,
|
|
205
225
|
faviconHref,
|
|
226
|
+
frameworkModules,
|
|
206
227
|
staticMode: document.querySelector('meta[name="furin-mode"][content="static"]') !== null,
|
|
207
228
|
stylesheets: Array.from(document.querySelectorAll('link[rel="stylesheet"]'))
|
|
208
229
|
.map((link) => link.getAttribute("href") ?? "")
|
|
@@ -313,6 +334,7 @@ if (__deferred && __deferred._chunks) {
|
|
|
313
334
|
initialMatch: match,
|
|
314
335
|
initialData: { ...loaderData, ...deferredData },
|
|
315
336
|
initialDigest: loaderData.__furinError?.digest,
|
|
337
|
+
initialError: loaderData.__furinError,
|
|
316
338
|
initialNotFound: isNotFound ? (loaderData.__furinNotFound ?? loaderData) : undefined,${routerProviderDefaults}
|
|
317
339
|
} as any);
|
|
318
340
|
} else if (loaderData.__furinStatus === 404) {
|
|
@@ -330,6 +352,7 @@ if (__deferred && __deferred._chunks) {
|
|
|
330
352
|
initialMatch: null,
|
|
331
353
|
initialData: cleanData,
|
|
332
354
|
initialDigest: loaderData.__furinError?.digest,
|
|
355
|
+
initialError: loaderData.__furinError,
|
|
333
356
|
initialNotFound: loaderData.__furinNotFound ?? {},${routerProviderDefaults}
|
|
334
357
|
} as any);
|
|
335
358
|
} else {
|
|
@@ -349,32 +372,46 @@ if (__deferred && __deferred._chunks) {
|
|
|
349
372
|
const hmrWindow = window as unknown as {
|
|
350
373
|
__FURIN_HMR_UPDATE__?: (
|
|
351
374
|
sourcePath: string,
|
|
352
|
-
component: (props: never) => ReactNode
|
|
353
|
-
|
|
375
|
+
component: (props: never) => ReactNode,
|
|
376
|
+
dataChanged: boolean
|
|
377
|
+
) => Promise<void>;
|
|
354
378
|
};
|
|
355
|
-
hmrWindow.__FURIN_HMR_UPDATE__ = (sourcePath, component) => {
|
|
356
|
-
const
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
379
|
+
hmrWindow.__FURIN_HMR_UPDATE__ = async (sourcePath, component, dataChanged) => {
|
|
380
|
+
const commitComponent = () => {
|
|
381
|
+
const componentKeySuffix = ":" + sourcePath;
|
|
382
|
+
for (const key of hotComponentRegistry.keys()) {
|
|
383
|
+
if (key.endsWith(componentKeySuffix)) {
|
|
384
|
+
updateHotComponent(hotComponentRegistry, key, component);
|
|
385
|
+
}
|
|
360
386
|
}
|
|
361
|
-
}
|
|
362
|
-
(window as
|
|
363
|
-
|
|
387
|
+
};
|
|
388
|
+
const refresh = (window as unknown as {
|
|
389
|
+
__FURIN_HMR_REFRESH__?: (
|
|
390
|
+
beforeCommit: (() => void) | undefined,
|
|
391
|
+
dataChanged: boolean
|
|
392
|
+
) => Promise<void>;
|
|
393
|
+
}).__FURIN_HMR_REFRESH__;
|
|
364
394
|
if (refresh) {
|
|
365
|
-
|
|
395
|
+
await refresh(commitComponent, dataChanged);
|
|
396
|
+
return;
|
|
366
397
|
}
|
|
398
|
+
window.location.reload();
|
|
367
399
|
};
|
|
368
400
|
if (existingRoot) {
|
|
369
|
-
// Already mounted — reconciliation, NOT hydration. React Fast Refresh
|
|
370
|
-
// patched the component in-place, now re-render with the new module.
|
|
371
|
-
existingRoot.render(app);
|
|
372
401
|
// The initialData embedded in the DOM is stale (from the original SSR).
|
|
373
|
-
//
|
|
374
|
-
//
|
|
375
|
-
|
|
402
|
+
// Prepare fresh loader data, then publish it with the new module in the
|
|
403
|
+
// same React commit. If the router effect is not installed yet, reconcile
|
|
404
|
+
// the module directly; this branch only occurs during initial boot.
|
|
405
|
+
const hmrRefresh = (window as unknown as {
|
|
406
|
+
__FURIN_HMR_REFRESH__?: (
|
|
407
|
+
beforeCommit: (() => void) | undefined,
|
|
408
|
+
dataChanged: boolean
|
|
409
|
+
) => Promise<void>;
|
|
410
|
+
}).__FURIN_HMR_REFRESH__;
|
|
376
411
|
if (hmrRefresh) {
|
|
377
|
-
|
|
412
|
+
await hmrRefresh(() => existingRoot.render(app), true);
|
|
413
|
+
} else {
|
|
414
|
+
existingRoot.render(app);
|
|
378
415
|
}
|
|
379
416
|
} else {
|
|
380
417
|
// First load — the root layout owns the server-rendered document.
|
|
@@ -389,6 +426,9 @@ if (__deferred && __deferred._chunks) {
|
|
|
389
426
|
log.info({ action: "hydrate_complete", pathname });
|
|
390
427
|
})().catch((err: unknown) => {
|
|
391
428
|
log.error({ action: "hydrate_failed", pathname, error: String(err) });
|
|
429
|
+
window.dispatchEvent(
|
|
430
|
+
new CustomEvent("furin:client-error", { detail: { error: err, phase: "hydrate" } })
|
|
431
|
+
);
|
|
392
432
|
});
|
|
393
433
|
`;
|
|
394
434
|
}
|
package/src/build/index.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// biome-ignore-all lint/performance/noAwaitInLoops: build phases run in sequence because later phases consume prior artifacts
|
|
2
2
|
import { existsSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { join, relative, resolve } from "node:path";
|
|
4
|
-
import { buildBunTarget
|
|
4
|
+
import { buildBunTarget } from "../adapter/bun";
|
|
5
5
|
import { buildPackageTarget } from "../adapter/package";
|
|
6
|
+
import type { RuntimeTargetApp } from "../adapter/runtime-build";
|
|
6
7
|
import { buildStaticTarget } from "../adapter/static";
|
|
8
|
+
import { buildVercelTarget } from "../adapter/vercel";
|
|
7
9
|
import { BUILD_TARGETS, type BuildTarget, type FurinPlugin } from "../config";
|
|
8
10
|
import { isomorphicTransformPlugin } from "../plugin/transform-isomorphic.ts";
|
|
9
11
|
import { normalizePrefix } from "../server/instance.ts";
|
|
@@ -25,11 +27,12 @@ export type {
|
|
|
25
27
|
BuildManifest,
|
|
26
28
|
BuildRouteManifestEntry,
|
|
27
29
|
TargetBuildManifest,
|
|
30
|
+
VercelTargetBuildManifest,
|
|
28
31
|
} from "./types";
|
|
29
32
|
|
|
30
33
|
// "package" is intentionally excluded from `--target all` — it is an
|
|
31
34
|
// alternative packaging of ONE app, not an additional deploy target.
|
|
32
|
-
const IMPLEMENTED_TARGETS = ["bun", "static"] as const satisfies BuildTarget[];
|
|
35
|
+
const IMPLEMENTED_TARGETS = ["bun", "vercel", "static"] as const satisfies BuildTarget[];
|
|
33
36
|
export const BUILD_OUTPUT_DIR = ".furin/build";
|
|
34
37
|
let isomorphicRuntimePluginRegistered = false;
|
|
35
38
|
|
|
@@ -147,13 +150,13 @@ export async function buildApp(options: BuildAppOptions): Promise<BuildAppResult
|
|
|
147
150
|
});
|
|
148
151
|
|
|
149
152
|
// scanPages throws if root.tsx is missing, so root is always defined per app.
|
|
150
|
-
const apps:
|
|
153
|
+
const apps: RuntimeTargetApp[] = [];
|
|
151
154
|
for (const spec of appSpecs) {
|
|
152
155
|
const { root, routes } = await scanPages(spec.pagesDir);
|
|
153
156
|
apps.push({ pagesDir: spec.pagesDir, prefix: spec.prefix, root, routes });
|
|
154
157
|
}
|
|
155
158
|
// The root-mounted app drives single-app manifest fields and the static target.
|
|
156
|
-
const primaryApp = (apps.find((app) => app.prefix === "") ?? apps[0]) as
|
|
159
|
+
const primaryApp = (apps.find((app) => app.prefix === "") ?? apps[0]) as RuntimeTargetApp;
|
|
157
160
|
|
|
158
161
|
ensureDir(buildRoot);
|
|
159
162
|
|
|
@@ -215,12 +218,18 @@ export async function buildApp(options: BuildAppOptions): Promise<BuildAppResult
|
|
|
215
218
|
options
|
|
216
219
|
);
|
|
217
220
|
break;
|
|
218
|
-
case "node":
|
|
219
221
|
case "vercel":
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
222
|
+
if (!serverEntry) {
|
|
223
|
+
throw new Error("[furin] `--target vercel` requires a server entry point.");
|
|
224
|
+
}
|
|
225
|
+
manifest.targets.vercel = await buildVercelTarget(
|
|
226
|
+
apps,
|
|
227
|
+
rootDir,
|
|
228
|
+
buildRoot,
|
|
229
|
+
serverEntry,
|
|
230
|
+
options
|
|
223
231
|
);
|
|
232
|
+
break;
|
|
224
233
|
default:
|
|
225
234
|
throw new Error(`[furin] Unsupported build target "${target}"`);
|
|
226
235
|
}
|
|
@@ -1,14 +1,66 @@
|
|
|
1
|
-
import { resolve } from "node:path";
|
|
1
|
+
import { dirname, relative, resolve } from "node:path";
|
|
2
2
|
|
|
3
3
|
const INSTRUMENTATION_IMPORT = /(?:^|[/\\])devtools[/\\]instrumentation(?:\.ts|\.js)?$/;
|
|
4
|
+
const DEV_PAGE_PLUGIN_IMPORT = /(?:^|[/\\])server[/\\]dev-page-plugin(?:\.ts|\.js)?$/;
|
|
5
|
+
const DEV_RUNTIME_IMPORT =
|
|
6
|
+
/(?:^|[/\\])server[/\\]dev[/\\](?:browser-events|diagnostics|graph|plugin)(?:\.ts|\.js)?$/;
|
|
7
|
+
const DEV_BUILD_IMPORT =
|
|
8
|
+
/(?:^|[/\\])(?:build[/\\]hydrate|plugin[/\\]route-config-autofix)(?:\.ts|\.js)?$/;
|
|
9
|
+
const HMR_IMPORT = /(?:^|[/\\])server[/\\]router[/\\]hmr(?:\.ts|\.js)?$/;
|
|
10
|
+
const PRODUCTION_BOUNDARY_IMPORT =
|
|
11
|
+
/(?:browser-events|instrumentation|dev-page-plugin|diagnostics|graph|plugin|hmr|hydrate|route-config-autofix)(?:\.ts|\.js)?$/;
|
|
12
|
+
const PRODUCTION_STUB_NAMESPACE = "furin-production-runtime-stub";
|
|
13
|
+
const FURIN_RUNTIME_ROOT = resolve(import.meta.dir, "..");
|
|
14
|
+
|
|
15
|
+
function isFurinRuntimePath(path: string): boolean {
|
|
16
|
+
const fromRuntimeRoot = relative(FURIN_RUNTIME_ROOT, path);
|
|
17
|
+
return (
|
|
18
|
+
fromRuntimeRoot !== ".." &&
|
|
19
|
+
!fromRuntimeRoot.startsWith("../") &&
|
|
20
|
+
!fromRuntimeRoot.startsWith("..\\")
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function devBuildExport(path: string): "fixRouteConfigLayout" | "writeDevFiles" {
|
|
25
|
+
return path.includes("route-config-autofix") ? "fixRouteConfigLayout" : "writeDevFiles";
|
|
26
|
+
}
|
|
4
27
|
|
|
5
28
|
export function productionInstrumentationPlugin(): Bun.BunPlugin {
|
|
6
29
|
return {
|
|
7
30
|
name: "furin-production-instrumentation",
|
|
8
31
|
setup(build) {
|
|
9
|
-
build.onResolve({ filter:
|
|
10
|
-
|
|
11
|
-
|
|
32
|
+
build.onResolve({ filter: PRODUCTION_BOUNDARY_IMPORT }, (args) => {
|
|
33
|
+
const importPath = resolve(dirname(args.importer), args.path);
|
|
34
|
+
if (!isFurinRuntimePath(importPath)) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (INSTRUMENTATION_IMPORT.test(importPath)) {
|
|
38
|
+
return {
|
|
39
|
+
path: resolve(import.meta.dir, "../server/devtools/instrumentation.production.ts"),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
if (DEV_PAGE_PLUGIN_IMPORT.test(importPath)) {
|
|
43
|
+
return { path: resolve(import.meta.dir, "../server/dev-page-plugin.production.ts") };
|
|
44
|
+
}
|
|
45
|
+
if (DEV_RUNTIME_IMPORT.test(importPath)) {
|
|
46
|
+
return { path: resolve(import.meta.dir, "../server/dev/runtime.production.ts") };
|
|
47
|
+
}
|
|
48
|
+
if (HMR_IMPORT.test(importPath)) {
|
|
49
|
+
return { path: resolve(import.meta.dir, "../server/router/hmr.production.ts") };
|
|
50
|
+
}
|
|
51
|
+
if (DEV_BUILD_IMPORT.test(importPath)) {
|
|
52
|
+
return { namespace: PRODUCTION_STUB_NAMESPACE, path: importPath };
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
build.onLoad(
|
|
56
|
+
{ filter: /.*/, namespace: PRODUCTION_STUB_NAMESPACE },
|
|
57
|
+
({ path }) => ({
|
|
58
|
+
contents: `export function ${devBuildExport(path)}() {
|
|
59
|
+
throw new Error("[furin] Development-only module reached a production bundle.");
|
|
60
|
+
}`,
|
|
61
|
+
loader: "js",
|
|
62
|
+
})
|
|
63
|
+
);
|
|
12
64
|
},
|
|
13
65
|
};
|
|
14
66
|
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import {
|
|
4
|
+
materializedRouteModuleSource,
|
|
5
|
+
type RouteInstanceSpec,
|
|
6
|
+
} from "../plugin/routes.ts";
|
|
7
|
+
import { buildEntrySource, type EntryAppContext } from "./entry-template.ts";
|
|
8
|
+
import { ensureDir, toPosixPath } from "./shared.ts";
|
|
9
|
+
|
|
10
|
+
interface MaterializeServerAppEntryOptions {
|
|
11
|
+
apps: EntryAppContext[];
|
|
12
|
+
headerComment: string;
|
|
13
|
+
instances: RouteInstanceSpec[];
|
|
14
|
+
outDir: string;
|
|
15
|
+
serverEntry: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function materializeServerAppEntry(
|
|
19
|
+
options: MaterializeServerAppEntryOptions
|
|
20
|
+
): Promise<string> {
|
|
21
|
+
ensureDir(options.outDir);
|
|
22
|
+
const apps = await Promise.all(
|
|
23
|
+
options.apps.map(async (app, index): Promise<EntryAppContext> => {
|
|
24
|
+
const instance = options.instances[index];
|
|
25
|
+
if (!instance) {
|
|
26
|
+
throw new Error(`[furin] Missing route instance for server app ${index}.`);
|
|
27
|
+
}
|
|
28
|
+
const routePath = join(options.outDir, `_furin-routes-${index}.ts`);
|
|
29
|
+
writeFileSync(routePath, await materializedRouteModuleSource(instance));
|
|
30
|
+
return { ...app, nativeRoutes: toPosixPath(routePath) };
|
|
31
|
+
})
|
|
32
|
+
);
|
|
33
|
+
const entryPath = join(options.outDir, "_furin-app.ts");
|
|
34
|
+
writeFileSync(
|
|
35
|
+
entryPath,
|
|
36
|
+
buildEntrySource({
|
|
37
|
+
apps,
|
|
38
|
+
headerComment: options.headerComment,
|
|
39
|
+
mode: "app",
|
|
40
|
+
serverEntry: options.serverEntry,
|
|
41
|
+
})
|
|
42
|
+
);
|
|
43
|
+
return entryPath;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function serverBootSource(appEntry: string): string {
|
|
47
|
+
return `// Auto-generated by furin build - do not edit
|
|
48
|
+
import app, { port, startServer } from ${JSON.stringify(toPosixPath(appEntry))};
|
|
49
|
+
|
|
50
|
+
if (typeof startServer === "function") {
|
|
51
|
+
await startServer();
|
|
52
|
+
} else if (app && typeof app.listen === "function" && !app.server) {
|
|
53
|
+
const serverPort = process.env.PORT === undefined
|
|
54
|
+
? typeof port === "number" ? port : 3000
|
|
55
|
+
: Number(process.env.PORT);
|
|
56
|
+
app.listen(serverPort);
|
|
57
|
+
console.log(\`[furin] Server running at http://localhost:\${app.server?.port}\`);
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
60
|
+
}
|
package/src/build/shared.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { cpSync, existsSync, mkdirSync, readdirSync, rmSync } from "node:fs";
|
|
|
2
2
|
import { join, relative } from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import type { BuildTarget } from "../config";
|
|
5
|
+
import { resolveRouteRevalidate } from "../server/router/patterns.ts";
|
|
5
6
|
import type { ResolvedRoute } from "../server/router/types.ts";
|
|
6
7
|
import type { BuildRouteManifestEntry, TargetBuildManifest } from "./types";
|
|
7
8
|
|
|
@@ -55,8 +56,10 @@ export function toBuildRouteManifestEntry(
|
|
|
55
56
|
mode: route.mode,
|
|
56
57
|
pagePath: toPosixPath(relative(rootDir, route.path)),
|
|
57
58
|
hasLayout: route.routeChain.some((entry) => !!entry.layout),
|
|
58
|
-
hasStaticParams:
|
|
59
|
-
|
|
59
|
+
hasStaticParams:
|
|
60
|
+
route.page.staticParams !== undefined ||
|
|
61
|
+
route.routeChain.some((entry) => entry.staticParams !== undefined),
|
|
62
|
+
revalidate: resolveRouteRevalidate(route.page) ?? null,
|
|
60
63
|
};
|
|
61
64
|
}
|
|
62
65
|
|
package/src/build/ssg-cache.ts
CHANGED
|
@@ -1,38 +1,119 @@
|
|
|
1
1
|
// biome-ignore-all lint/performance/noAwaitInLoops: SSG cache generation runs routes sequentially for deterministic cache output
|
|
2
2
|
import type { SsgCacheEntry } from "../server/cache/index.ts";
|
|
3
3
|
import { resolvePath } from "../server/render/assemble.ts";
|
|
4
|
-
import { prerenderSSG } from "../server/render/index.ts";
|
|
4
|
+
import { prerenderRoute, prerenderSSG } from "../server/render/index.ts";
|
|
5
|
+
import { hasRequestLoader } from "../server/render/loaders.ts";
|
|
6
|
+
import { hasStaticParams, resolveStaticParams } from "../server/render/static-params.ts";
|
|
7
|
+
import { buildRouteMatcher } from "../server/router/patterns.ts";
|
|
5
8
|
import { createSearchRouteMetadata } from "../server/router/schemas.ts";
|
|
6
9
|
import type { ResolvedRoute, RootLayout } from "../server/router/types.ts";
|
|
7
10
|
|
|
8
11
|
export type SSGCacheSnapshot = Record<string, SsgCacheEntry>;
|
|
9
12
|
|
|
13
|
+
export interface RoutePrerender {
|
|
14
|
+
path: string;
|
|
15
|
+
/** PPR targets are materialized later by the exact production bundle. */
|
|
16
|
+
result?: SsgCacheEntry | Response;
|
|
17
|
+
route: ResolvedRoute;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const DYNAMIC_SEGMENT_RE = /\/:[^/]+|\/\*/;
|
|
21
|
+
|
|
22
|
+
function hasRequestDependentInput(route: ResolvedRoute, root: RootLayout): boolean {
|
|
23
|
+
return [root.route, ...route.routeChain].some(
|
|
24
|
+
(routeConfig) =>
|
|
25
|
+
routeConfig.query !== undefined
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Renders every selected route URL known at build time. Fixed routes are always
|
|
31
|
+
* known; dynamic routes contribute the values returned by staticParams(). ISR
|
|
32
|
+
* routes with query schemas stay on-demand. PPR paths are collected here, then
|
|
33
|
+
* rendered by the production bundle so React's postponed tree matches at runtime.
|
|
34
|
+
*/
|
|
35
|
+
export async function buildRoutePrerenders(
|
|
36
|
+
routes: ResolvedRoute[],
|
|
37
|
+
root: RootLayout,
|
|
38
|
+
origin: string,
|
|
39
|
+
basePath: string
|
|
40
|
+
): Promise<RoutePrerender[]> {
|
|
41
|
+
const prerenders: RoutePrerender[] = [];
|
|
42
|
+
const searchRoutes = createSearchRouteMetadata(routes);
|
|
43
|
+
const matchRoute = buildRouteMatcher(routes);
|
|
44
|
+
|
|
45
|
+
for (const route of routes) {
|
|
46
|
+
if (route.mode === "ssr") {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (hasRequestDependentInput(route, root)) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let paramSets: Record<string, string>[];
|
|
54
|
+
if (!DYNAMIC_SEGMENT_RE.test(route.pattern)) {
|
|
55
|
+
paramSets = [{}];
|
|
56
|
+
} else if (hasStaticParams(route)) {
|
|
57
|
+
paramSets = (await resolveStaticParams(route, origin)) ?? [];
|
|
58
|
+
} else {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
for (const params of paramSets) {
|
|
63
|
+
const path = resolvePath(route.pattern, params);
|
|
64
|
+
if (matchRoute(path)?.route !== route) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (root.route.requestLoader !== undefined || hasRequestLoader(route)) {
|
|
68
|
+
prerenders.push({ path, route });
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const result =
|
|
72
|
+
route.mode === "ssg"
|
|
73
|
+
? await prerenderSSG(route, params, root, origin, basePath, searchRoutes)
|
|
74
|
+
: await prerenderRoute(
|
|
75
|
+
route,
|
|
76
|
+
params,
|
|
77
|
+
root,
|
|
78
|
+
origin,
|
|
79
|
+
"isr",
|
|
80
|
+
basePath,
|
|
81
|
+
searchRoutes
|
|
82
|
+
);
|
|
83
|
+
prerenders.push({ path, result, route });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return prerenders;
|
|
88
|
+
}
|
|
89
|
+
|
|
10
90
|
export async function buildSSGCacheSnapshot(
|
|
11
91
|
routes: ResolvedRoute[],
|
|
12
92
|
root: RootLayout,
|
|
13
93
|
origin: string,
|
|
14
|
-
// Build-time renders run OUTSIDE any instance scope (default bucket), so a
|
|
15
|
-
// prefixed app's mount prefix must be passed explicitly — otherwise the
|
|
16
|
-
// snapshot HTML bakes in basePath "" and prerendered <Link> hrefs lose it.
|
|
17
94
|
basePath?: string
|
|
18
95
|
): Promise<SSGCacheSnapshot> {
|
|
19
96
|
const snapshot: SSGCacheSnapshot = {};
|
|
20
97
|
const searchRoutes = createSearchRouteMetadata(routes);
|
|
21
98
|
|
|
22
99
|
for (const route of routes) {
|
|
23
|
-
if (route.mode !== "ssg" || !route
|
|
100
|
+
if (route.mode !== "ssg" || !hasStaticParams(route) || hasRequestLoader(route)) {
|
|
24
101
|
continue;
|
|
25
102
|
}
|
|
26
|
-
|
|
27
|
-
const paramSets = await route.page.staticParams();
|
|
103
|
+
const paramSets = (await resolveStaticParams(route, origin)) ?? [];
|
|
28
104
|
for (const params of paramSets) {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
105
|
+
const result = await prerenderSSG(
|
|
106
|
+
route,
|
|
107
|
+
params,
|
|
108
|
+
root,
|
|
109
|
+
origin,
|
|
110
|
+
basePath,
|
|
111
|
+
searchRoutes
|
|
112
|
+
);
|
|
113
|
+
if (!(result instanceof Response)) {
|
|
114
|
+
snapshot[resolvePath(route.pattern, params)] = result;
|
|
32
115
|
}
|
|
33
|
-
snapshot[resolvePath(route.pattern, params)] = entry;
|
|
34
116
|
}
|
|
35
117
|
}
|
|
36
|
-
|
|
37
118
|
return snapshot;
|
|
38
119
|
}
|
package/src/build/types.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
BuildTarget,
|
|
3
|
+
StaticExportConfig,
|
|
4
|
+
VercelDeploymentConfig,
|
|
5
|
+
} from "../config";
|
|
2
6
|
import type { ResolvedRoute } from "../server/router/types.ts";
|
|
3
7
|
|
|
4
8
|
export interface BuildClientOptions {
|
|
@@ -15,9 +19,15 @@ export interface BuildClientOptions {
|
|
|
15
19
|
clientDirName?: string;
|
|
16
20
|
/** Inject the evlog client logger into the hydrate entry. Off by default. */
|
|
17
21
|
clientLogging: boolean;
|
|
22
|
+
/** Write Bun's complete build metafile to this path when provided. */
|
|
23
|
+
metafilePath?: string;
|
|
24
|
+
/** Package barrels Bun should parse on demand instead of loading in full. */
|
|
25
|
+
optimizeImports?: string[];
|
|
18
26
|
outDir: string;
|
|
19
27
|
pagesDir?: string;
|
|
20
28
|
plugins?: Bun.BunPlugin[];
|
|
29
|
+
/** Enable Bun's native Rust React Compiler. Defaults to true. */
|
|
30
|
+
reactCompiler?: boolean;
|
|
21
31
|
/**
|
|
22
32
|
* Public path prefix for all emitted JS/CSS chunks.
|
|
23
33
|
* Pass "/_client/" for root deployments; override for basePath deployments,
|
|
@@ -64,7 +74,8 @@ export interface PackageTargetBuildManifest {
|
|
|
64
74
|
export type AnyTargetManifest =
|
|
65
75
|
| TargetBuildManifest
|
|
66
76
|
| StaticTargetBuildManifest
|
|
67
|
-
| PackageTargetBuildManifest
|
|
77
|
+
| PackageTargetBuildManifest
|
|
78
|
+
| VercelTargetBuildManifest;
|
|
68
79
|
|
|
69
80
|
/** One mounted app in a multi-instance build. */
|
|
70
81
|
export interface BuildAppSpec {
|
|
@@ -87,6 +98,8 @@ export interface BuildManifest {
|
|
|
87
98
|
}
|
|
88
99
|
|
|
89
100
|
export interface BuildAppOptions {
|
|
101
|
+
/** Emit Bun metafiles for client and supported server bundle analysis. */
|
|
102
|
+
analyze?: boolean;
|
|
90
103
|
/**
|
|
91
104
|
* Explicit multi-app build (furin.config.ts `apps`). Overrides `pagesDir`
|
|
92
105
|
* and server-entry auto-detection.
|
|
@@ -95,13 +108,19 @@ export interface BuildAppOptions {
|
|
|
95
108
|
/** Inject the evlog client logger into the hydrate entry. Defaults to false. */
|
|
96
109
|
clientLogging?: boolean;
|
|
97
110
|
compile?: "server" | "embed";
|
|
111
|
+
/** Package barrels Bun should parse on demand in production client bundles. */
|
|
112
|
+
optimizeImports?: string[];
|
|
98
113
|
pagesDir?: string;
|
|
99
114
|
plugins?: Bun.BunPlugin[];
|
|
115
|
+
/** Enable Bun's native Rust React Compiler for client bundles. Defaults to true. */
|
|
116
|
+
reactCompiler?: boolean;
|
|
100
117
|
rootDir?: string;
|
|
101
118
|
serverEntry?: string;
|
|
102
119
|
/** Configuration for the `static` build target. */
|
|
103
120
|
staticConfig?: StaticExportConfig;
|
|
104
121
|
target: BuildTarget | "all";
|
|
122
|
+
/** Configuration for the Vercel build target. */
|
|
123
|
+
vercelConfig?: VercelDeploymentConfig;
|
|
105
124
|
}
|
|
106
125
|
|
|
107
126
|
/** Build manifest entry produced by the `static` adapter. */
|
|
@@ -113,6 +132,16 @@ export interface StaticTargetBuildManifest {
|
|
|
113
132
|
skippedRoutes: string[];
|
|
114
133
|
}
|
|
115
134
|
|
|
135
|
+
/** Build manifest entry produced by the Vercel Build Output API adapter. */
|
|
136
|
+
export interface VercelTargetBuildManifest {
|
|
137
|
+
buildId: string;
|
|
138
|
+
generatedAt: string;
|
|
139
|
+
isrRoutes: string[];
|
|
140
|
+
outputDir: string;
|
|
141
|
+
serverPath: string;
|
|
142
|
+
ssgRoutes: string[];
|
|
143
|
+
}
|
|
144
|
+
|
|
116
145
|
export interface BuildAppResult {
|
|
117
146
|
manifest: BuildManifest;
|
|
118
147
|
targets: Partial<Record<BuildTarget, AnyTargetManifest>>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const REGEX_SPECIAL_CHARACTERS_RE = /[.*+?^${}()|[\]\\]/g;
|
|
2
|
+
|
|
3
|
+
export interface VirtualBuildEntry {
|
|
4
|
+
entrypoint: string;
|
|
5
|
+
files: { [path: string]: string };
|
|
6
|
+
plugin: Bun.BunPlugin;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function createVirtualBuildEntry(
|
|
10
|
+
entrypoint: string,
|
|
11
|
+
source: string,
|
|
12
|
+
loader: Bun.Loader
|
|
13
|
+
): VirtualBuildEntry {
|
|
14
|
+
const normalizedEntrypoint = entrypoint.replaceAll("\\", "/");
|
|
15
|
+
const entrypointFilter = new RegExp(
|
|
16
|
+
`^${normalizedEntrypoint.replace(REGEX_SPECIAL_CHARACTERS_RE, "\\$&")}$`
|
|
17
|
+
);
|
|
18
|
+
return {
|
|
19
|
+
entrypoint: normalizedEntrypoint,
|
|
20
|
+
files: { [normalizedEntrypoint]: source },
|
|
21
|
+
plugin: {
|
|
22
|
+
name: `furin-virtual-entry:${normalizedEntrypoint}`,
|
|
23
|
+
setup(build) {
|
|
24
|
+
build.onLoad({ filter: entrypointFilter }, () => ({ contents: source, loader }));
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
package/src/cache.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getCache as getRuntimeCache,
|
|
3
|
+
type RuntimeCache as RuntimeCacheContract,
|
|
4
|
+
type RuntimeCacheOptions as RuntimeCacheOptionsContract,
|
|
5
|
+
type RuntimeCacheSetOptions as RuntimeCacheSetOptionsContract,
|
|
6
|
+
} from "./server/cache/runtime-cache.ts";
|
|
7
|
+
|
|
8
|
+
// biome-ignore lint/performance/noBarrelFile: this is the intentional public cache entrypoint.
|
|
9
|
+
export {
|
|
10
|
+
createMemoryPageCache,
|
|
11
|
+
type PageCacheAdapter,
|
|
12
|
+
type PageCacheEntry,
|
|
13
|
+
type PageCacheIdentity,
|
|
14
|
+
type PageCacheInvalidation,
|
|
15
|
+
type PageCacheInvalidationResult,
|
|
16
|
+
type PageCacheLease,
|
|
17
|
+
type PageCacheMode,
|
|
18
|
+
} from "./server/cache/page-cache.ts";
|
|
19
|
+
|
|
20
|
+
export type RuntimeCache = RuntimeCacheContract;
|
|
21
|
+
export type RuntimeCacheOptions = RuntimeCacheOptionsContract;
|
|
22
|
+
export type RuntimeCacheSetOptions = RuntimeCacheSetOptionsContract;
|
|
23
|
+
|
|
24
|
+
export function getCache(options?: RuntimeCacheOptions): RuntimeCache {
|
|
25
|
+
return getRuntimeCache(options);
|
|
26
|
+
}
|
package/src/cli/config.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
3
|
import { pathToFileURL } from "node:url";
|
|
4
|
+
import { Validator } from "elysia";
|
|
4
5
|
import { configSchema, type FurinConfig } from "../config.ts";
|
|
5
|
-
import { TypeCompiler } from "../shared/elysia-contract.ts";
|
|
6
6
|
|
|
7
|
-
const compiledConfigSchema =
|
|
7
|
+
const compiledConfigSchema = Validator.create(configSchema);
|
|
8
8
|
|
|
9
9
|
const DEFAULT_CONFIG_FILENAMES = [
|
|
10
10
|
"furin.config.ts",
|
|
@@ -57,7 +57,7 @@ export async function loadCliConfig(
|
|
|
57
57
|
if (!compiledConfigSchema.Check(configToValidate)) {
|
|
58
58
|
const [firstError] = compiledConfigSchema.Errors(configToValidate);
|
|
59
59
|
throw new Error(
|
|
60
|
-
`[furin] Invalid config at ${configPath}: ${firstError?.message ?? "unknown error"} (path: ${firstError?.
|
|
60
|
+
`[furin] Invalid config at ${configPath}: ${firstError?.message ?? "unknown error"} (path: ${firstError?.instancePath ?? "/"})`
|
|
61
61
|
);
|
|
62
62
|
}
|
|
63
63
|
|