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

Migrate package to ESM #268

Merged
merged 6 commits into from
Oct 17, 2024
Merged

Migrate package to ESM #268

merged 6 commits into from
Oct 17, 2024

Conversation

connor-baer
Copy link
Member

Purpose

We're full-speed ahead on the migration to ES modules. This migration is inevitable anyway, and the ecosystem seems ready enough at this point (especially after #2053).

Sindre Sorhus has published an extremely helpful guide for pure ESM packages which I referenced throughout the migration.

Approach and changes

  • Module resolution: ESM requires imports to use the full path to a file, including the file name (even for index files) and the file extension.
  • package.json fields:
    • Added "type": "module" to the package:

      A package.json "type" value of "module" tells Node.js to interpret .js files within that package as using ES module syntax.

    • Switched to the "exports" field to configure the package entry point(s):

      The "exports" provides a modern alternative to "main" allowing multiple entry points to be defined, conditional entry resolution support between environments, and preventing any other entry points besides those defined in "exports".

    • Configured the "engines" field to require Node.js 18+, the first version of Node with full support for ES modules.

Definition of done

  • Development completed
  • Reviewers assigned
  • Unit and integration tests
  • Meets minimum browser support
  • Meets accessibility requirements

Copy link

changeset-bot bot commented Oct 17, 2024

🦋 Changeset detected

Latest commit: dbdf233

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sumup-oss/intl Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

codecov bot commented Oct 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.46%. Comparing base (e8f0005) to head (dbdf233).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #268   +/-   ##
=======================================
  Coverage   93.46%   93.46%           
=======================================
  Files          15       15           
  Lines         689      689           
  Branches       85       88    +3     
=======================================
  Hits          644      644           
  Misses         43       43           
  Partials        2        2           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@connor-baer connor-baer changed the title Convert the package to an ES module Migrate package to ESM Oct 17, 2024
@connor-baer connor-baer marked this pull request as ready for review October 17, 2024 08:36
@connor-baer connor-baer requested a review from sirineJ October 17, 2024 08:37
@connor-baer connor-baer merged commit 3d4219e into main Oct 17, 2024
4 checks passed
@connor-baer connor-baer deleted the feature/es-module branch October 17, 2024 09:07
@connor-baer connor-baer mentioned this pull request Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants