Hooks - #742
Conversation
|
Very excited to be able to handle https://github.com/tivac/modular-css/blob/master/src/rollup.js#L61-L84 in a more sensible way! |
|
@Rich-Harris What's the intended difference between It makes sense to me that Should it stick new properties onto the For context, I'm trying to update the Once we've got it hashed out I can update the wiki page as well. |
|
I don't see a sense in onwrite hook which will never be called with custom writing on disk. Ongenerate will be called in any case. |
|
WIP usage of After thinking about it more I'm with @TrySound, I don't see an obvious use for If there's a standardized way to return data that the user can access from |
|
Yeah, I see where you're coming from.
Any thoughts on what that should look like? I'm reluctant to make |
|
Could the signature of plugin.ongenerate( assign({
bundle: result
}, options ), rendered);so that the plugin's So ongenerate: function(options, rendered) {
// processor.output() returns a promise, but that isn't the end of the world
rendered.css = processor.output();
},
onwrite: function(options, rendered) {
return rendered.css.then(function(result) {
// write to disk blah blah
});
}Rollup's Thoughts? |
This implements hooks as discussed in #353, with a couple of differences – the result of
bundle.generate(...)is unchanged, andongeneratehooks can't do anything asynchronously (well, they can, but Rollup won't wait for them).The
onwritehook can return a promise. Both it andongenerateare passed a copy of theoptionsobject with an additionalbundleproperty (the same object thatrollup.rollup(...)resolves with).onwritehandlers are called in sequence, not in parallel.I'm a little unsure about the naming of
onwrite, since it's weird for an event handler to be asynchronous. Am open to alternative suggestions.Feedback welcome!