unplugin / unplugin-icons

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

Latest version breaks with unplugin-vue-components #319

Closed amir20 closed 8 months ago

amir20 commented 8 months ago

Describe the bug

Recently upgraded to 0.17.1 and now get

[unplugin-icons] Could not load ~icons/mdi/light-chevron-right (imported by assets/layouts/default.vue?vue&type=script&setup=true&lang.ts): Icon `mdi/light-chevron-right` not found
error during build:
Error: Could not load ~icons/mdi/light-chevron-right (imported by assets/layouts/default.vue?vue&type=script&setup=true&lang.ts): Icon `mdi/light-chevron-right` not found
    at generateComponent (/Users/amirraminfar/Workspace/dozzle/node_modules/.pnpm/unplugin-icons@0.17.1_@vue+compiler-sfc@3.3.6/node_modules/unplugin-icons/dist/chunk-ACYGWCJ6.cjs:337:11)
    at async Object.load (/Users/amirraminfar/Workspace/dozzle/node_modules/.pnpm/unplugin-icons@0.17.1_@vue+compiler-sfc@3.3.6/node_modules/unplugin-icons/dist/chunk-ACYGWCJ6.cjs:394:20)
    at async PluginDriver.hookFirstAndGetPlugin (file:///Users/amirraminfar/Workspace/dozzle/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:25444:28)
    at async file:///Users/amirraminfar/Workspace/dozzle/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:24611:75
    at async Queue.work (file:///Users/amirraminfar/Workspace/dozzle/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:25654:32)

My config:

import path from "path";
import { defineConfig } from "vite";
import Vue from "@vitejs/plugin-vue";
import VueMacros from "unplugin-vue-macros/vite";
import Icons from "unplugin-icons/vite";
import Components from "unplugin-vue-components/vite";
import AutoImport from "unplugin-auto-import/vite";
import IconsResolver from "unplugin-icons/resolver";
import Pages from "vite-plugin-pages";
import Layouts from "vite-plugin-vue-layouts";
import VueI18nPlugin from "@intlify/unplugin-vue-i18n/vite";

export default defineConfig(() => ({
  resolve: {
    alias: {
      "@/": `${path.resolve(__dirname, "assets")}/`,
    },
  },
  build: {
    manifest: true,
    rollupOptions: {
      input: "assets/main.ts",
    },
    modulePreload: {
      polyfill: false,
    },
  },
  plugins: [
    VueMacros({
      plugins: {
        vue: Vue(),
      },
    }),
    Icons({
      autoInstall: true,
    }),
    Pages({
      dirs: "assets/pages",
      importMode: "sync",
    }),
    Layouts({
      layoutsDirs: "assets/layouts",
    }),
    Components({
      dirs: ["assets/components"],
      resolvers: [
        IconsResolver({
          componentPrefix: "",
        }),
      ],

      dts: "assets/components.d.ts",
    }),
    AutoImport({
      imports: ["vue", "vue-router", "vue-i18n", "vue/macros", "pinia", "@vueuse/head", "@vueuse/core"],
      dts: "assets/auto-imports.d.ts",
      dirs: ["assets/composables", "assets/stores", "assets/utils"],
      vueTemplate: true,
    }),
    VueI18nPlugin({ ... }),
  ],
}));

I did not create a reproducible env since version 0.17.0 does not have this problem.

Reproduction

Did not create one

System Info

System:
    OS: macOS 13.6
    CPU: (10) arm64 Apple M1 Max
    Memory: 8.04 GB / 64.00 GB
    Shell: 3.6.1 - /Users/amirraminfar/homebrew/bin/fish
  Binaries:
    Node: 21.0.0 - ~/Library/Caches/fnm_multishells/18037_1697825440073/bin/node
    npm: 10.2.0 - ~/Library/Caches/fnm_multishells/18037_1697825440073/bin/npm
    pnpm: 8.9.2 - ~/.n/bin/pnpm
  Browsers:
    Chrome: 118.0.5993.88
    Safari: 17.0

Used Package Manager

pnpm

Validations

amir20 commented 8 months ago

Looks like components.d.ts is no longer generated correctly.

diff --git a/assets/components.d.ts b/assets/components.d.ts
index e83dc2aa..852b1547 100644
--- a/assets/components.d.ts
+++ b/assets/components.d.ts
@@ -8,17 +8,8 @@ export {}
 declare module 'vue' {
   export interface GlobalComponents {
     BarChart: typeof import('./components/BarChart.vue')['default']
-    'Carbon:caretDown': typeof import('~icons/carbon/caret-down')['default']
-    'Carbon:circleSolid': typeof import('~icons/carbon/circle-solid')['default']
     'Carbon:information': typeof import('~icons/carbon/information')['default']
-    'Carbon:macShift': typeof import('~icons/carbon/mac-shift')['default']
-    'Carbon:star': typeof import('~icons/carbon/star')['default']
-    'Carbon:starFilled': typeof import('~icons/carbon/star-filled')['default']
     'Carbon:warning': typeof import('~icons/carbon/warning')['default']
-    'Cil:checkCircle': typeof import('~icons/cil/check-circle')['default']
-    'Cil:circle': typeof import('~icons/cil/circle')['default']
-    'Cil:columns': typeof import('~icons/cil/columns')['default']
-    'Cil:xCircle': typeof import('~icons/cil/x-circle')['default']
     ComplexLogItem: typeof import('./components/LogViewer/ComplexLogItem.vue')['default']
     ContainerHealth: typeof import('./components/LogViewer/ContainerHealth.vue')['default']
     ContainerPopup: typeof import('./components/LogViewer/ContainerPopup.vue')['default']
@@ -31,8 +22,6 @@ declare module 'vue' {
     Dropdown: typeof import('./components/common/Dropdown.vue')['default']
     FieldList: typeof import('./components/LogViewer/FieldList.vue')['default']
     FuzzySearchModal: typeof import('./components/FuzzySearchModal.vue')['default']
-    'Ic:sharpFindInPage': typeof import('~icons/ic/sharp-find-in-page')['default']
-    'Ic:sharpKeyboardReturn': typeof import('~icons/ic/sharp-keyboard-return')['default']
     InfiniteLoader: typeof import('./components/InfiniteLoader.vue')['default']
     KeyShortcut: typeof import('./components/common/KeyShortcut.vue')['default']
     LogActionsToolbar: typeof import('./components/LogViewer/LogActionsToolbar.vue')['default']
userquin commented 8 months ago

Are you using mdi and mdi-light collections? How are you using the icons?

amir20 commented 8 months ago

I am using mdi like <mdi:light-chevron-left />. Has something else changed from 0.17.0 --> 0.17.1 that can break this?

userquin commented 8 months ago

Check last merged pr or last release in releases from root repo page

I Will check this tmr.

userquin commented 8 months ago

What collections do you have installed? There is a chevron-left in both mdi and mdi-light IIRC, maybe you only have mdi-light collection installed? If so you only need to replace it with <mdi-light:chevron-left />, my pr just fix a bug.

EDIT: there is no light-chevron-left icon in mdi nor mdi-light and you are using the mdi collection (: is use as separator, but csmelToKebab function replaces it with dash) nd that's why it is not working

amir20 commented 8 months ago

This used to work before the patch. I tested by reverting. So I don't think it's something on my side.

userquin commented 8 months ago

I Will try to send a patch tomorrow, your icon works in previous version due to a bug parsing the tag, that icon doesnt exist in the mdi collection.

amir20 commented 8 months ago

Hi @userquin you maybe right. I don't see light-chevron-left anymore on https://icon-sets.iconify.design/?query=light-chevron-left. Which is weird because it was there before. But I find it weird that it used to work and stopped working. If I revert, it works again. Perhaps it's a change with other deps.

amir20 commented 8 months ago

It seems like all light-* icons have been removed. Not sure why. Feel free to close this. I am not sure why previous ever worked.

userquin commented 8 months ago

@amir20 yeah, it seems the light variants moved to mdi-light collection...

cyberalien commented 8 months ago

light- icons never existed in mdi set. mdi:light-chevron-left never existed. mdi-light:chevron-left though did exist.

I don't know why your code worked before, probably there was a bug in resolving icon sets.

userquin commented 8 months ago

@cyberalien there was a bug resolving icon component, check this pr https://github.com/unplugin/unplugin-icons/pull/316 and linked issue