@bractjs/bractjs 0.1.24 → 0.1.25
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/package.json +1 -1
- package/src/build/env-plugin.ts +13 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bractjs/bractjs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.25",
|
|
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",
|
package/src/build/env-plugin.ts
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import type { BunPlugin } from "bun";
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
3
|
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
|
|
4
|
+
// Lazy: this module is re-exported from the package barrel, so it may be
|
|
5
|
+
// statically pulled into client bundles. `import.meta.dir` is undefined in the
|
|
6
|
+
// browser, and a top-level `resolve(import.meta.dir, "..")` would throw
|
|
7
|
+
// "Path must be a string" at module load — before any plugin is even invoked.
|
|
8
|
+
// Defer the resolve until a plugin actually runs (always server-side).
|
|
9
|
+
let frameworkSrcRoot: string | undefined;
|
|
10
|
+
function getFrameworkSrcRoot(): string {
|
|
11
|
+
if (frameworkSrcRoot === undefined) {
|
|
12
|
+
frameworkSrcRoot = resolve(import.meta.dir, "..");
|
|
13
|
+
}
|
|
14
|
+
return frameworkSrcRoot;
|
|
15
|
+
}
|
|
8
16
|
|
|
9
17
|
// ── Server-only import guard ───────────────────────────────────────────────
|
|
10
18
|
|
|
@@ -56,7 +64,7 @@ export function clientEnvPlugin(
|
|
|
56
64
|
// the client. Without this guard, linking the framework via `file:`
|
|
57
65
|
// produces a build that fails to parse its own source.
|
|
58
66
|
if (args.path.includes("/node_modules/")) return undefined;
|
|
59
|
-
if (args.path.startsWith(
|
|
67
|
+
if (args.path.startsWith(getFrameworkSrcRoot())) return undefined;
|
|
60
68
|
const src = await Bun.file(args.path).text();
|
|
61
69
|
// SECURITY(medium): textual regex replace runs over the whole source,
|
|
62
70
|
// including inside string literals and comments. A bare `process.env.X`
|