Skip to content

chore: explicit "type" field in package.json and alignment for "exports"#2430

Merged
andrii-bodnar merged 11 commits intolingui:nextfrom
yslpn:chore/source-esm
Feb 4, 2026
Merged

chore: explicit "type" field in package.json and alignment for "exports"#2430
andrii-bodnar merged 11 commits intolingui:nextfrom
yslpn:chore/source-esm

Conversation

@yslpn
Copy link
Contributor

@yslpn yslpn commented Feb 1, 2026

Description

ESM migration: added "type": "module" to root and several packages. Removed unused Jest files, replaced strip-ansi with node:util.

Added explicit "type": "commonjs" to babel-plugin-lingui-macro, metro-transformer and remote-loader. Publint recommends explicitly specifying the type, for example https://publint.dev/@lingui/react@5.9.0

Note: website/ without ESM due to Docusaurus limitation facebook/docusaurus#6520

Removed legacy workarounds for older React Native versions that didn't support the "exports" field. Lingui supports React Native >= 0.73 (@lingui/metro-transformer peerDependencies). React Native 0.72+ supports "exports"

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Examples update

Checklist

  • I have read the CONTRIBUTING and CODE_OF_CONDUCT docs
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation (if appropriate)

@vercel
Copy link

vercel bot commented Feb 1, 2026

@yslpn is attempting to deploy a commit to the Crowdin Team on Vercel.

A member of the Team first needs to authorize it.

@codecov
Copy link

codecov bot commented Feb 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.74%. Comparing base (dd43fb0) to head (a2979ab).
⚠️ Report is 296 commits behind head on next.

Additional details and impacted files
@@             Coverage Diff             @@
##             next    #2430       +/-   ##
===========================================
+ Coverage   76.66%   88.74%   +12.07%     
===========================================
  Files          81      117       +36     
  Lines        2083     3297     +1214     
  Branches      532      972      +440     
===========================================
+ Hits         1597     2926     +1329     
+ Misses        375      333       -42     
+ Partials      111       38       -73     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yslpn yslpn marked this pull request as draft February 1, 2026 23:46
…ingui-macro, metro-transformer, and remote-loader
@yslpn yslpn marked this pull request as ready for review February 2, 2026 10:28
@yslpn yslpn changed the title chore: enable native ESM for development chore: explicit "type" field in package.json Feb 2, 2026
@yslpn yslpn changed the title chore: explicit "type" field in package.json chore: explicit "type" field in package.json and alignment for "exports" Feb 2, 2026
Comment on lines +31 to +34
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.mjs"
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically you don't need to specify a types condition for typescript. It will infer typings perfectly fine automatically.

In all places where i changed recently i did not use that, just for simplicity. So for consistency please simplify it to just:

".": "./dist/index.mjs"

here in all other places

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been reading the documentation, and it's true. Thanks

ref
https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-exports

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't specify types in exports, Ubuild won't generate them. I'll look at it in more detail later.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, i explicitly ask it to generate types with:

  "unbuild": {
    "declaration": "node16"
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about creating the config as a separate file in each package. It has type checking, and you can go to the source code and read the comments in the ts types. Plus, this adds consistency, as currently in some places there are separate configs (React), while in others you need to go to package json.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't spend too much time on this, it's likely possible that build pipeline would be replaced to nx in the near future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, good

@yslpn yslpn marked this pull request as draft February 2, 2026 11:27
@yslpn yslpn marked this pull request as ready for review February 3, 2026 10:27
@timofei-iatsenko
Copy link
Collaborator

@yslpn i fixed verdaccio script. but tests in the CRA is failing, better to know why that happend because the error looks weird to me.

@yslpn
Copy link
Contributor Author

yslpn commented Feb 3, 2026

@yslpn i fixed verdaccio script. but tests in the CRA is failing, better to know why that happend because the error looks weird to me.

I removed the old files needed by Jest 27
https://github.com/lingui/js-lingui/pull/2430/changes#diff-7da44f92d02898353f3d20536ca010c9f91f38b4b5df6e8d1d23fb9fd910f674

but I didn't notice that CRA uses Jest.

Do we support Jest 27? If so, I'll revert the removed files. If not, I'll add moduleNameMapper to CRA's package.json.

I previously proposed removing CRA from example maps. #2411 We can do that later.

Copy link
Collaborator

@timofei-iatsenko timofei-iatsenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, could be merged

@yslpn
Copy link
Contributor Author

yslpn commented Feb 4, 2026

chore: remove CRA, write tests for vite-babel example, correct macro exports #2432

Thank you

@andrii-bodnar andrii-bodnar added this to the v6 milestone Feb 4, 2026
@vercel
Copy link

vercel bot commented Feb 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
js-lingui Ready Ready Preview Feb 4, 2026 1:30pm

Request Review

@andrii-bodnar andrii-bodnar merged commit 7f98167 into lingui:next Feb 4, 2026
9 checks passed
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.

3 participants