Environment
Versions
- node: v24.13.0
- nitro: 3.0.260610-beta
- pnpm: 10.30
Config
{
traceDeps: ["sharp", "bcrypt"]
}
Reproduction
- Use pnpm as package manager
- Install and import dependency
xyz that internally depends on a non-bundleable dependency such as sharp or bcrypt
- Add
sharp / bcrypt to nitro's traceDeps array
- pnpm build
Describe the bug
Nitro / nf3 fail to trace nested dependencies of dependencies inside node_modules/.pnpm.
Additional context
Resolve Aliasing
I first tried to fix this issue, by adding an alias for the failing traces like below. Said alias fixed the result of rolldown's resolve at
|
let resolved = await this.resolve(id, importer, rOpts); |
, but nitro still failed to trace the dependency later down the line at
|
if (!tryResolve(importId, importer)) { |
.
{
rolldownConfig: {
resolve: {
alias: {
"sharp": "path/to/node_modules/.pnpm/sharp-xyz"
}
}
}
}
Functioning workaround
By adding the failing dependencies to pnpms publicHoistPattern, they will be installed directly in node_modules and can be traced my nitro / nf3
# pnpm-workspace.yaml:
publicHoistPattern:
- "sharp"
- "bcrypt"
Logs
Environment
Versions
Config
Reproduction
xyzthat internally depends on a non-bundleable dependency such assharporbcryptsharp/bcryptto nitro'straceDepsarrayDescribe the bug
Nitro / nf3 fail to trace nested dependencies of dependencies inside
node_modules/.pnpm.Additional context
Resolve Aliasing
I first tried to fix this issue, by adding an alias for the failing traces like below. Said alias fixed the result of rolldown's resolve at
nitro/src/build/plugins/externals.ts
Line 91 in 6de81ee
nitro/src/build/plugins/externals.ts
Line 119 in 6de81ee
Functioning workaround
By adding the failing dependencies to pnpms
publicHoistPattern, they will be installed directly innode_modulesand can be traced my nitro / nf3Logs