Open dabeeeenster opened 6 months ago
Can you create 2 minimal runnable repros?
I doubt it's the upgrade that led this warning to appear, because the new release doesn't contain any code change related to this.
My believe is that this warning has likely always been there, when you reference svgs in markdown content.
I'd kindly ask you to invest time to qualify better this potential bug.
Ah yes you are correct @slorber ! It was my clearing the build cache that caused the warnings to reappear. I'm still not clear why they are being thrown however? I believe the SVG files are valid?
Ah yes you are correct @slorber ! It was my clearing the build cache that caused the warnings to reappear. I'm still not clear why they are being thrown however? I believe the SVG files are valid?
That's likely a bug related to using svg files using markdown image syntax.
We should probably find a way to read the dimensions of local svg files to apply them to the <img>
tag, so that it doesn't produce layout shifts when the svgs load.
Hmm apparently our lib "image-size" is supposed to handle svgs as well, so it's probably a bug in this library.
https://github.com/image-size/image-size
Can you provide a sample SVG? Can you try reading its dimensions with that lib?
OK yep https://gist.github.com/dabeeeenster/004e82c3e344707751f294c16d5ddf50 shows the error being thrown in that library - issue raised here.
FWIW, I have the same issue with editable svg's saved with draw.io.
For now my solution is to add a build step that is invoked before yarn build
:
# finds all .svg files and passes them to xargs to paraellelize
# svgo-ing them in groups of 10 (this avoids paying nodejs JIT time for every file)
fd -e svg -0 | xargs -0 -P $(nproc) -n 10 svgo ─╯
Pin image-size
to v1.0.x
fix this:
// package.json
{
"devDependencies": {
"image-size": "~1.0.2"
}
}
Have you read the Contributing Guidelines on issues?
Prerequisites
npm run clear
oryarn clear
command.rm -rf node_modules yarn.lock package-lock.json
and re-installing packages.Description
When running
npm run build
after upgrading to docusaurus3.1.0
I have started seeing the following WARNING errors in the console:You can find the images referenced here: https://github.com/Flagsmith/flagsmith/tree/main/docs/static/img e.g. https://github.com/Flagsmith/flagsmith/blob/main/docs/static/img/self-hosted-architecture.svg
These are optimised SVG images but they are valid and display fine in browsers.
Reproducible demo
https://github.com/Flagsmith/flagsmith/pull/3246
Steps to reproduce
npm run build
Expected behavior
No warning should show as the images are valid
Actual behavior
Receive warnings
[WARNING] The image at "/Users/ben/flagsmith/flagsmith/docs/static/img/saas-architecture.svg" can't be read correctly. Please ensure it's a valid image.
Your environment
v20.9.0
Self-service