[TypeScript] TypeScript plugin seems to be watching files and trigerring builds by itself
- 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-3
Expected Behavior
Whenever src/index.ts changes to an invalid syntax, a single warning is emitted.
Actual Behavior
Whenever the file src/index.ts is changed to an invalid syntax, Rollup emits additionals warning:
- change the file one time, rollup will emit 2 warnings
- change the file one more time, rollup will emit 4 warnings
- change the file one more time, rollup will emit 6 warnings
Basically, rollup emit n warnings, n begin the number of times the file was changed multiplied by 2.
$ node test.mjs
(typescript plugin) src/index.ts (1:9) @rollup/plugin-typescript TS2551: Property 'logs' does not exist on type 'Console'. Did you mean 'log'?
FILE CHANGED src/index.ts
(typescript plugin) src/index.ts (1:9) @rollup/plugin-typescript TS2551: Property 'logss' does not exist on type 'Console'. Did you mean 'log'?
(typescript plugin) src/index.ts (1:9) @rollup/plugin-typescript TS2551: Property 'logss' does not exist on type 'Console'. Did you mean 'log'?
FILE CHANGED src/index.ts
(typescript plugin) src/index.ts (1:9) @rollup/plugin-typescript TS2339: Property 'logsss' does not exist on type 'Console'.
(typescript plugin) src/index.ts (1:9) @rollup/plugin-typescript TS2339: Property 'logsss' does not exist on type 'Console'.
(typescript plugin) src/index.ts (1:9) @rollup/plugin-typescript TS2339: Property 'logsss' does not exist on type 'Console'.
(typescript plugin) src/index.ts (1:9) @rollup/plugin-typescript TS2339: Property 'logsss' does not exist on type 'Console'.
FILE CHANGED src/index.ts
(typescript plugin) src/index.ts (1:9) @rollup/plugin-typescript TS2339: Property 'logssss' does not exist on type 'Console'.
(typescript plugin) src/index.ts (1:9) @rollup/plugin-typescript TS2339: Property 'logssss' does not exist on type 'Console'.
(typescript plugin) src/index.ts (1:9) @rollup/plugin-typescript TS2339: Property 'logssss' does not exist on type 'Console'.
(typescript plugin) src/index.ts (1:9) @rollup/plugin-typescript TS2339: Property 'logssss' does not exist on type 'Console'.
(typescript plugin) src/index.ts (1:9) @rollup/plugin-typescript TS2339: Property 'logssss' does not exist on type 'Console'.
(typescript plugin) src/index.ts (1:9) @rollup/plugin-typescript TS2339: Property 'logssss' does not exist on type 'Console'.
FILE CHANGED src/index.ts
(typescript plugin) src/index.ts (1:9) @rollup/plugin-typescript TS2339: Property 'logsssss' does not exist on type 'Console'.
(typescript plugin) src/index.ts (1:9) @rollup/plugin-typescript TS2339: Property 'logsssss' does not exist on type 'Console'.
(typescript plugin) src/index.ts (1:9) @rollup/plugin-typescript TS2339: Property 'logsssss' does not exist on type 'Console'.
(typescript plugin) src/index.ts (1:9) @rollup/plugin-typescript TS2339: Property 'logsssss' does not exist on type 'Console'.
(typescript plugin) src/index.ts (1:9) @rollup/plugin-typescript TS2339: Property 'logsssss' does not exist on type 'Console'.
(typescript plugin) src/index.ts (1:9) @rollup/plugin-typescript TS2339: Property 'logsssss' does not exist on type 'Console'.
(typescript plugin) src/index.ts (1:9) @rollup/plugin-typescript TS2339: Property 'logsssss' does not exist on type 'Console'.
(typescript plugin) src/index.ts (1:9) @rollup/plugin-typescript TS2339: Property 'logsssss' does not exist on type 'Console'.
Additional Information
This behaviour seems to indicate that the typescript plugin watches the src/index.ts file and triggers a build (from the inner TypeScript compiler) whenever it changes. Since chokidar is also watching the file and triggering the rollup build on change - instantiating another plugin in the process, we end up with the warning being emitted for each previously build trigerred plus the current one.
This seems to be confirmed by the source code of the plugin itself which instantiate a watch compiler host:
https://github.com/rollup/plugins/blob/33174f956304ab4aad4bbaba656f627c31679dc5/packages/typescript/src/watchProgram.ts#L148