Add some nice warnings if plugins happen to return promises instead of sync values. #6818
+78
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This does nothing for current users. The intention with this is just a bit of future-proofing. I think at some point we'll want to add support for plugins that are async, either as a top-level promise-returning function like an
async function(){}
, or with async handler functions of likepre
,post
,parserOverride
, orgeneratorOverride
.This PR does 2 things:
api.async()
function that would allow a plugin to check if async logic is allowed in plugins. Where in the future it might returntrue
if used via a Babel transform that allows async logic, liketransform("", () => {})
.I'm imagining that in the future we might for instance have users doing
which is certainly just a guess, but at least if we do go that route, plugins could rely on it being there in early 7.x versions too.