karma-rollup-preprocessor icon indicating copy to clipboard operation
karma-rollup-preprocessor copied to clipboard

Watch mode overwrites the test file

Open jiripudil opened this issue 3 years ago • 4 comments

Hi, I've been using this awesome package for some time to my satisfaction, but now I've stumbled upon an issue with the latest version. It manifests in this repo: https://github.com/naja-js/naja. If I run yarn run test locally, it runs karma in watch mode (with autoWatch: true, singleRun: false), the tests get stuck in an endless loop where it keeps detecting a change in the tests/index.js. When I manage to exit the loop, the tests/index.js is indeed modified – it is either empty, or it contains the generated bundle.

Downgrading this package to 7.0.7 helps, so I'm guessing it's somehow connected to #72 / #74. Is this a bug? Or should I change the configuration in some way? Thanks for your help!

jiripudil avatar Feb 15 '22 10:02 jiripudil

Hey! I wanted to leave a note that I was seeing the same behavior of an endless loop of re-writing and watching the tests file when autoWatch: true, singleRun: false. I also implemented a quick fix of downgrading to 7.0.7 and am investigating locally.

mgoetzke avatar Feb 15 '22 15:02 mgoetzke

@jlmakes any chance you could have a look please? :)

XhmikosR avatar Mar 16 '22 11:03 XhmikosR

We hit this issue as well and downgrading resolved the problem. (Internal project, no link to share)

rwaldron avatar Mar 17 '22 20:03 rwaldron

I see, that's no good! Roping @YonatanKra into this conversation. Let's see if we can get this fixed, thanks for the report.

jlmakes avatar Mar 30 '22 05:03 jlmakes

I've looked into this one and here is what I found.

  • The changes made for #72 introduced this issue.

  • rollup.watch is used instead of rollup.rollup. rollup.watch also writes directly to the file system, resulting in this issue.

  • I think that the root cause of #72 is in @rollup/plugin-typescript when using rollup.rollup (i.e. watchMode is false)

  • I created an issue in @rollup/plugin-typescript rollup/plugins#1354

  • I also created a pull request in @rollup/plugin-typescript https://github.com/rollup/plugins/pull/1356.

Once rollup/plugins#1354 is fixed and released, the fix for #72 could be reverted and everything should work as expected when using the official Typescript plugin.

gbaron avatar Nov 27 '22 13:11 gbaron

The pull request for @rollup/plugin-typescript was approved and released as part of version 10.0.1.

I created a pull request #76 to revert the changes that introduced this issue and added a basic test case.

@jlmakes

gbaron avatar Nov 28 '22 19:11 gbaron

@jlmakes LMK if you think the change can be integrated

gbaron avatar Dec 05 '22 18:12 gbaron

@jlmakes would you consider releasing a new version with this fix? The current v7.0.8 has this issue...

gbaron avatar Dec 13 '22 13:12 gbaron

@jlmakes friendly ping!

XhmikosR avatar Mar 14 '23 07:03 XhmikosR