-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Hooks #742
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, andongenerate
hooks can't do anything asynchronously (well, they can, but Rollup won't wait for them).The
onwrite
hook can return a promise. Both it andongenerate
are passed a copy of theoptions
object with an additionalbundle
property (the same object thatrollup.rollup(...)
resolves with).onwrite
handlers 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!