Skip to content

Commit e1bff79

Browse files
committed
perf(deps): share dependencies across checkouts via the bun global store
The isolated linker was already in use, but without the global store each checkout copied a full dependency tree into its own node_modules/.bun. Anyone keeping several worktrees open paid roughly 2G per checkout for identical packages. Enabling globalStore installs each package once into a shared store and symlinks it in. Measured across a whole checkout: 2098M drops to 32M. The store resolves dependencies through symlinks whose real path lies outside the project, and TypeScript follows symlinks by default. A dependency re-exporting React's own types, such as LucideProps extending SVGProps<SVGSVGElement>, can no longer reach @types/react by walking up from the store path, so its React-contributed props disappear. Pinning the react and react-dom specifiers to the workspace copy fixes it for the whole program, including inside dependency .d.ts files. claw-app had no paths block of its own and inherited one through extends. Since a paths block replaces rather than merges, the generated wxt aliases are restated there alongside the redirect. Verified by full typecheck in three configurations, all producing an identical 39 findings: no store, no paths (before this change) store + paths (local development) paths only, no store (CI on the pinned bun, which ignores globalStore)
1 parent 195b15c commit e1bff79

3 files changed

Lines changed: 30 additions & 1 deletion

File tree

packages/browseros-agent/apps/app/tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"noUncheckedIndexedAccess": false,
99
"verbatimModuleSyntax": false,
1010
"paths": {
11+
"react": ["./node_modules/@types/react"],
12+
"react-dom": ["./node_modules/@types/react-dom"],
1113
"@/*": ["./*"],
1214
"@browseros/shared/*": ["../../packages/shared/src/*"]
1315
},

packages/browseros-agent/apps/claw-app/tsconfig.json

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,27 @@
55
"allowImportingTsExtensions": true,
66
"jsx": "react-jsx",
77
// wxt 0.21's generated base turns on noUncheckedIndexedAccess; opt back out until the codebase adopts it deliberately.
8-
"noUncheckedIndexedAccess": false
8+
"noUncheckedIndexedAccess": false,
9+
// The global virtual store resolves dependencies through symlinks into a
10+
// store outside the project, and TypeScript follows those to their real
11+
// path. A dependency re-exporting React's own types (LucideProps extending
12+
// SVGProps) can no longer reach @types/react by walking up from there, so
13+
// pin the specifier to the workspace copy.
14+
//
15+
// A paths block replaces rather than merges with the one inherited from
16+
// .wxt/tsconfig.json, so the generated aliases are repeated here, rebased
17+
// from .wxt/ to this directory.
18+
"paths": {
19+
"react": ["./node_modules/@types/react"],
20+
"react-dom": ["./node_modules/@types/react-dom"],
21+
"@": ["."],
22+
"@/*": ["./*"],
23+
"~": ["."],
24+
"~/*": ["./*"],
25+
"@@": ["."],
26+
"@@/*": ["./*"],
27+
"~~": ["."],
28+
"~~/*": ["./*"]
29+
}
930
}
1031
}

packages/browseros-agent/bunfig.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ timeout = 30000
1414
[install]
1515
linker = "isolated"
1616

17+
# Global virtual store: install each package once into a shared store and
18+
# symlink it in, instead of copying a full dependency tree per checkout. With
19+
# many worktrees open this is the difference between ~2G each and ~32M each.
20+
# Requires the isolated linker above. https://bun.com/docs/pm/global-store
21+
globalStore = true
22+
1723
# Do not install dependency versions published less than 3 days ago: a brand
1824
# new release has not had time to be flagged if it is malicious or broken.
1925
# Applies to fresh resolutions (bun add / non-frozen bun install). CI runs

0 commit comments

Comments
 (0)