Updated version. Read on: https://medium.com/@perisicnikola37/dont-use-react-imports-like-this-use-wrapper-pattern-instead-b7a49b864ff4

For further actions, you may consider blocking this person and/or reporting abuse
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (11)
This has nothing to do with wrapper files or components, its just comparing importing everything from a library with importing only what you really need.
E.g. you compare
with
but wrongfully suggest that you need a new file to benefit from bundling - you don't. Just don't import the whole library when you need two functions.
Great to know, thanks Nikola.
what is the use of wrapper here, when you are changing completely what you are importing from the library.
There are multiple benefits:
I don't think that's how modern bundling work.
For your problem the wrapper is just redundant. The article is misleading, trying to state that by putting something in another file you can "optimize" something.
Also I couldn't find it being used in the repo you, can you point to the exact file?
yep, this is still the old version
check new one on: medium.com/@perisicnikola37/dont-u...
Yeah, this makes more sense now.
It's a bundler issue. Not worth for changing.
Well, many people who liked this article on Medium would argue with you xD
I also think that this article is misleading as it let the reader think that the suggested wrapper pattern is the actual solution to fix the presented issue.
Like @thraizz says in his comment, no need for the wrapper to fix the issue. The real fix is to load only the necessary modules, assuming the library export them independentely.
Plus, grouping several unique modules into 1 unique "wrapper" file like the given example for Lodash, though in some cases could be a good idea (like to be able to replace any third party tool by an equivalent one), could load to creating "barrel files" which may lead to loading superfluous modules when used in combination with code splitting.
New version on: medium.com/@perisicnikola37/dont-u...
Some comments have been hidden by the post's author - find out more