Replies: 3 comments 1 reply
-
Hi i am not familar with webpack but with typescript and with treeshaking in general (rollup) Your using * import + a function that uses dynamic icons[''] This can not be resolved this needs always to get handled not treeshaken as no one knows programatical what your using and what not :) import only the icons that you need and then this can work! |
Beta Was this translation helpful? Give feedback.
-
@frank-dspeed this is not correct. Webpack4 supports tree-shaking for namespaced imports ( Should work out of the box in Webpack5 (unsupported in NextJS yet). |
Beta Was this translation helpful? Give feedback.
-
Uff overall that are great news |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello Next Community Members!
I am using using styled-components and styled-icons with material icons for our typescript app.
The goal is to dynamically import only the icons that we need.
The example component below does that but as i import all icons i can't treeshake them and my bundle is blown up with icons we don't use.
Is there something I'm doing wrong or that I'm missing here to load only the icons we want and still utilize tree shaking for this?
We're using next 9.3.5
Here is the code for the component.
this is my
tsconfig.json
and this the
next.config.js
Beta Was this translation helpful? Give feedback.
All reactions