-
Notifications
You must be signed in to change notification settings - Fork 259
Expand file tree
/
Copy pathpreload.ts
More file actions
33 lines (30 loc) · 963 Bytes
/
preload.ts
File metadata and controls
33 lines (30 loc) · 963 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
* Bun preload plugin for running Claude Code from source.
*
* Handles two compile-time features that don't exist at runtime:
* 1. bun:bundle - Feature flag system (DCE at build time)
* 2. MACRO.* - Build-time constants inlined by the bundler
*/
import { plugin } from "bun";
// Shim bun:bundle's feature() to return false for all feature flags.
// In the official build, feature() is evaluated at compile time and
// dead code is eliminated. At runtime, we just disable all gates.
plugin({
name: "bun-bundle-shim",
setup(build) {
build.module("bun:bundle", () => {
return {
exports: {
feature: (_name: string) => false,
},
loader: "object",
};
});
},
});
// MACRO.* globals are inlined at build time by Bun's bundler.
// We define them as runtime globals instead.
(globalThis as any).MACRO = {
VERSION: "2.1.88",
ISSUES_EXPLAINER: "https://github.com/anthropics/claude-code/issues",
};