diff --git a/scripts/generate-phosphor-icon-registry.mjs b/scripts/generate-phosphor-icon-registry.mjs index 251e6fe73..2a3eaf74f 100644 --- a/scripts/generate-phosphor-icon-registry.mjs +++ b/scripts/generate-phosphor-icon-registry.mjs @@ -9,17 +9,14 @@ const iconNames = readdirSync(path.join(packageRoot, 'dist/csr')) .filter((fileName) => fileName.endsWith('.es.js')) .map((fileName) => fileName.slice(0, -'.es.js'.length)) .sort((a, b) => a.localeCompare(b)) -const getLocalName = (iconName) => - iconName === 'Infinity' ? 'InfinityIcon' : iconName -const getImportSpecifier = (iconName) => { - const localName = getLocalName(iconName) - return localName === iconName ? iconName : `${iconName} as ${localName}` -} +// Every icon module exports both `Name` (deprecated) and `NameIcon`. The +// suffixed export is the supported one and never collides with a JS global. +const getLocalName = (iconName) => `${iconName}Icon` const imports = iconNames .map( (iconName) => - `import { ${getImportSpecifier(iconName)} } from '@phosphor-icons/react/${iconName}'`, + `import { ${getLocalName(iconName)} } from '@phosphor-icons/react/${iconName}'`, ) .join('\n') const entries = iconNames diff --git a/src/builder/templates.ts b/src/builder/templates.ts index 941aaa6d4..7e3c2105b 100644 --- a/src/builder/templates.ts +++ b/src/builder/templates.ts @@ -7,16 +7,16 @@ import type { Icon } from '@phosphor-icons/react' import { - Rocket, - Robot, - SquaresFour, - FileText, - HardDrives, - Radio, - Globe, - HardDrive, - Plus, - ShoppingBag, + RocketIcon, + RobotIcon, + SquaresFourIcon, + FileTextIcon, + HardDrivesIcon, + RadioIcon, + GlobeIcon, + HardDriveIcon, + PlusIcon, + ShoppingBagIcon, } from '@phosphor-icons/react' export interface Template { @@ -39,7 +39,7 @@ export const TEMPLATES: Array