8 | {Object.keys(IconComponents).map((c) => (
9 |
10 | {IconComponents[c]()}
11 |
{c}
12 |
13 | ))}
14 |
15 | );
16 | };
17 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "include": ["src"],
3 | "compilerOptions": {
4 | "target": "esnext",
5 | "lib": ["DOM", "ESNext"],
6 | "jsx": "react-jsx",
7 | "module": "esnext",
8 | "rootDir": "./src",
9 | "moduleResolution": "node",
10 | "outDir": "./dist",
11 | "resolveJsonModule": true,
12 | "declaration": true,
13 | "importHelpers": true,
14 | "isolatedModules": true,
15 | "esModuleInterop": true,
16 | "forceConsistentCasingInFileNames": true,
17 | "strict": true,
18 | "noUnusedLocals": true,
19 | "noUnusedParameters": true,
20 | "noImplicitReturns": true,
21 | "noFallthroughCasesInSwitch": true,
22 | "skipLibCheck": true
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/tsup.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'tsup';
2 |
3 | export default defineConfig({
4 | clean: true,
5 | dts: true,
6 | format: ['cjs', 'esm'],
7 | entry: ['src', '!src/**/*.spec.*', '!src/**/*.d.ts'],
8 | external: ['react'],
9 | bundle: false,
10 | plugins: [
11 | {
12 | name: 'fix-esm',
13 | renderChunk(_, chunk) {
14 | if (this.format === 'esm') {
15 | // https://github.com/egoist/tsup/issues/953
16 | const code = addMjsExtension(chunk.code);
17 | return { code };
18 | }
19 | },
20 | },
21 | ],
22 | });
23 |
24 | function addMjsExtension(content) {
25 | return content.replace(
26 | /import\s+\{\s*default\s+as\s+(default\d+)\s*\}\s+from\s+"\.\/([^"]+)"/g,
27 | `import { default as $1 } from "./$2.mjs"`,
28 | );
29 | }
30 |
--------------------------------------------------------------------------------