implement "nodeLinker": "isolated" in bun install#20440
Conversation
|
Updated 12:23 AM PT - Jul 9th, 2025
❌ @dylan-conway, your commit b01a5f9 has 1 failures in
🧪 To try this PR locally: bunx bun-pr 20440That installs a local version of the PR into your bun-20440 --bun |
| }, | ||
| }; | ||
| } | ||
| }; |
| allocator.free(item.script); | ||
| } | ||
| } | ||
| // pub fn deinit(this: Package.Scripts.List, allocator: std.mem.Allocator) void { |
There was a problem hiding this comment.
Did you mean to comment this out
| @compileError("unexpected path type"); | ||
| } | ||
|
|
||
| const ret = std.c.link(src, dest); |
There was a problem hiding this comment.
ideally we would use the system version of link instead so it would use the linux syscall instead of the link c stdlib function but it's okay
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
"nodeLinker": "isolated""nodeLinker": "isolated" in bun install
|
Going to try this out on canary, does the workspaces.nodeLinker configuration go in the root package.json, or does it go in each app's package.json? |
|
@Sparticuz I think it'll only go in your root package.json, and that {
"type": "module",
"private": true,
"workspaces": {
"nodeLinker": "isolated",
"packages": [
"packages/*",
"apps/*"
]
},
"devDependencies": {
"@types/bun": "latest"
},
"peerDependencies": {
"typescript": "^5"
}
}Just tested it out on my end with a bare-bones project 🎉 for the bun team, for what it's worth npm has an "install-strategy" option they use for their experimental "linked" strategy that aims to produce a similar node_modules directory https://docs.npmjs.com/cli/v11/commands/npm-install#install-strategy I'd like to have this option available in bunfig.toml as well so I can configure this behavior globally |
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
|
I've got a monorepo and am looking into bun support. Shouldn't @tokenizer/inflate, strtok3, token-types, and uint8array-extras be included in my node_modules folder since they are dependencies of file-types in this scenario? {
"name": "dependant-package",
"version": "1.0.0",
"description": "",
"license": "ISC",
"author": "",
"type": "module",
"main": "index.js",
"dependencies": {
"file-type": "^21.0.0"
}
}file-type's package.json ...
"dependencies": {
"@tokenizer/inflate": "^0.2.7",
"strtok3": "^10.2.2",
"token-types": "^6.0.0",
"uint8array-extras": "^1.4.0"
},
"devDependencies": {
"@tokenizer/token": "^0.3.0",
"@types/node": "^22.15.21",
...monotest/packages/dependant-package
total 16K
drwxr-xr-x 3 kyle kyle 4.0K Jul 15 09:13 ./
drwxr-xr-x 3 kyle kyle 4.0K Jul 15 09:06 ../
drwxr-xr-x 2 kyle kyle 4.0K Jul 15 09:13 node_modules/
-rw-r--r-- 1 kyle kyle 0 Jul 15 09:11 index.js
-rw-r--r-- 1 kyle kyle 285 Jul 15 09:11 package.json
packages/dependant-package/node_modules
total 12K
drwxr-xr-x 2 kyle kyle 4.0K Jul 15 09:13 ./
drwxr-xr-x 3 kyle kyle 4.0K Jul 15 09:13 ../
lrwxrwxrwx 1 kyle kyle 66 Jul 15 09:13 file-type -> ../../../node_modules/.bun/file-type\@21.0.0/node_modules/file-type/They are not in file-type's node_modules folder either. dependant-package/node_modules/file-type
total 132K
drwxr-xr-x 2 kyle kyle 4.0K Jul 15 09:13 ./
drwxr-xr-x 4 kyle kyle 4.0K Jul 15 09:13 ../
-rw-r--r-- 2 kyle kyle 11K Jul 11 07:20 core.d.ts
-rw-r--r-- 2 kyle kyle 43K Jul 11 07:20 core.js
-rw-r--r-- 2 kyle kyle 4.9K Jul 11 07:20 index.d.ts
-rw-r--r-- 2 kyle kyle 2.4K Jul 11 07:20 index.js
-rw-r--r-- 2 kyle kyle 1.1K Jul 11 07:20 license
-rw-r--r-- 2 kyle kyle 3.6K Jul 11 07:20 package.json
-rw-r--r-- 2 kyle kyle 33K Jul 11 07:20 readme.md
-rw-r--r-- 2 kyle kyle 6.1K Jul 11 07:20 supported.js
-rw-r--r-- 2 kyle kyle 1.3K Jul 11 07:20 util.js |
|
@Sparticuz transitive dependencies are symlinked to the the package location in
Also note: we are going to change |
|
Hmm, ok, I guess what I'm looking for is 'isolated' + 'nohoist' or something similar that would link the transitive dependencies in a node_modules folder at the package level. Currently, with just isolated, it seems like it (serverless framework) will not package strtok3, etc... because they are not linked within the packages node_modules folder anywhere. Let me know if this is a separate issue, or if this is covered under #20178 |
|
Really enjoying Bun these days, truly a breath of fresh air in the madness. Thanks for the great work everyone! |
|
But it still does not resolve link dependencies like:
Will this be implemented as well? |

What does this PR do?
This PR implements the
"nodeLinker": "isolated"option forbun install, providing a pnpm-style isolated installation mode that prevents phantom dependencies and and enables installing packages in parallel.Key features:
workspaces.nodeLinker: "isolated"configuration in package.jsonnode_modules/.bun/directorynode_modules/<package>to the actual packages in.bun/<package>@<version>/node_modules/<package>Directory structure example:
Configuration: (bunfig.toml)
closes #4274
fixes #5688
closes #1760
How did you verify your code works?
Tests:
@types/*)TODO: many more test