phosphor-icons/core

Module not found

simontaisne opened this issue ยท 7 comments

I'm trying to import SVGs in a Next project with @svgr/webpack loader setup.

import CubeTransparent from '@phosphor-icons/core/regular/cube-transparent.svg';

For some reason I get the following error:

Module not found: 
Package path ./regular/cube-transparent.svg is not exported from package /node_modules/@phosphor-icons/core
(see exports field in /node_modules/@phosphor-icons/core/package.json)

Not exactly sure what is going wrong as I do see the exports in the package.json. No issue when trying to import local SVGs ๐Ÿค”

Some people have reported issues with certain build tools lacking support for package.json exports field. You Might try importing from the fully-qualified path rather than the alias:

import CubeTransparent from '@phosphor-icons/core/assets/regular/cube-transparent.svg';

Let me know if that works!

Thanks! I already tried with the full path and no luck there either. I'll share a repro next week ๐Ÿ‘

Please do ๐Ÿ™

Not sure I have a good answer for you... it's pretty far outside the purview of Javascript doing stuff like this, and the truth is if/whether SVG imports work is going to be very framework / environment dependent. I got your repo working by simply importing the icons using the full path into node_modules:

import Logo from "../../../node_modules/@phosphor-icons/core/assets/regular/phosphor-logo.svg";

Best I can do without understanding the ins and outs of the Next CLI.

I retried today and this is working with Next.js 13.5 ๐Ÿ‘

Great to hear! Next does some really weird hacky stuff by hooking and changing behavior of resolve and fs.readFile, I expect this had something to do with it.