Ban the use of default exports?
See original GitHub issueNamed exports are superior to default exports in a few ways:
It’s easier to find all uses of a function / property through the project, easier to rename across project, less confusion around names / mental load.
Adopting named exports will pay dividends down the road as the number of modules and exported properties are added.
More info: https://humanwhocodes.com/blog/2019/01/stop-using-default-exports-javascript-module/
// instead of this export / import
export default function AddChild (parent: IParent, child: IGameObject | IGameObject[])
import AddChild from '../src/gameobjects/container/AddChild';`
// I suggest we use named exports
export function AddChild (parent: IParent, child: IGameObject | IGameObject[])
import { AddChild } from '../src/gameobjects/container/AddChild';
// it's more consistent with importing from an index, ex:
import { AddChild, SetParent } from '../src/gameobjects/container';
Having 1 way of importing things is better than having 2 ways of importing things imo.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Why we have banned default exports in Javascript and you ...
In this article, I want to explain why here at Neufund, we decided to ban default exports and use solely named ones. ESM...
Read more >Why we have banned default exports in ... - JavaScript Works
In this article, I want to explain why here at Neufund, we decided to ban default exports and use solely named ones.
Read more >Why we have banned default exports in JavaScript
Default exports were introduced because often a module wants to export a single value or piece of functionality. In such cases, in module ......
Read more >eslint-plugin-import/no-default-export.md at main - GitHub
Prohibit default exports. Mostly an inverse of prefer-default-export . Rule Details. The following patterns are considered warnings:.
Read more >Forbidding default exports - Stack Overflow
Forbidding default exports · Where did you read that? What was the context? · There's no difference between both the cases you've mentioned...
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
If nothing else, you made me very happy 😄
I’ve updated the whole codebase to use named exports. It took quite a while, this had better be worth it 😃