Skip to content
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

Run plugins in a predefined order #2085

Open
noahbald opened this issue Nov 7, 2024 · 7 comments
Open

Run plugins in a predefined order #2085

noahbald opened this issue Nov 7, 2024 · 7 comments

Comments

@noahbald
Copy link

noahbald commented Nov 7, 2024

Is your feature request related to a problem? Please describe.
Certain plugins perform better based on a prior plugin. Consider the following
convertPathData, then convertShapeToPath

<!-- before -->
    <rect id="useless" width="0" height="0" fill="#ff0000"/>
<!-- `convertPathData`, then `convertShapeToPath` -->
    <path id="useless" fill="#ff0000" d="M0 0H0V0H0z"/>
<!-- `convertShapeToPath`, then `convertPathData` -->
    <path id="useless" fill="#ff0000" d="M0 0"/>

Describe the solution you'd like
Right now the order plugins are run in is in the order provided in the config, however this can be suboptimal.
For example, it makes sense to run convertShapeToPath before convertPathData.

Describe alternatives you've considered
N/A

Additional context
N/A

@KTibow
Copy link
Contributor

KTibow commented Nov 8, 2024

Right now the order plugins are run in is in the order provided in the config, however this can be suboptimal.

Is updating your config an option here? You should be able to just move around the plugins in your config to match your preferred order.

@noahbald
Copy link
Author

noahbald commented Nov 8, 2024

For sure, but given that there exists an ideal order, I think it makes sense to use that by default rather than leave it to the user?

@KTibow
Copy link
Contributor

KTibow commented Nov 8, 2024

So you think the order of plugins in preset-default should be changed?

@noahbald
Copy link
Author

noahbald commented Nov 9, 2024

Not just the preset, but any given set of plugins should run in an ideal order.

if you check out the example I gave, it demonstrates that some plugins should always run before others to produce an optimal output

@KTibow
Copy link
Contributor

KTibow commented Nov 9, 2024

That's a breaking change, and IMO a breaking change that doesn't make any sense

@noahbald
Copy link
Author

noahbald commented Nov 9, 2024

Not sure what’s not making sense? And besides, being a breaking change is fine if it’s part of a major release?

If it would be helpful for me to look into it more than just the one example I’ve found, I can certainly do so.

If it’s something that’s not worth it for the project, all good too, just a suggestion :)

@KTibow
Copy link
Contributor

KTibow commented Nov 9, 2024

Well SVGO is a composition of plugins, and right now, they act like a pipeline. This makes it easy to change the order of plugins or add custom plugins.

Even if you changed it to be more like toggles, that would just hide the underlying pipeline.

I feel like the problems here would be better addressed by updating whatever pipeline is being ran rather than changing how plugins are specified, but that's just the opinion of this random guy who watches this repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants