@bractjs/bractjs 0.1.13 → 0.1.15

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 CHANGED
@@ -71,12 +71,18 @@ switch (command) {
71
71
  break;
72
72
 
73
73
  case "build": {
74
+ // Force production so React's conditional exports resolve to the prod
75
+ // server build (react-dom/server.bun production) instead of the dev one.
76
+ if (!process.env.NODE_ENV) process.env.NODE_ENV = "production";
74
77
  const { runBuild } = await import("../src/build/bundler.ts");
75
78
  await runBuild({ port: 3000, appDir: "./app", publicDir: "./public", buildDir: "./build", manifest: { clientEntry: "", routes: {} } });
76
79
  break;
77
80
  }
78
81
 
79
82
  case "start": {
83
+ // Default to production so SSR-side gates (e.g. <LiveReload/>) emit prod
84
+ // output. Users can still override with `NODE_ENV=staging bractjs start`.
85
+ if (!process.env.NODE_ENV) process.env.NODE_ENV = "production";
80
86
  const { createServer } = await import("../src/server/serve.ts");
81
87
  createServer({ port: 3000, buildDir: "./build" });
82
88
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bractjs/bractjs",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
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",
@@ -33,6 +33,12 @@ export async function runBuild(config: BractJSConfig): Promise<void> {
33
33
  target: "bun",
34
34
  outdir: "build/server",
35
35
  sourcemap: config.sourcemap ?? "external",
36
+ // Force production so Bun picks the `jsx`/`jsxs` runtime instead of
37
+ // `jsxDEV` — `jsxDEV` only exists on react/jsx-dev-runtime, which is a
38
+ // no-op when bundled under NODE_ENV=production, leaving the call site
39
+ // calling an undefined function. Same fix applied to the client bundle
40
+ // implicitly via buildDefines().
41
+ define: { "process.env.NODE_ENV": JSON.stringify("production") },
36
42
  plugins: [useClientStubPlugin],
37
43
  });
38
44
  if (!serverResult.success) throw new AggregateError(serverResult.logs, "Server build failed");
@@ -62,7 +68,11 @@ export async function runBuild(config: BractJSConfig): Promise<void> {
62
68
  const rootBase = basename(rootFilePath, extname(rootFilePath)); // "root"
63
69
 
64
70
  for (const artifact of clientResult.outputs) {
65
- if (artifact.kind !== "chunk" && artifact.kind !== "entry-point") continue;
71
+ // Only rename entry points. Bun's split chunks (kind === "chunk") already
72
+ // have content-hashed basenames (e.g. chunk-189z661a.js); renaming them
73
+ // would break sibling import refs, which Bun bakes in at bundle time and
74
+ // does NOT rewrite after rename.
75
+ if (artifact.kind !== "entry-point") continue;
66
76
  const hash = await contentHash(artifact.path);
67
77
  const ext = artifact.path.slice(artifact.path.lastIndexOf("."));
68
78
  const base = artifact.path.slice(0, artifact.path.lastIndexOf("."));
@@ -78,9 +88,9 @@ export async function runBuild(config: BractJSConfig): Promise<void> {
78
88
  const rel = absPath.startsWith(outdirAbs + "/") ? absPath.slice(outdirAbs.length + 1) : basename(artifact.path);
79
89
  const outBase = basename(artifact.path, extname(artifact.path));
80
90
 
81
- if (artifact.kind === "entry-point" && outBase === entryBase) {
91
+ if (outBase === entryBase) {
82
92
  clientEntry = publicPath;
83
- } else if (artifact.kind === "entry-point" && outBase === rootBase) {
93
+ } else if (outBase === rootBase) {
84
94
  rootChunk = publicPath;
85
95
  } else {
86
96
  const matched = routes.find((r) => {
@@ -4,8 +4,8 @@
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "dev": "bractjs dev",
7
- "build": "bractjs build",
8
- "start": "bractjs start"
7
+ "build": "NODE_ENV=production bractjs build",
8
+ "start": "NODE_ENV=production bractjs start"
9
9
  },
10
10
  "dependencies": {
11
11
  "@bractjs/bractjs": "latest",
@@ -0,0 +1,20 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "lib": ["ESNext", "DOM", "DOM.Iterable"],
7
+ "jsx": "react-jsx",
8
+ "jsxImportSource": "react",
9
+ "strict": true,
10
+ "esModuleInterop": true,
11
+ "skipLibCheck": true,
12
+ "allowImportingTsExtensions": true,
13
+ "verbatimModuleSyntax": true,
14
+ "noEmit": true,
15
+ "resolveJsonModule": true,
16
+ "isolatedModules": true,
17
+ "types": ["bun-types", "react", "react-dom"]
18
+ },
19
+ "include": ["app/**/*.ts", "app/**/*.tsx", "bractjs.config.ts"]
20
+ }