-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Remove non-stable SVG features #13488
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
Conversation
🦋 Changeset detectedLatest commit: 41f1e0b The changes in this PR will be included in the next version bump. 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 |
CodSpeed Performance ReportMerging #13488 will not alter performanceComparing Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for grabbing time to talk through this and quick follow-up! 🎉
| */ | ||
| const ATTRS_TO_DROP = ['xmlns', 'xmlns:xlink', 'version']; | ||
| const DEFAULT_ATTRS: SvgAttributes = { role: 'img' }; | ||
| const DEFAULT_ATTRS: SvgAttributes = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just calling out this change! Probably the right move given the other changes, but I'd still like to provide good accessibility defaults where we can.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For sure, we definitely need to follow up on this. Just removing for the initial release as there isn't consensus on what the best approach is yet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Let's update the changeset to follow the contribution guide.
Also, regarding the memory leak, the malicious code is here:
I'm not sure if it's directly related to the sprite mode. What we have seen is that a Starlight website that uses a lot of SVG was growing in memory, without control. The experimental SVG feature wasn't enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just making some suggestions with what the changeset could look like here! As Ema mentioned, we do have a standard that we follow to let people know that this contains breaking changes if (and only if) you are using the experimental feature. And since that's the case, we really need to guide people through updating to compatible code (suggestions included! make them accurate!)
Commenting for the Docs changes needed in a PR, if I'm reading this right, it looks like it will be sufficient to:
- delete the section on
size(it simply won't exist at this point) - delete the section on the
modecomponent attribute (ifmode="sprite"can't be set, then there's no other value it could take? I'm assuming everything will bemode="inline"not just default, but as the only option? In that case, we wouldn't showmodeat all) - delete the entry for
experimental.svg.mode- similarly, it can't be set, so no need to show it there. - maybe document the
SVGComponenttype? I'll ask @ArmandPhilippot whether this feels necessary here!
Thanks for your help getting this right, and helping experimental users update from what they might already have! 🙌
|
@sarah11918 We don't document I'm not familiar with this experimental feature so I'm a little surprised by the example shown in the link. My assumption was that the imported SVG is a regular Astro component so it should be used with a slot and not as prop. If so, I'm not sure when this type might be useful. If it's only for uncommon setups, maybe we can wait until someone asks to document it? 😅 |
@sarah11918 @ematipico Thanks for the guidance on the changeset! I have updated based on the feedback. WRT the Docs, you're correct on all points. I have removed the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code wise, it looks good, but the changeset is incorrect. The feature is still experimental, we just removed some stuff.
.changeset/little-steaks-rule.md
Outdated
| 'astro': patch | ||
| --- | ||
|
|
||
| The SVG import feature introduced behind a flag in [v5.0.0](https://github.com/withastro/astro/blob/main/packages/astro/CHANGELOG.md#500) is no longer experimental and is available for general use. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The feature is still experimental, judging by the code. I think, maybe, there's been a misunderstanding on how to reword the changeset. Here's the relevant paragraph: https://contribute.docs.astro.build/docs-for-code-changes/experimental-feature-docs/#breaking-changes-while-still-experimental
We just need to add at the top of the changeset the following:
**BREAKING CHANGE to the experimental SVG configuration only**
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh my gosh, how embarrassing 😂 Sorry for that! I'll get that updated today
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just checking @ematipico -- taking this out of experimental might be a plan for Launch week? Which now would be our next minor release. So, not sure whether this PR is intended as a patch first, or whether this will merge with the next minor at launch.
But yes, either the code needs to catch up to that, or the changeset needs to only discuss the remove the features. I'll wait to polish up the changeset until we have decided what the goal of this PR is!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went ahead and pushed the breaking changes changeset instead. If we need to ready for stable, we can revert that commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sarah11918 that's the plan, but that's not for this PR. We still have a memory leak that we need to fix, and if we can't fix it, we can't make the feature stable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mind tagging that issue for me here? I'm having trouble finding where you pointed it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stramel There isn't an issue for that, but there's a Discord thread: https://discord.com/channels/830184174198718474/1349441804193239150
This was caught by a contributor of ours who works at Cloudflare. They tried to upgrade their Astro and Starlight dependencies. They didn't use the SVG experimental feature, however we idenfied that the issue was coming from code that was changed for the SVG support.
I believe Cloudflare project uses many SVG files, and I believe Astro was parsing/saving them exponentially. This is just a gut feeling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good code wise. @sarah11918 are you happy with the changeset?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, glad we got that sorted! Just added some extra "padding" to the text in a few places to give explicit instruction as to code changes needed as well as some gentle editing.
Also noting: I don't see a PR to docs to update the reference material yet. Is this something on your radar, @stramel ?
Co-authored-by: Sarah Rainsberger <[email protected]>
Co-authored-by: Sarah Rainsberger <[email protected]>
|
Wait, what?
and then:
|
|
Re: @sarah11918 it's not an internal implementation. It's meant to improve the developer experience. I specifically requested for it, so that SVGs can be passed as props and be type-checked correctly in actual projects. @ArmandPhilippot we treat SVG files as vector images, so since there's an Currently there's no easy way to type a prop that accepts SVG other than this: It's also helpful to type-check dynamically set SVG vector images in data structures. All these I have explained in more detail in my recent comments in Roadmap #1035. FWIW, currently I'm using this to define it manually in our type definitions file. Perhaps this is better than aliasing type SVGComponent = typeof import('astro/client/*.svg').default |
|
@ADTC While the following works: <SVGComponentAsProp icon={SVGIcon} />
<ComponentAsProp child={RegularComponent} />This doesn't: <ComponentAsProp child={<RegularComponent prop="foo" />} />So, for me, this is not the recommended way to use components. A slot (either default or a named one) should be used instead. So what I was saying is: I don't think if an |
|
@stramel so can we re-add the removed type? @ArmandPhilippot only asked to remove the documentation, not the type itself. The type itself is useful, and since it's only a type it doesn't affect anything semantically in the build output. |
* Remove non-stable features * docs: add changeset * align changeset with unflagging experimental features docs * Drop SVGComponent type * Add examples for removals to changeset * Report changeset as breaking change rather than unflagged * Apply suggestions from code review Co-authored-by: Sarah Rainsberger <[email protected]> * Apply suggestions from code review Co-authored-by: Sarah Rainsberger <[email protected]> --------- Co-authored-by: Emanuele Stoppa <[email protected]> Co-authored-by: Sarah Rainsberger <[email protected]>
Changes
After discussing with @natemoo-re,
Sprite Mode: We decided it was better to push this off until later. Inlining SVGs alone is a big win for Astro and there are some hurdles to creating a good DX without footguns in adding sprites.
Size Prop: We decided to remove this all together as it is pretty opinionated.
Title Prop: We're good with holding off on this until later as well considering there is a good discussion about how this should be implemented by default. Removing this allows users to control the a11y while we work to provide a better DX.
Default Role Attribute: Similar to above, it isn't obvious what we should apply by default. So we'll remove this in favor of a better solution down the road.
Memory Issue: I highly suspect this was tied to Sprite mode but I can look into it more if it still persists.
Additionally, I added a
SVGComponenttype that is equivalent toAstroComponentFactoryto provide a better DX for passing SVGs down to other Astro components.References withastro/roadmap#1035
Testing
Ran tests
Docs
Will need to update the docs but will need some help
/cc @withastro/maintainers-docs for feedback!