@bractjs/bractjs 0.1.11 → 0.1.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/bin/cli.ts +3 -0
- package/package.json +1 -1
- package/src/client/ClientRouter.tsx +4 -1
- package/src/server/serve.ts +19 -0
package/bin/cli.ts
CHANGED
|
@@ -64,6 +64,9 @@ switch (command) {
|
|
|
64
64
|
break;
|
|
65
65
|
|
|
66
66
|
case "dev":
|
|
67
|
+
// Ensure dev-only handlers gated by isExplicitDev() (e.g. /_hmr/module,
|
|
68
|
+
// /_bractjs/devtools.js) are reachable when the user hasn't set NODE_ENV.
|
|
69
|
+
if (!process.env.NODE_ENV) process.env.NODE_ENV = "development";
|
|
67
70
|
await import("../src/dev/server.ts");
|
|
68
71
|
break;
|
|
69
72
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bractjs/bractjs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"description": "Production-grade SSR framework for Bun + React 19. File-based routing, streaming SSR, server actions, typed routes.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/bractjs/bractjs#readme",
|
|
@@ -155,7 +155,10 @@ export function ClientRouter({ children, initialData, initialModule = null }: Cl
|
|
|
155
155
|
// Update DevTools state (dev-only — no-op in prod since the import fails).
|
|
156
156
|
const w = window as unknown as { __BRACT_DEV__?: boolean };
|
|
157
157
|
if (w.__BRACT_DEV__ === true) {
|
|
158
|
-
|
|
158
|
+
// Use the dev-only HTTP endpoint (registered in serve.ts) rather than
|
|
159
|
+
// a relative source-path import — Bun preserves dynamic-import paths
|
|
160
|
+
// as runtime URLs, and a relative .ts path 404s in the browser.
|
|
161
|
+
void import(/* @vite-ignore */ "/_bractjs/devtools.js").then(({ updateDevtoolsState }) => {
|
|
159
162
|
updateDevtoolsState({
|
|
160
163
|
route: toPathname,
|
|
161
164
|
loaderData: data,
|
package/src/server/serve.ts
CHANGED
|
@@ -95,6 +95,25 @@ export function buildFetchHandler(config: Partial<BractJSConfig>) {
|
|
|
95
95
|
return handleHmrModuleRequest(url, appDir);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
// Dev-only: serve the DevTools panel module imported by hmr-client.
|
|
99
|
+
// SECURITY(high): gated by isExplicitDev() so production never compiles
|
|
100
|
+
// and ships package internals as JS.
|
|
101
|
+
if (isExplicitDev() && pathname === "/_bractjs/devtools.js") {
|
|
102
|
+
const devtoolsEntry = resolve(import.meta.dir, "../dev/devtools.ts");
|
|
103
|
+
const built = await Bun.build({
|
|
104
|
+
entrypoints: [devtoolsEntry],
|
|
105
|
+
target: "browser",
|
|
106
|
+
minify: false,
|
|
107
|
+
sourcemap: "inline",
|
|
108
|
+
});
|
|
109
|
+
if (!built.success || built.outputs.length === 0) {
|
|
110
|
+
return new Response("DevTools build failed", { status: 500 });
|
|
111
|
+
}
|
|
112
|
+
return new Response(await built.outputs[0].text(), {
|
|
113
|
+
headers: { "Content-Type": "text/javascript", "Cache-Control": "no-store" },
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
98
117
|
// Typed API routes (registered via bract.route())
|
|
99
118
|
if (pathname.startsWith("/api")) {
|
|
100
119
|
const { handleApiRequest } = await import("./api-route.ts");
|