Code splitting in library mode causes undefined component import
See original GitHub issueBug report
What is the current behavior? When code splitting used (common chunk usage) imported component resolved as undefined. I don’t want to include shared code in each component import but i cannot achieve this with chunks or dependOn.
Library module import without code splitting

Library module import with code splitting

If the current behavior is a bug, please provide the steps to reproduce. Repository to reproduce: https://github.com/xleepy/webpack-library-code-splitting
What is the expected behavior? Module should not return undefined module in case common chunk used (at least i hope)
Other relevant information: webpack version: 5.75.0 Node.js version: v18.12.1 Operating System: Xubuntu 22.04.1/macOS Additional tools:
Thanks for any suggestion!
Issue Analytics
- State:
- Created 10 months ago
- Reactions:2
- Comments:6 (2 by maintainers)
Top Results From Across the Web
TypeError: Cannot read property 'bind' of undefined · Issue #296
As i can see chunks are being created for all dynamic imported components so i think we can do code splitting for library...
Read more >Webpack Import Code Splitting rendering <undefined>
one thing that I have noticed is, no matter what path I give for the component to import, it always imports the chunk....
Read more >Code-splitting for libraries—bundling for npm with Rollup 1.0
Imagine one module imports the upper function from "fancy-case" while another imports it from "fancy-case/src/upper" .
Read more >Code Splitting - webpack
The reason we need default is that since webpack 4, when importing a CommonJS module, the import will no longer resolve to the...
Read more >Lazy loading React components - LogRocket Blog
One approach to code-splitting React components is called route-based code-splitting, which entails applying dynamic import() to lazy load route ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@xleepy I recommend bundle (or even more - don’t bundle at all) icons as a separate library and put in TODO how to use them, it’s possible if you (an another developer) want to customize icons. Example:
Also developer can:
Thanks for advice! Wish you a nice day!