fluentui-system-icons icon indicating copy to clipboard operation
fluentui-system-icons copied to clipboard

react-icons ES module seems broken

Open steabert opened this issue 1 year ago • 2 comments

The exported ES module has internal imports without .js extensions which causes it to fail.

To reproduce:

npm i
cd packages/react-icons
npm run build

node --import='./lib/index.js'

The import fails because chunk-0 is imported without .js extension, as are all other subsequent imports.

steabert avatar Dec 22 '24 14:12 steabert

This is making it really difficult to write tests for components that indirectly import react-icons (or other fluent packages - the issues seem widespread). Neither Node tests nor Playwright component tests are able to resolve these imports.

  • export * from './icons/chunk-0' should be export * from './icons/chunk-0.js' (missing file extensions)
  • from '../contexts' should be from '../contexts/index.js' (directory imports)

Can be reproduced by setting "type": "module" and trying to import Fluent UI packages.

There's a temporary workaround of cd:ing into Fluent packages under node_modules and symlinking ESM -> CJS: mv lib lib-esm-backup && ln -sf lib-commonjs lib # react-icons uses lib-cjs instead and then fixing the exports in each package.json from "import": "./lib/index.js" to "import": "./lib-commonjs/index.js".

toerndev avatar Jul 14 '25 08:07 toerndev

see https://github.com/microsoft/fluentui/issues/34685

Hotell avatar Sep 29 '25 12:09 Hotell