3 ms·
Two of the three reasons listed involve refactoring and autocomplete quirks of Visual Studio Code, specifically. For instance, Webstorm has no such issues with
by chrisco255 9y ago
Two of the three reasons listed involve refactoring and autocomplete quirks of Visual Studio Code, specifically. For instance, Webstorm has no such issues with default exports. It is smart enough to find all uses of a module and to track them down. The third reason is not all that common in my experience. Tree shaking is an optimization and often a premature one. It's also a technique primarily used for third party libraries.
My problem with this article is the advice is far too broad "ban all default exports" without being considerate of how others code.
For example, I prefer to keep my modules small, with only one export. I may export helper or unwrapped versions of higher order components for easier testing, but generally I want my modules small and single purpose.
Default exports are helpful constructs. Disagree with this article overall.
- chrisfosterelli 9y agoAgreed, I'd argue the developer experience is often worse using named exports. I can find myself wondering 'What names does this module export again?' and it often can encourage putting only tangentially related things in a module together.
- sceutre 9y agoIn webstorm/intellij say you have a react component, one export per module as you say. The import statements are a tie imo to write by hand: import MyThing from "../../components/editors/MyThing"; import {MyThing} from "../../components/editors/MyThing"; But if it's named, you don't need to stop what you're doing, scroll to the top of the file, type out the import statement by hand, and look over at your code tree and figure out the path to the module you want. You just type MyT Ctrl-Space and let intellij do all that for you, not even having to move out of the function you're writing.
- Guillaume86 9y agoSo it's exactly like vs code?
- _hardwaregeek 9y agoYou can easily add the import statement, named or not, with option-space
- chrisco255 9y agoYou shouldn't code around your tools. Your tools are there to serve you, not the other way around. Also, devs on my team use vim, Sublime, Atom, VS Code, Webstorm/IntelliJ, and many more. They all work radically different for things like this.