react-bun-ssr 0.2.0 → 0.3.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/README.md +36 -17
- package/framework/cli/commands.ts +52 -30
- package/framework/cli/dev-client-watch.ts +12 -5
- package/framework/cli/internal.ts +7 -3
- package/framework/cli/scaffold.ts +183 -5
- package/framework/runtime/build-tools.ts +3 -1
- package/framework/runtime/client-runtime.tsx +83 -33
- package/framework/runtime/config.ts +7 -2
- package/framework/runtime/index.ts +1 -1
- package/framework/runtime/link.tsx +3 -11
- package/framework/runtime/module-loader.ts +13 -1
- package/framework/runtime/render.tsx +94 -2
- package/framework/runtime/route-api.ts +1 -1
- package/framework/runtime/router.ts +75 -4
- package/framework/runtime/server.ts +8 -0
- package/framework/runtime/tree.tsx +24 -2
- package/framework/runtime/types.ts +1 -1
- package/package.json +13 -8
|
@@ -227,6 +227,11 @@ function applyConfiguredHeaders(options: {
|
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
for (const [name, value] of Object.entries(rule.headers)) {
|
|
230
|
+
if (value === null) {
|
|
231
|
+
headers.delete(name);
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
|
|
230
235
|
headers.set(name, value);
|
|
231
236
|
}
|
|
232
237
|
}
|
|
@@ -630,15 +635,18 @@ export function createServer(
|
|
|
630
635
|
|
|
631
636
|
const routeAdapter = await getRouteAdapter(activeConfig);
|
|
632
637
|
const devCacheBustKey = dev ? String(runtimeOptions.reloadVersion?.() ?? 0) : undefined;
|
|
638
|
+
const nodeEnv: "development" | "production" = dev ? "development" : "production";
|
|
633
639
|
const routeModuleLoadOptions = {
|
|
634
640
|
cacheBustKey: devCacheBustKey,
|
|
635
641
|
serverBytecode: activeConfig.serverBytecode,
|
|
636
642
|
devSourceImports: false,
|
|
643
|
+
nodeEnv,
|
|
637
644
|
};
|
|
638
645
|
const requestModuleLoadOptions = {
|
|
639
646
|
cacheBustKey: undefined,
|
|
640
647
|
serverBytecode: activeConfig.serverBytecode,
|
|
641
648
|
devSourceImports: dev,
|
|
649
|
+
nodeEnv,
|
|
642
650
|
};
|
|
643
651
|
const routeAssetsById = resolveAllRouteAssets({
|
|
644
652
|
dev,
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
createContext,
|
|
3
3
|
useContext,
|
|
4
4
|
type ComponentType,
|
|
5
|
+
type Context,
|
|
5
6
|
type ReactElement,
|
|
6
7
|
type ReactNode,
|
|
7
8
|
} from "react";
|
|
@@ -15,8 +16,29 @@ interface RuntimeState {
|
|
|
15
16
|
reset: () => void;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
const
|
|
19
|
-
const
|
|
19
|
+
const RUNTIME_CONTEXT_KEY = Symbol.for("react-bun-ssr.runtime-context");
|
|
20
|
+
const OUTLET_CONTEXT_KEY = Symbol.for("react-bun-ssr.outlet-context");
|
|
21
|
+
|
|
22
|
+
function getGlobalContext<T>(key: symbol, createValue: () => Context<T>): Context<T> {
|
|
23
|
+
const globalRegistry = globalThis as typeof globalThis & { [contextKey: symbol]: Context<T> | undefined };
|
|
24
|
+
const existing = globalRegistry[key];
|
|
25
|
+
if (existing) {
|
|
26
|
+
return existing;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const context = createValue();
|
|
30
|
+
globalRegistry[key] = context;
|
|
31
|
+
return context;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const RuntimeContext = getGlobalContext<RuntimeState | null>(
|
|
35
|
+
RUNTIME_CONTEXT_KEY,
|
|
36
|
+
() => createContext<RuntimeState | null>(null),
|
|
37
|
+
);
|
|
38
|
+
const OutletContext = getGlobalContext<ReactNode>(
|
|
39
|
+
OUTLET_CONTEXT_KEY,
|
|
40
|
+
() => createContext<ReactNode>(null),
|
|
41
|
+
);
|
|
20
42
|
const NOOP_RESET = () => undefined;
|
|
21
43
|
|
|
22
44
|
function useRuntimeState(): RuntimeState {
|
|
@@ -123,7 +123,7 @@ export interface ApiRouteModule {
|
|
|
123
123
|
|
|
124
124
|
export interface ResponseHeaderRule {
|
|
125
125
|
source: string;
|
|
126
|
-
headers: Record<string, string>;
|
|
126
|
+
headers: Record<string, string | null>;
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
export interface ResolvedResponseHeaderRule extends ResponseHeaderRule {
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-bun-ssr",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
+
"workspaces": [
|
|
8
|
+
"app"
|
|
9
|
+
],
|
|
7
10
|
"types": "./framework/runtime/index.ts",
|
|
8
11
|
"repository": {
|
|
9
12
|
"type": "git",
|
|
@@ -44,10 +47,16 @@
|
|
|
44
47
|
"start": "bun bin/rbssr.ts start",
|
|
45
48
|
"typecheck": "bun bin/rbssr.ts typecheck",
|
|
46
49
|
"test": "bun bin/rbssr.ts test",
|
|
47
|
-
"test:unit": "bun test ./tests/unit",
|
|
48
|
-
"test:integration": "bun test ./tests/integration",
|
|
49
|
-
"test:consumer": "RBSSR_RUN_CONSUMER_SMOKE=1 bun test ./tests/integration/package-smoke.test.ts",
|
|
50
|
+
"test:unit": "bun test ./tests/framework/unit ./tests/docs-app/unit",
|
|
51
|
+
"test:integration": "bun test ./tests/framework/integration ./tests/docs-app/integration",
|
|
52
|
+
"test:consumer": "RBSSR_RUN_CONSUMER_SMOKE=1 bun test ./tests/framework/integration/package-smoke.test.ts",
|
|
53
|
+
"test:watch": "bunx chokidar-cli \"framework/**/*\" \"app/**/*\" \"scripts/**/*\" \"tests/**/*\" -c \"bun run test:unit && bun run test:integration\"",
|
|
54
|
+
"test:watch:framework:unit": "bunx chokidar-cli \"framework/**/*\" \"scripts/**/*\" \"tests/framework/unit/**/*\" \"tests/framework/helpers/**/*\" -c \"bun test ./tests/framework/unit\"",
|
|
55
|
+
"test:watch:framework:integration": "bunx chokidar-cli \"framework/**/*\" \"scripts/**/*\" \"tests/framework/integration/**/*\" \"tests/framework/helpers/**/*\" \"app/**/*\" -c \"bun test ./tests/framework/integration\"",
|
|
56
|
+
"test:watch:docs-app:unit": "bunx chokidar-cli \"app/**/*\" \"tests/docs-app/unit/**/*\" -c \"bun test ./tests/docs-app/unit\"",
|
|
57
|
+
"test:watch:docs-app:integration": "bunx chokidar-cli \"app/**/*\" \"scripts/**/*\" \"tests/docs-app/integration/**/*\" -c \"bun test ./tests/docs-app/integration\"",
|
|
50
58
|
"test:e2e": "bunx playwright test",
|
|
59
|
+
"test:e2e:ui": "bunx playwright test --ui",
|
|
51
60
|
"docs:dev": "bun run scripts/generate-api-docs.ts && bun run scripts/build-docs-manifest.ts && bun run scripts/build-search-index.ts && bun run scripts/build-blog-manifest.ts && bun run scripts/build-sitemap.ts && bun bin/rbssr.ts dev",
|
|
52
61
|
"docs:build": "bun run scripts/docs-build.ts",
|
|
53
62
|
"docs:check": "bun run scripts/check-docs.ts",
|
|
@@ -65,9 +74,5 @@
|
|
|
65
74
|
"react": "^19",
|
|
66
75
|
"react-dom": "^19",
|
|
67
76
|
"typescript": "^5.9.2"
|
|
68
|
-
},
|
|
69
|
-
"dependencies": {
|
|
70
|
-
"@datadog/browser-rum": "^6.28.1",
|
|
71
|
-
"@datadog/browser-rum-react": "^6.28.1"
|
|
72
77
|
}
|
|
73
78
|
}
|