Skip to content

Core: Use named exports in src/ #5262

Closed

Description

@mgol

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

Activity

  1. added
    Discuss in MeetingReserved for Issues and PRs that anyone would like to discuss in the weekly meeting.
    on May 30, 2023
  2. self-assigned this
    on May 30, 2023
  3. added this to the 4.0.0 milestone on Jun 23, 2023
  4. mgol commented on Jun 23, 2023

    @mgol
    MemberAuthor

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

  5. removed
    Discuss in MeetingReserved for Issues and PRs that anyone would like to discuss in the weekly meeting.
    on Jul 10, 2023
  6. timmywil commented on Jul 10, 2023

    @timmywil
    Member

    Will be using named exports in the src folder.

  7. added 2 commits that reference this issue on Jul 10, 2023
    fc72338
    cfe5704
  8. deleted a comment from truthtahoe on Jul 13, 2023
  9. changed the title [-]Use named exports?[/-] [+]Use named exports[/+] on Sep 12, 2023
  10. changed the title [-]Use named exports[/-] [+]Core: Use named exports in `src/`[/+] on Sep 12, 2023
  11. added and removed on Sep 12, 2023
  12. added a commit that references this issue on Sep 12, 2023
    f75daab
  13. GeoffreyBooth commented on Sep 14, 2023

    @GeoffreyBooth
  14. locked as resolved and limited conversation to collaborators on Sep 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions