unplugin / unplugin-icons

🤹 Access thousands of icons as components on-demand universally.
https://www.npmjs.com/package/unplugin-icons
MIT License
3.66k stars 131 forks source link

svgr is not a function when using "type": "commonjs" after updating to svgr v7 #277

Closed markgaze closed 1 year ago

markgaze commented 1 year ago

Describe the bug

This is similar to #96 and slightly related to #275

v0.16.0 supports svgr v7.0.0 but only when "type": "module" is set. When this is not set then it fails the build with the svgr is not a function.

When debugging, it looks like the svgrCore object now has another default inside it that means that you have to access transform via svgrCore.default.transform rather than the svgrCore.transform that it's using at the moment.

When I change this in my node_modules that does indeed fix the issue for me but I'm not sure what would be needed to maintain backwards compatibility otherwise I'd raise a PR. Looks like the peerDependency has been updated to >=7.0.0 though.

Reproduction

https://stackblitz.com/edit/unplugin-icons-commonjs-issue?file=package.json

System Info

  System:
    OS: macOS 13.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 15.07 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 19.8.1 - ~/.nvm/versions/node/v19.8.1/bin/node
    npm: 9.5.1 - ~/.nvm/versions/node/v19.8.1/bin/npm
  Browsers:
    Chrome: 111.0.5563.110
    Edge: 111.0.1661.54
    Firefox: 83.0
    Safari: 16.2

Used Package Manager

pnpm

Validations