Closed
Description
- Rollup Plugin Name: @rollup/plugin-typescript
- Rollup Plugin Version: 11.1.5
- Rollup Version: 4.9.0
- Operating System (or Browser): Ubuntu
- Node Version: 16.20
- Link to reproduction: https://github.com/ericmorand/rollup-plugin-typescript-issue-2
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.ts
orsrc/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:
$ tsc src/index.ts
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.