Random SVGs are undefined upon first compilation
See original GitHub issueThis is a funny bug. Upon first webpack compilation a code line like this among many similar ones
import broomSvg from 'broom.svg'
gives me undefined, nothing.
But when I make a change and webpack recompiles, then the above works and that missing SVG can be seen. Using the latest version v3.6.2 here with all the latest webpack packages.
DOM is loaded and the SVG symbols exist in the HTML which is fine. Still, do not understand why some random SVG import statements do not work upon first compilation.
With some debugging, I can see that deep inside webpack, where it holds all installed modules in the installedModules
variables, this broom SVG is missing and not included. But few other random SVGs are.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Unable to import svg files in typescript - Stack Overflow
If you use webpack, you can do this by creating a custom types file. Create a file named custom.d.ts with the following content:...
Read more >SVGR fails to load SVGs with Next 11 · Issue #26130 - GitHub
icon.svg TypeError: unsupported file type: undefined (file: undefined) ... First I was frustrated, then I reflected on how I am using SVGs.
Read more >An SVG Primer for Today's Browsers - W3C
SVG is an XML language. This is important for at least three reasons. First, the code tends to adhere to agreed upon standards...
Read more >Icon System with SVG Sprites - CSS-Tricks
First let's cover how it works. A nice way to handle your icons is to have a folder full of .svg files. That's...
Read more >How to use SVGs in React | Sanity.io guide
Depending on the SVG, component code may not readable; Not scalable for a large number of SVGs. Use case: One-off graphic such as...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Honestly I have no idea how to investigate this and I think it’s webpack’s HMR issue
This issue is still bugging me and studying webpack’s HMR does’t make me believe it’s their problem. What makes you think so @kisenka ?