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

feat(watch): add skipWrite option #3454

Merged
merged 5 commits into from Mar 24, 2020

Conversation

lukeed
Copy link
Contributor

@lukeed lukeed commented Mar 21, 2020

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

List any relevant issue numbers: #3225

Description

This change allows programmatic rollup.watch users to opt out of automatic bundle.write calls. This definitely won't be the common use case, but it's been requested (a few times) in the past for certain scenarios.

```
rollup -i input.js -f es -p ./my-plugin.js
```

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, these look to be my editor's auto-trimming

@@ -1096,6 +1096,13 @@ Default: `true`

Whether to clear the screen when a rebuild is triggered.

#### watch.skipWrite
Type: `boolean`<br>
<!-- CLI: `--watch.skipWrite`<br> -->
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This CLI option will work, but I figure it's better not to list it (similar to watch.chokidar) since its application makes zero sense via the CLI layer.

@codecov
Copy link

codecov bot commented Mar 21, 2020

Codecov Report

Merging #3454 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3454      +/-   ##
==========================================
+ Coverage   95.02%   95.02%   +<.01%     
==========================================
  Files         171      171              
  Lines        5851     5852       +1     
  Branches     1726     1727       +1     
==========================================
+ Hits         5560     5561       +1     
  Misses        157      157              
  Partials      134      134
Impacted Files Coverage Δ
src/watch/watch.ts 98.03% <100%> (+0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e9ece1d...d8a2aa7. Read the comment docs.

@@ -174,7 +176,7 @@ export class Task {
return;
}
this.updateWatchedFiles(result);
await Promise.all(this.outputs.map(output => result.write(output)));
this.skipWrite || (await Promise.all(this.outputs.map(output => result.write(output))));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where the new option is applied.

(Not a fan of how the linter formatted it)

Copy link
Member

@lukastaegert lukastaegert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks sensible to me 👍

@timiyay
Copy link
Contributor

timiyay commented Mar 24, 2020

Nice. This skipWrite option will give me a way to deal with Rollup challenge I'm currently facing.

I need to get my hands on the return value from rollup.write when running in watch mode. To do this, I have to listen for BUNDLE_END and call event.result.write. This means I write the bundle to disk twice in quick succession, which feels dirty.

skipWrite would let me take responsibility for calling write() within my event listener, giving me my return value while avoiding the double write.

Is there anything I can do to help get this ready for release?

@lukastaegert lukastaegert merged commit 485700e into rollup:master Mar 24, 2020
@lukeed lukeed deleted the feat/watch-skipwrite branch March 24, 2020 16:01
@lukeed
Copy link
Contributor Author

lukeed commented Mar 24, 2020

Thanks!

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

Successfully merging this pull request may close these issues.

None yet

3 participants