Skip to content

Commit 22d9e46

Browse files
MarcosBrendonDePaulaclaude
andcommitted
fix: add postinstall patch for @fluxstack/live bun export condition
The published @fluxstack/live packages (v0.3.0) include a "bun" export condition pointing to ./src/index.ts, but the npm tarball only ships dist/. On Linux, Bun's bundler strictly follows the "bun" condition and fails with "Could not resolve" because src/ doesn't exist. This adds a postinstall script that strips the "bun" condition from package exports, forcing Bun to fall back to the "import" condition (./dist/index.js) which works correctly on all platforms. TODO: Remove after publishing @fluxstack/live >= 0.3.1 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent e768155 commit 22d9e46

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"cli": "bun run core/cli/index.ts",
3737
"make:component": "bun run core/cli/index.ts make:component",
3838
"sync-version": "bun run core/utils/sync-version.ts",
39+
"postinstall": "bun run scripts/patch-live-exports.ts",
3940
"test": "vitest",
4041
"test:ui": "vitest --ui",
4142
"test:coverage": "vitest run --coverage",

scripts/patch-live-exports.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* Temporary postinstall patch for @fluxstack/live packages.
3+
*
4+
* The published packages (v0.3.0) include a "bun" export condition pointing to
5+
* ./src/index.ts, but the npm tarball only ships dist/. On Linux, Bun's bundler
6+
* fails to resolve the package because src/ doesn't exist.
7+
*
8+
* This script removes the "bun" condition from exports so Bun falls back to
9+
* the "import" condition (./dist/index.js) which works correctly.
10+
*
11+
* TODO: Remove this script after publishing @fluxstack/live >= 0.3.1
12+
*/
13+
import { readFileSync, writeFileSync, existsSync } from "fs"
14+
import { join } from "path"
15+
16+
const packages = [
17+
"node_modules/@fluxstack/live/package.json",
18+
"node_modules/@fluxstack/live-client/package.json",
19+
"node_modules/@fluxstack/live-react/package.json",
20+
"node_modules/@fluxstack/live-elysia/package.json",
21+
]
22+
23+
for (const pkgPath of packages) {
24+
const fullPath = join(process.cwd(), pkgPath)
25+
if (!existsSync(fullPath)) continue
26+
27+
try {
28+
const pkg = JSON.parse(readFileSync(fullPath, "utf-8"))
29+
let patched = false
30+
31+
if (pkg.exports) {
32+
for (const [key, value] of Object.entries(pkg.exports)) {
33+
if (typeof value === "object" && value !== null && "bun" in value) {
34+
delete (value as Record<string, unknown>).bun
35+
patched = true
36+
}
37+
}
38+
}
39+
40+
if (patched) {
41+
writeFileSync(fullPath, JSON.stringify(pkg, null, 2) + "\n")
42+
console.log(`Patched exports in ${pkgPath}`)
43+
}
44+
} catch {
45+
// Ignore errors - package might not be installed yet
46+
}
47+
}

0 commit comments

Comments
 (0)