question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ban the use of default exports?

See original GitHub issue

Named 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:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
bhgsbatistacommented, Apr 20, 2020

If nothing else, you made me very happy 😄

1reaction
photonstormcommented, Apr 20, 2020

I’ve updated the whole codebase to use named exports. It took quite a while, this had better be worth it 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found