Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revisit default exports #1126

Open
Lemmingh opened this issue May 19, 2022 · 2 comments
Open

Revisit default exports #1126

Lemmingh opened this issue May 19, 2022 · 2 comments
Labels
Area: Meta Pertaining to build system, test system, infrastructure, code health, and the project itself. Issue: Bug

Comments

@Lemmingh
Copy link
Collaborator

Proposal

Convert default exports to named exports.

Avoid default exports in future.

Background

There was a time when I thought default exports are succinct. However, they introduce insidious problems. It will be dangerous to mix named and default exports in our codebase after #1077.

  • Interoperability. Module systems apply different constraints and semantics. For example, CommonJS exports and module.exports are incompatible with ECMAScript export default. A real-world case is our hard time with highlight.js.

  • Maintainability. Default exports make it much harder to find references, due to implicit name conversion and inconsistent import pattern. See Google's rationale.

@Lemmingh Lemmingh added Issue: Bug Area: Meta Pertaining to build system, test system, infrastructure, code health, and the project itself. labels May 19, 2022
@yzhang-gh
Copy link
Owner

Haven't ever paid much attention to this. It looks like currently most of the existing exports are named exports, right?
I am of course okay with it.

@Lemmingh
Copy link
Collaborator Author

currently most of the existing exports are named exports

Yes.

The few default exports were introduced by me. 😂


For reference, the lesson from Highlight.js:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Meta Pertaining to build system, test system, infrastructure, code health, and the project itself. Issue: Bug
Projects
None yet
Development

No branches or pull requests

2 participants