optimizePackageImports
is not working with react-icons
in dev mode
#70666
Labels
bug
Issue was opened via the bug report template.
linear: next
Confirmed issue that is tracked by the Next.js team.
Performance
Anything with regards to Next.js performance.
Link to the code that reproduces this issue
https://github.com/FilipiBrabo/nextjs-react-icons
To Reproduce
ANALYZE=true npm run dev
localhost:3000
the bundle files should open in your browserCurrent vs. Expected behavior
The current behavior is that all icons from a
react-icon
pack are being included in the final bundle in dev mode.From the optimizePackageImports docs I expected that
react-icons/*
would be tree shaken both in dev and in prod build.I've also included a
lucide
icon to see the difference, and noticed thatoptimizePackageImports
is working as expected.These are the bundles generated in dev mode of the application provided. You can see that all
fa
,bs
andai
icons are being included in the final dev bundle.Client bundle:
Node.js bundle:
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #123-Ubuntu SMP Mon Jun 10 08:16:17 UTC 2024 Available memory (MB): 32012 Available CPU cores: 16 Binaries: Node: 18.20.4 npm: 10.7.0 Yarn: N/A pnpm: 8.15.8 Relevant Packages: next: 15.0.0-canary.174 // Latest available version is detected (15.0.0-canary.174). eslint-config-next: N/A react: 19.0.0-rc-2d16326d-20240930 react-dom: 19.0.0-rc-2d16326d-20240930 typescript: 5.3.3 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Developer Experience, Performance
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
I didn't dig too much deep into this, but these were the things that I've tried:
modularizeImports
to replacereact-icons
with@react-icons/all-files
. You can check it out in thenext.config.js
file.react-icons
lib inoptimizePackageImports
configThis really affects DX if you have too many icons from different packs being imported.
I'm happy to help in any way to fix this issue, just need a little guidance 😅
The text was updated successfully, but these errors were encountered: