Expected Behavior
In the reproduction repository, we find 3 TS files:
src/index.ts, the entry point
src/valid.ts, imported by the entry point
src/invalid.ts, containing non valid TypeScript syntax and imported by neither src/index.ts or src/valid.ts
When executing rollup on src/index.ts, the build should be successful since the src/invalid.ts file is not imported.
Actual Behavior
The build is unsuccessful, and the error suggests that src/invalid.ts is syntax-checked by the plugin even though it is not part of the dependency graph of the entry point:
$ npx rollup -i src/index.ts -p @rollup/plugin-typescript
npm WARN cli npm v10.2.4 does not support Node.js v16.20.2. This version of npm supports the following node versions: `^18.17.0 || >=20.5.0`. You can find the latest version at https://nodejs.org/.
src/index.ts → stdout...
var foo = 5;
console.log(foo);
(!) Plugin typescript: @rollup/plugin-typescript TS2304: Cannot find name 'foo'.
src/invalid.ts: (1:1)
1 foo
~~~
Additional Information
Note that the behaviour of tsc is correct in that regard:
No error is emitted and src/index.ts and src/valid.ts are successfully compiled.
So the error is coming from the plugin, not from the TypeScript compiler.
Expected Behavior
In the reproduction repository, we find 3 TS files:
src/index.ts, the entry pointsrc/valid.ts, imported by the entry pointsrc/invalid.ts, containing non valid TypeScript syntax and imported by neithersrc/index.tsorsrc/valid.tsWhen executing rollup on
src/index.ts, the build should be successful since thesrc/invalid.tsfile is not imported.Actual Behavior
The build is unsuccessful, and the error suggests that
src/invalid.tsis syntax-checked by the plugin even though it is not part of the dependency graph of the entry point:Additional Information
Note that the behaviour of
tscis correct in that regard:No error is emitted and
src/index.tsandsrc/valid.tsare successfully compiled.So the error is coming from the plugin, not from the TypeScript compiler.