Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TypeScript] TypeScript plugin seems to be watching files and trigerring builds by itself #1656

Open
ericmorand opened this issue Dec 26, 2023 · 0 comments

Comments

@ericmorand
Copy link

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:

const baseHost = ts.createWatchCompilerHost(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant