-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Labels
Description
Based on a discussion in Slack with @06romix:
What I was thinking of was to have two interfaces with corresponding methods:
interface Requires {
/**
* Return the collection of dependencies that this transformer requires.
*
* @return string[]
*/
public static function requires();
}
interface Provides {
/**
* Return the collection of dependencies that this transformer provides.
*
* @return string[]
*/
public static function provides();
}
The interfaces can be checked with instanceof
without even instantiating the classes. The strings that are returned can be thought of as "tags". So, one or more transformers could require 'ssr'
, and the ServersideRendering
transformer would provide 'ssr'
. If someone replaces that transformer with a custom one, they can still have it provide 'ssr'
to fulfil the dependency chain.
The ordering can then happen based on these tags, provided that it is resolvable. If it is not, there is obviously already a problem that needs to be solved.