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

Build error in version 0.16.4 #294

Closed woqk closed 12 months ago

woqk commented 12 months ago

Describe the bug

Version 0.16.3 works well, but latest version give an error.


failed to load config from /home/projects/github-mgbdfs/vite.config.ts
error when starting dev server:
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/projects/github-mgbdfs/node_modules/.pnpm/unplugin-icons@0.16.4/node_modules/unplugin-icons/dist/vite.js from /home/projects/github-mgbdfs/vite.config.ts not supported.
Instead change the require of vite.js in /home/projects/github-mgbdfs/vite.config.ts to a dynamic import() which is available in all CommonJS modules.
    at InternalError.get (https://githubmgbdfs-equ4.w-credentialless.staticblitz.com/blitz.e809191e.js:35:385021)
    at Module._extensions..js (https://githubmgbdfs-equ4.w-credentialless.staticblitz.com/blitz.e809191e.js:35:259510)
    at _require.] (/home/projects/github-mgbdfs/node_modules/.pnpm/vite@4.3.9/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:64579:17)
    at Module.load (https://githubmgbdfs-equ4.w-credentialless.staticblitz.com/blitz.e809191e.js:35:257700)
    at Module._load (https://githubmgbdfs-equ4.w-credentialless.staticblitz.com/blitz.e809191e.js:35:255119)
    at Module.require (https://githubmgbdfs-equ4.w-credentialless.staticblitz.com/blitz.e809191e.js:35:258018)
    at i (https://githubmgbdfs-equ4.w-credentialless.staticblitz.com/blitz.e809191e.js:35:514801)
    at _0x216930 (https://githubmgbdfs-equ4.w-credentialless.staticblitz.com/blitz.e809191e.js:42:144147)
    at Object.eval (/home/projects/github-mgbdfs/vite.config.ts:38:28)
    at Object.function (https://githubmgbdfs-equ4.w-credentialless.staticblitz.com/blitz.e809191e.js:42:144956)
    at Module._compile (https://githubmgbdfs-equ4.w-credentialless.staticblitz.com/blitz.e809191e.js:35:259006)
    at _require.] (/home/projects/github-mgbdfs/node_modules/.pnpm/vite@4.3.9/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:64576:24)
    at Module.load (https://githubmgbdfs-equ4.w-credentialless.staticblitz.com/blitz.e809191e.js:35:257700)
    at Module._load (https://githubmgbdfs-equ4.w-credentialless.staticblitz.com/blitz.e809191e.js:35:255119)
    at Module.require (https://githubmgbdfs-equ4.w-credentialless.staticblitz.com/blitz.e809191e.js:35:258018)
    at i (https://githubmgbdfs-equ4.w-credentialless.staticblitz.com/blitz.e809191e.js:35:514801)
    at loadConfigFromBundledFile (/home/projects/github-mgbdfs/node_modules/.pnpm/vite@4.3.9/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:64584:21)
    at async loadConfigFromFile (/home/projects/github-mgbdfs/node_modules/.pnpm/vite@4.3.9/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:64440:28)
    at async resolveConfig (/home/projects/github-mgbdfs/node_modules/.pnpm/vite@4.3.9/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:64045:28)
    at async _createServer (/home/projects/github-mgbdfs/node_modules/.pnpm/vite@4.3.9/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:63326:20)
    at async CAC.eval (/home/projects/github-mgbdfs/node_modules/.pnpm/vite@4.3.9/node_modules/vite/dist/node/cli.js:748:24)
 ELIFECYCLE  Command failed with exit code 1.

vite.config.ts

import { defineConfig } from 'vite';
import solidPlugin from 'vite-plugin-solid';
import Icons from 'unplugin-icons/vite';

export default defineConfig({
  plugins: [solidPlugin(), Icons({ compiler: 'solid' })],
  server: {
    port: 3000,
  },
  build: {
    target: 'esnext',
  },
});

Reproduction

https://stackblitz.com/edit/github-mgbdfs?file=vite.config.ts,tsconfig.json,package.json

System Info

System:
    OS: macOS 13.4.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 74.52 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.3.1 - /opt/homebrew/bin/node
    Yarn: 1.22.18 - /opt/homebrew/bin/yarn
    npm: 9.6.7 - /opt/homebrew/bin/npm
    pnpm: 8.6.3 - /opt/homebrew/bin/pnpm
  Browsers:
    Brave Browser: 114.1.52.122
    Chrome: 114.0.5735.198
    Safari: 16.5.1
    Safari Technology Preview: 17.0

Used Package Manager

pnpm

Validations

zhangtao25 commented 12 months ago

@antfu 这是一个bug,没锁lock.json会G

antfu commented 12 months ago

Should be fixed in 0.16.5