Skip to content

traceDeps fails to trace nested dependencies in .pnpm folder #4372

Description

@katywings

Environment

Versions

  • node: v24.13.0
  • nitro: 3.0.260610-beta
  • pnpm: 10.30

Config

{
  traceDeps: ["sharp", "bcrypt"]
}

Reproduction

  1. Use pnpm as package manager
  2. Install and import dependency xyz that internally depends on a non-bundleable dependency such as sharp or bcrypt
  3. Add sharp / bcrypt to nitro's traceDeps array
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions