nitrojs / nitrojs/nitro

Config resolvers assume files in same directory

Open
#2,618 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug v2
Dominant language
TypeScript
Stars
11.2k
Forks
899
Avg merge
2d 24m
Merged PRs (30d)
40

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/core/config/resolvers/fetch.ts and trace how the #internal/nitro/virtual/polyfill aliases are passed to Rollup. Reproduce the build with yarn and nodeLinker: pnpm, then verify that dependency paths resolve correctly when files are not in the package's local node_modules directory.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, rollup, typescript
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.