unjs / nitro

Next Generation Server Toolkit. Create web servers with everything you need and deploy them wherever you prefer.
https://nitro.unjs.io
MIT License
5.89k stars 496 forks source link

Config resolvers assume files in same directory #2618

Open Llois41 opened 2 months ago

Llois41 commented 2 months ago

Environment

Nitro: 2.9.7 Node: 20.15.1

Reproduction

Build nitro app using yarn and nodeLinker: pnpm

Describe the bug

When building my app, the import '#internal/nitro/virtual/polyfill' statement will try to set some aliases, e.g. https://github.com/unjs/nitro/blob/eaffb9a62ca3aec702c11c6a5373a39882652a05/src/core/config/resolvers/fetch.ts#L16

Rollup (via Node's readFile) will then try to open this file with the given relative path. Using yarn and nodeLinker: pnpm will not place the actual file in the same node_modules folder but instead in the top-level one.

Maybe nitropack should resolve these dependencies using import.meta.resolve or require.resolve instead of letting rollup resolve it relative to the package to be bundled.

Additional context

No response

Logs

No response