diff --git a/packages/icon-files/package.json b/packages/icon-files/package.json index f926fb47f..93cb4b9ef 100644 --- a/packages/icon-files/package.json +++ b/packages/icon-files/package.json @@ -5,10 +5,6 @@ "type": "module", "main": "./src/index.cjs", "module": " ./src/index.js", - "exports": { - "require": "./src/index.cjs", - "default": "./src/index.js" - }, "types": "./src/index.d.ts", "files": [ "src", diff --git a/packages/icons/src/charcoalIconFiles.ts b/packages/icons/src/charcoalIconFiles.ts index 936310bcb..e8b6d84d7 100644 --- a/packages/icons/src/charcoalIconFiles.ts +++ b/packages/icons/src/charcoalIconFiles.ts @@ -1,11 +1,9 @@ -import charcoalIconFiles from '@charcoal-ui/icon-files' +import type charcoalIconFiles from '@charcoal-ui/icon-files' export default charcoalIconFiles export type KnownIconFile = keyof typeof charcoalIconFiles -export const KNOWN_ICON_FILES = Object.keys( - charcoalIconFiles -) as KnownIconFile[] +export const KNOWN_ICON_FILES: KnownIconFile[] = [] export function isKnownIconFile(name: string): name is KnownIconFile { - return name in charcoalIconFiles + return true } diff --git a/packages/icons/src/loaders/CharcoalIconFilesLoader.ts b/packages/icons/src/loaders/CharcoalIconFilesLoader.ts index c5bcc6303..83b693edf 100644 --- a/packages/icons/src/loaders/CharcoalIconFilesLoader.ts +++ b/packages/icons/src/loaders/CharcoalIconFilesLoader.ts @@ -1,6 +1,6 @@ import { PixivIconLoadError } from './PixivIconLoadError' import { Loadable } from './Loadable' -import charcoalIconFiles, { KnownIconFile } from '../charcoalIconFiles' +import { KnownIconFile } from '../charcoalIconFiles' /** * `@charcoal-ui/icon-files` に収録されているアイコンを取ってくる @@ -15,7 +15,12 @@ export class CharcoalIconFilesLoader implements Loadable { } get importIconFile() { - return charcoalIconFiles[this._name] + const [size, name] = this._name.split('/') + + return () => + import(`@charcoal-ui/icon-files/src/${size}/${name}.js`).then( + (res: { default: string }) => res.default + ) } async fetch(): Promise { diff --git a/packages/react/src/components/Icon/index.tsx b/packages/react/src/components/Icon/index.tsx index b8dfd2cfb..c33191866 100644 --- a/packages/react/src/components/Icon/index.tsx +++ b/packages/react/src/components/Icon/index.tsx @@ -1,8 +1,9 @@ import * as React from 'react' -import '@charcoal-ui/icons' import type { PixivIcon, Props } from '@charcoal-ui/icons' +import '@charcoal-ui/icons' + export interface OwnProps { unsafeNonGuidelineScale?: number className?: string