Open
Description
- Rollup Plugin Name: Typescript
- Rollup Plugin Version: 12.1.3
- Rollup Version: 4.43.0
- Operating System (or Browser): Linux 6.15.1-arch1-2,
- Node Version: 24.2.0
- Link to reproduction (
⚠️ read below): https://stackblitz.com/edit/rollup-repro-sbbqvy8r?file=rollup.config.js
Expected Behavior
On plugin-typescript
12.1.2 and below, it was possible to use a plugin with resolveId
and declare module "xyz" { ... }
to load modules outside the standard resolution path (for instance, loading generated sources from elsewhere).
For instance, with the following in your rollup.config.js
.
plugins: [
typescript(),
{
name: "custom",
async resolveId(source) {
if (source === "test-module") return path.resolve("generated/test-module.js")
}
}
]
and the following declaration file:
declare module "test-module" {
export const sayHello: () => void;
}
Then it was possible to import "test-module"
from a Typescript file.
Actual Behavior
This no longer works under the recent 12.1.3 release (I assume this is introduced by #1653), failing with the following:
(!) [plugin typescript] src/index.ts (1:26): @rollup/plugin-typescript TS2307: Cannot find module 'test-module' or its corresponding type declarations.
rollup-demo/src/index.ts:1:26
1 import { sayHello } from "test-module";
~~~~~~~~~~~~~
Additional Information
It's possible I'm doing something utterly unspeakable and unsupported! I wasn't sure if this was an accidental breaking change or just Hyrum's law in action, so felt worth reporting.
Metadata
Metadata
Assignees
Labels
No labels