antfu / purge-icons

🎐 Bundles icons on demand
https://www.npmjs.com/package/purge-icons
MIT License
229 stars 18 forks source link

Using `iconSource='local'` does not work with `"type": "module"` #42

Open stafyniaksacha opened 1 year ago

stafyniaksacha commented 1 year ago

Describe the bug

When forcing purge-icon to load icons data from package @iconify/json or @iconify-json/[collection] using vite and "type": "module", it results with an exception: Dynamic require of "@iconify/json/json/[collection].json" is not supported, which is thrown here

It seems to be an issue related to esbuild / tsup

Reproduction

https://stackblitz.com/edit/vitejs-vite-9qv2ug?file=vite.config.ts

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 16.14.2 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.4.2 - /usr/local/bin/npm

Used Package Manager

npm

Validations