Pass file path to SVGO so prefixIds generates unique per-file prefixes - #17816
Merged
Conversation
…es unique prefixes The `SvgOptimizer` interface and `svgoOptimizer()` did not forward the file path to SVGO's `optimize()`. Plugins like `prefixIds` that derive per-file values from the path fell back to a generic prefix, causing ID collisions when multiple SVGs were inlined on the same page. - Add `path` parameter to `SvgOptimizer.optimize` signature - Forward `path` into SVGO config in `svgoOptimizer()` - Pass `path` from `parseSvg()` to `svgOptimizer.optimize()` Fixes #17728
1 task
🦋 Changeset detectedLatest commit: b3e965c The changes in this PR will be included in the next version bump. This PR includes changesets to release 420 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
|
| 📦 Package | 🔒 Before | 🔓 After |
|---|---|---|
| postcss | stagedPublish | none |
| @markdoc/markdoc | trustedPublisher | none |
| preact | stagedPublish | none |
| nanoid | stagedPublish | none |
myakura
added a commit
to myakura/test--astro-v7-svgo-prefixids
that referenced
this pull request
Aug 25, 2026
Verified against the fix build (astro@37a4692) from withastro/astro#17816.
matthewp
approved these changes
Aug 25, 2026
Merged
dadezzz
pushed a commit
to dadezzz/university_notes
that referenced
this pull request
Aug 29, 2026
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [astro](https://astro.build) ([source](https://github.com/withastro/astro/tree/HEAD/packages/astro)) | [`7.2.6` → `7.2.7`](https://renovatebot.com/diffs/npm/astro/7.2.6/7.2.7) |  |  | --- ### Release Notes <details> <summary>withastro/astro (astro)</summary> ### [`v7.2.7`](https://github.com/withastro/astro/blob/HEAD/packages/astro/CHANGELOG.md#727) [Compare Source](https://github.com/withastro/astro/compare/astro@7.2.6...astro@7.2.7) ##### Patch Changes - [#​17415](withastro/astro#17415) [`55d38c8`](withastro/astro@55d38c8) Thanks [@​iseraph-dev](https://github.com/iseraph-dev)! - Deserializes each route once when loading the SSR manifest - [#​17772](withastro/astro#17772) [`023b48b`](withastro/astro@023b48b) Thanks [@​matthewp](https://github.com/matthewp)! - Fixes route selection for normalized request paths in adapter and development request handling - [#​17819](withastro/astro#17819) [`633855b`](withastro/astro@633855b) Thanks [@​matthewp](https://github.com/matthewp)! - Updates generated and default Cloudflare `compatibility_date` values to match the installed runtime and requires Wrangler `^4.125.0` - [#​17813](withastro/astro#17813) [`ae26d18`](withastro/astro@ae26d18) Thanks [@​matthewp](https://github.com/matthewp)! - Fixes `rewrite()` and `next(payload)` for GET and HEAD requests with host-provided bodies - [#​17816](withastro/astro#17816) [`a0d2fe3`](withastro/astro@a0d2fe3) Thanks [@​astro-factory](https://github.com/apps/astro-factory)! - Fixes the experimental `svgOptimizer` not generating unique per-file ID prefixes when using SVGO's `prefixIds` plugin </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC40OS4xIiwidXBkYXRlZEluVmVyIjoiNDQuNDkuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
svgOptimizerdid not forward the SVG's file path to SVGO'soptimize(). Plugins likeprefixIdsthat derive per-file values from the path fell back to the same generic prefix for every file, so inlining multiple SVGs on one page produced colliding IDs.SvgOptimizer.optimizenow takes the file path as a second parameter, andsvgoOptimizer()forwards it into SVGO's config, soprefixIds(and similar plugins) generate distinct prefixes per file.SvgOptimizerinterface by adding a requiredpathparameter. SincesvgOptimizeris experimental, this is acceptable, but customSvgOptimizerimplementations will need to pass through the new parameter.Testing
prefixIdsthat the resulting IDs differ across files.Docs
SvgOptimizeris an experimental interface and its usage docs don't specify theoptimizesignature.Fixes #17728