question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Random SVGs are undefined upon first compilation

See original GitHub issue

This 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:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kisenkacommented, Jan 9, 2018

Honestly I have no idea how to investigate this and I think it’s webpack’s HMR issue

0reactions
binarykitchencommented, Feb 20, 2018

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 ?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found