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

Core: Use named exports in src/ #5262

Closed
mgol opened this issue May 30, 2023 · 3 comments · Fixed by #5292
Closed

Core: Use named exports in src/ #5262

mgol opened this issue May 30, 2023 · 3 comments · Fixed by #5292
Assignees
Milestone

Comments

@mgol
Copy link
Member

mgol commented May 30, 2023

Description

The code in src/ on the main branch is authored using ECMAScript modules with default exports. Each file exports a single API.

In the exports PR (#5255) for 4.0, a concern has been raised by @GeoffreyBooth that default exports are generally discouraged so we should ideally provide named jQuery & $ exports in addition, even if we keep the default export as well. There's a link to a Webpack docs page there that says:

Avoid the default export. It's handled differently between tooling. Only use named exports.

I just wondered how that affects our approach to jQuery source code. Since we plan to expose the ESM files from src/, should we switch them to use named exports as well?

If we switch, this is likely to affect our AMD output published to the amd directory. We can either accept it, or tweak the AMD output or maybe even give up on AMD for individual modules and just bet on ESM here.

Link to test case

N/A

@mgol mgol added the Discuss in Meeting Reserved for Issues and PRs that anyone would like to discuss in the weekly meeting. label May 30, 2023
@mgol mgol self-assigned this May 30, 2023
@mgol mgol added this to the 4.0.0 milestone Jun 23, 2023
@mgol
Copy link
Member Author

mgol commented Jun 23, 2023

Adding the 4.0.0 milestone and the Blocker label to ensure we make a decision before the release.

@timmywil timmywil removed the Discuss in Meeting Reserved for Issues and PRs that anyone would like to discuss in the weekly meeting. label Jul 10, 2023
@timmywil
Copy link
Member

Will be using named exports in the src folder.

mgol added a commit to mgol/jquery that referenced this issue Jul 10, 2023
mgol added a commit to mgol/jquery that referenced this issue Jul 10, 2023
@jquery jquery deleted a comment from truthtahoe Jul 13, 2023
@mgol mgol changed the title Use named exports? Use named exports Sep 12, 2023
@mgol mgol changed the title Use named exports Core: Use named exports in src/ Sep 12, 2023
@mgol mgol added Core and removed Build labels Sep 12, 2023
mgol added a commit that referenced this issue Sep 12, 2023
The `default` export is treated differently across tooling when transpiled
to CommonJS - tools differ on whether `module.exports` represents the full
module object or just its default export. Switch `src/` modules to named
exports for tooling consistency.

Fixes gh-5262
Closes gh-5292
@GeoffreyBooth
Copy link

In the exports PR (#5255) for 4.0, a concern has been raised by @GeoffreyBooth that default exports are generally discouraged

https://x.com/kentcdodds/status/1702338292065399179?s=20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants