Skip to content

Add dependency resolution and ordering for transformers #219

@schlessera

Description

@schlessera

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions