-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Don't run base64 calculation when demanding tracedSVG #12043
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
Why shouldn't we calculate the base64? Is it because we won't use it anyway as tracedSVG is used as a placeholder image? |
Yeah when user opts in for tracedSVG then he will want to use that as initial image. I would guess this also happens in the gatsby-transformer-sharp but i haven't really checked. There's an option |
Well, this means that this would be a breaking change. Couldn't we just introduce |
What do you mean a breaking change? Generating tracedSVG placeholders in plugin-sharp during fixed and fluid processing was added like two days ago. |
no no, the breaking change is removing base64 when tracedSVG is true. Now it generates base64 always even before your fix from 2 days ago. |
But before the fix it wasn't generating tracedSVG at all during fluid or fixed processing :D any way we can discuss this on discord or somewhere more live? i am probably missing something! |
I'm not sure I understand this change. Is the problem that base64 is being generated even when it's not needed? |
Yes, and then in gatsby-image it gets loaded https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-image/src/index.js#L280-L288 even if we ask for tracedSVG. |
gatsby-image only renders what's passed into it. If a query doesn't ask for base64, it's not loaded. Check our the tracedSVG fragments. They're not querying the base64 field https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-transformer-sharp/src/fragments.js |
Yeah right but this happens when you can control the query arguments. When another plugin uses A solution would be to just delete base64 on the third party end but i find this hacky! I am just not seeing any breaking change :/ When user asks fluid or fixed for tracedSVG doesn't it make sense not to generate base64? This will not impact gatsby-transformer-sharp. Unless i am really missing something here, which can totally be the case! |
Discussed on discord. current implementation is confusing since i am changing options based on another option. In a breaking change we could add |
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 updating this one!
This is a follow-up on #11981 which addresses the following issue:
when user asks for tracedSVG sharp also calculates base64 image. This leads to longer build times and when using gatsby-image the base64 gets loaded before the tracedSVG.
Updated the unit-test that now shows that base64 should be undefined. let me know if you think i could improve this.