Skip to content

[Bug]: Rolldown tsconfig resolver cannot resolve package.json imports in extends (node subpath imports) #9611

@sanperrier

Description

@sanperrier

Reproduction link or steps

Rolldown tsconfig resolver cannot resolve package.json "imports" in "extends"

npx rolldown --input index.ts --tsconfig tsconfig.json --format es --file index.mjs

with tsconfig.json like this:

{
    "extends": "#base-tsconfig-json",
    "compilerOptions": {
        "outDir": "./dist",
        "declaration": true
    }
}

and with package.json like this:

{
    "imports": {
        "#base-tsconfig-json": "./common.tsconfig.json"
    },
}

fails with error:

 ERROR  [UNHANDLEABLE_ERROR] Something went wrong inside rolldown, please report this problem at https://github.com/rolldown/rolldown/issues.
Tsconfig not found #base-tsconfig-json

Caused by:
    Failed to resolve tsconfig option: /workspaces/rolldown-tsconfig-resolver-imports-issue-repro/packages/simpler/tsconfig.json

Minimal repro:

├── index.js
├── common.tsconfig.json
├── tsconfig.json
└── package.json

common.tsconfig.json

{
    "compilerOptions": {
        "target": "es2022",
        "module": "esnext",
        "diagnostics": true
    }
}

tsconfig.json

{
    "extends": "#base-tsconfig-json",
    "compilerOptions": {
        "outDir": "./dist",
        "declaration": true
    }
}

package.json

{
    "name": "simpler",
    "version": "0.0.1",
    "private": "true",
    "type": "module",
    "imports": {
        "#base-tsconfig-json": "./common.tsconfig.json"
    },
    "scripts": {
        "build": "npx rolldown --input index.ts --tsconfig tsconfig.json --format es --dir dist"
    },
    "devDependencies": {
        "rolldown": "^1.0.3",
        "typescript": "^6.0.3"
    }
}

index.ts

import cfg from '#base-tsconfig-json' with { type: 'json' };

console.log(import.meta.resolve('#base-tsconfig-json'), cfg);

repo with reproduction is here: https://github.com/sanperrier/rolldown-tsconfig-resolver-imports-issue-repro (in npm workspaces monorepo)
or more simplier repro: https://github.com/sanperrier/rolldown-tsconfig-resolver-imports-issue-repro/tree/main/packages/simpler

What is expected?

Rolldown should resolve extends using TypeScript-compatible semantics for package import specifiers, or at least not fail when TypeScript itself resolves the same config.

At minimum, this should probably be documented as an unsupported extends form.

In repro npx rolldown --input index.ts --tsconfig tsconfig.json --format es --dir dist should build it without problems

<DIR>/index.js  chunk │ size: 0.19 kB

✔ rolldown v1.0.3 Finished in 22.27 ms

What is actually happening?

 ERROR  [UNHANDLEABLE_ERROR] Something went wrong inside rolldown, please report this problem at https://github.com/rolldown/rolldown/issues.
Tsconfig not found #base-tsconfig-json

Caused by:
    Failed to resolve tsconfig option: /workspaces/rolldown-tsconfig-resolver-imports-issue-repro/packages/simpler/tsconfig.json

System Info

System:
    OS: Linux 6.8 Ubuntu 24.04.4 LTS 24.04.4 LTS (Noble Numbat)
    CPU: (2) x64 AMD EPYC 7763 64-Core Processor
    Memory: 5.14 GB / 7.76 GB
    Container: Yes
    Shell: 5.2.21 - /bin/bash
  Binaries:
    Node: 24.14.0 - /home/codespace/nvm/current/bin/node
    Yarn: 1.22.22 - /home/codespace/nvm/current/bin/yarn
    npm: 11.9.0 - /home/codespace/nvm/current/bin/npm
    pnpm: 10.32.1 - /home/codespace/nvm/current/bin/pnpm

Any additional comments?

I'm using package.json#imports in monorepos to reuse common configs (like oxlint.config.ts, oxfmt.config.ts, etc, and common settings for TS).
It allows to avoid fragile deep relative paths like "extends": "../../../../tsconfig.json".

TypeScript and Node already resolve this pattern correctly, but Rolldown currently forces to use fragile relative paths with tons of ../ or to manually copy configs in every package.
That is not critical, but very irritating.

Metadata

Metadata

Assignees

Type

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions