@teyik0/furin 0.1.0-alpha.11 → 0.1.0-alpha.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +251 -0
- package/dist/build/compile-entry.ts +129 -0
- package/dist/build/entry-template.ts +133 -0
- package/dist/build/index.js +453 -282
- package/dist/build/server-routes-entry.ts +55 -0
- package/dist/cli/index.js +457 -286
- package/dist/env.d.ts +50 -0
- package/dist/furin.js +402 -263
- package/dist/internal.js +17 -0
- package/dist/link.d.ts +5 -438
- package/dist/link.js +228 -137
- package/dist/plugin/index.js +9 -7
- package/dist/render/cache.d.ts +18 -5
- package/dist/render/dev-cache.d.ts +29 -0
- package/dist/render/index.ts +870 -0
- package/dist/render/route-cache.d.ts +26 -0
- package/dist/render/shell.ts +187 -0
- package/dist/router-provider.d.ts +467 -0
- package/dist/router.js +515 -368
- package/dist/router.ts +1034 -0
- package/dist/runtime-env.js +10 -0
- package/package.json +47 -17
- package/src/adapter/bun.ts +4 -1
- package/src/build/entry-template.ts +13 -6
- package/src/build/hydrate.ts +7 -5
- package/src/build/scan-server.ts +32 -3
- package/src/dev-page-plugin.ts +6 -0
- package/src/link.tsx +43 -1297
- package/src/plugin/transform-client.ts +10 -8
- package/src/render/cache.ts +77 -67
- package/src/render/dev-cache.ts +106 -15
- package/src/render/index.ts +4 -3
- package/src/render/route-cache.ts +124 -0
- package/src/router-provider.tsx +1428 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { buildEntrySource } from "./entry-template";
|
|
4
|
+
import { ensureDir } from "./shared";
|
|
5
|
+
|
|
6
|
+
export interface ServerRoutesEntryOptions {
|
|
7
|
+
buildId?: string;
|
|
8
|
+
outDir: string;
|
|
9
|
+
rootConventions?: { errorPath?: string; notFoundPath?: string };
|
|
10
|
+
rootPath: string;
|
|
11
|
+
routeMetadata?: Record<
|
|
12
|
+
string,
|
|
13
|
+
{
|
|
14
|
+
segmentBoundaries: Array<{
|
|
15
|
+
depth: number;
|
|
16
|
+
path: string;
|
|
17
|
+
errorPath?: string;
|
|
18
|
+
notFoundPath?: string;
|
|
19
|
+
}>;
|
|
20
|
+
}
|
|
21
|
+
>;
|
|
22
|
+
routes: Array<{ mode: "ssr" | "ssg" | "isr"; path: string; pattern: string }>;
|
|
23
|
+
serverEntry: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Generates `server.ts` — an intermediate entry used to produce `server.js`.
|
|
28
|
+
*
|
|
29
|
+
* Equivalent to `_compile-entry.ts` but for disk (non-binary) production builds:
|
|
30
|
+
* 1. Statically imports every page module so Bun bundles them into server.js
|
|
31
|
+
* 2. Sets production mode and registers everything in a single CompileContext
|
|
32
|
+
* 3. Imports server.ts to boot the app
|
|
33
|
+
*
|
|
34
|
+
* This file is intermediate: `adapter/bun.ts` runs `Bun.build()` on it to produce
|
|
35
|
+
* the self-contained `server.js` bundle, then deletes this file.
|
|
36
|
+
*/
|
|
37
|
+
export function generateServerRoutesEntry(options: ServerRoutesEntryOptions): string {
|
|
38
|
+
const { buildId, outDir, rootPath, routes, serverEntry, rootConventions, routeMetadata } =
|
|
39
|
+
options;
|
|
40
|
+
ensureDir(outDir);
|
|
41
|
+
const source = buildEntrySource({
|
|
42
|
+
buildId,
|
|
43
|
+
headerComment: "// Auto-generated by furin build — do not edit",
|
|
44
|
+
rootPath,
|
|
45
|
+
routes,
|
|
46
|
+
serverEntry,
|
|
47
|
+
rootConventions,
|
|
48
|
+
routeMetadata,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Named "server.ts" so Bun.build() outputs "server.js"
|
|
52
|
+
const entryPath = join(outDir, "server.ts");
|
|
53
|
+
writeFileSync(entryPath, source);
|
|
54
|
+
return entryPath;
|
|
55
|
+
}
|