unplugin / unplugin-icons

šŸ¤¹ Access thousands of icons as components on-demand universally.

Home Page:https://www.npmjs.com/package/unplugin-icons

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

build failed with rollup

KarasuShin opened this issue Ā· comments

commented

Describe the bug

I got some error messages while building with rollup:

CleanShot 2023-05-15 at 15 09 57@2x

rollup.config.js

import { defineConfig } from 'rollup'
import iconPlugin from 'unplugin-icons/rollup'
import typescriptPlugin from '@rollup/plugin-typescript'

const config = defineConfig({
  input: ['src/index.tsx'],
  output: {
    format: 'es',
    dir: 'dist',
    preserveModules: true,
  },
  plugins: [
    typescriptPlugin(),
    iconPlugin({
      compiler: 'jsx',
      jsx: 'react',
    }),
  ],
  external: [
    'react/jsx-runtime',
    'react',
  ],
})

export default config

tsconfig.json

{
  "compilerOptions": {
    "target": "ESNext",
    "useDefineForClassFields": true,
    "lib": ["DOM", "DOM.Iterable", "ESNext"],
    "allowJs": false,
    "skipLibCheck": true,
    "esModuleInterop": false,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "ESNext",
    "moduleResolution": "Node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx",
    "types": ["unplugin-icons/types/react"]
  },
  "include": ["src"]
}

src/index.tsx

import UserIcon from '~icons/carbon/user'

export const Icon = () => <UserIcon />

Reproduction

https://github.com/KarasuShin/unplugin-icons-rollup-reproduction

System Info

System:
    OS: macOS 13.3.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 107.00 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.14.0 - ~/Library/Caches/fnm_multishells/8359_1683852025838/bin/node
    Yarn: 1.22.15 - /usr/local/bin/yarn
    npm: 9.3.1 - ~/Library/Caches/fnm_multishells/8359_1683852025838/bin/npm
    Watchman: 2023.04.24.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 113.0.5672.92
    Safari: 16.4

Used Package Manager

pnpm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.