rollup-plugin-rust icon indicating copy to clipboard operation
rollup-plugin-rust copied to clipboard

Rust compilation output cleared too quikly in watch mode

Open BenoitZugmeyer opened this issue 3 years ago • 2 comments

I have a small issue when using this plugin with rollup in watch mode. When doing a rust file modification, it seems rollup is bundles the project in two pass, clearing the Rust compilation warnings right after the Rust compilation finishes.

It would be great if rollup could bundle everything in one pass, keeping the Rust compilation visible until another file is modified.

Minimal project to reproduce

Screencast: asciicast

BenoitZugmeyer avatar Nov 07 '20 15:11 BenoitZugmeyer

After investigation, it seems that this issue is caused by macOS FSEvent notifying of a change on target/wasm-pack/xxx/index.js even if this file is being watched after the change.

In fact, I can even reproduce in the shell with this command:

wasm-pack build --dev --out-name index --out-dir ./out; fswatch ./out/index.js

fswatch will notify about an update of the watched file even if it is started after watch-pack finishes. Any idea what would cause this?

Because we don't really care about this file being watched, my workaround is to use the Rollup watch.exclude option like so:

  watch: {
    exclude: 'target/wasm-pack/xxx/index.js'
  }

This is not ideal, but it does the job.

BenoitZugmeyer avatar Nov 11 '20 17:11 BenoitZugmeyer

@BenoitZugmeyer Thanks for the report, and the investigation. FS events are really wacky on OSX in general, so it doesn't surprise me that it's having problems.

Let me see if it's possible for the plugin to ignore the target folder.

Pauan avatar Nov 21 '20 06:11 Pauan