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

Make options hook async #3660

Merged
merged 1 commit into from Jul 5, 2020
Merged

Make options hook async #3660

merged 1 commit into from Jul 5, 2020

Conversation

TomerAberbach
Copy link
Contributor

@TomerAberbach TomerAberbach commented Jul 4, 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: Closes #3397

Description

Makes the options plugin hook async, sequential instead of sync, sequential so that asynchronous work can be done in the options hook. This is useful because sometimes plugins need to modify the input options, but need to do some asynchronous work to get the necessary information to modify the input options (e.g. access the file system, make a network request, #3397, etc.)

options plugin hooks written before this change will still work because the next options hook in a chain of options hooks is always passed the resolved value of the previous options hook's promise (or just the value of the hook didn't return a promise). I can't think of why an options plugin hook would have been written before this change that returns a promise and expects the next promise hook to receive the unwrapped promise.

@codecov
Copy link

codecov bot commented Jul 4, 2020

Codecov Report

Merging #3660 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3660   +/-   ##
=======================================
  Coverage   96.70%   96.70%           
=======================================
  Files         183      183           
  Lines        6287     6287           
  Branches     1832     1832           
=======================================
  Hits         6080     6080           
  Misses        105      105           
  Partials      102      102           
Impacted Files Coverage Δ
src/rollup/rollup.ts 100.00% <100.00%> (ø)

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 0d5a017...2dc6bb4. Read the comment docs.

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.

Thanks, really nice work, I have nothing to add here! Will release this right away.

@lukastaegert lukastaegert merged commit 1fa9374 into rollup:master Jul 5, 2020
@lukastaegert
Copy link
Member

I can't think of why an options plugin hook would have been written before this change that returns a promise and expects the next promise hook to receive the unwrapped promise

If you mean that the next hook would receive the promise as an argument, no, that is definitely not something we would do as it would also differ in behaviour form all other async hooks. The idea is always that you can write something completely sync in an async hook. transform would be an example where a value is reduced by async hooks that also works like you implemented it.

@Amareis Amareis mentioned this pull request Nov 1, 2020
4 tasks
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.

async options hook
2 participants