Skip to content

fix: respect corePackage/jsxPackage setting in experimental extractor#2579

Closed
mogelbrod wants to merge 1 commit into
lingui:mainfrom
mogelbrod:experimental-extractor-macro-detection
Closed

fix: respect corePackage/jsxPackage setting in experimental extractor#2579
mogelbrod wants to merge 1 commit into
lingui:mainfrom
mogelbrod:experimental-extractor-macro-detection

Conversation

@mogelbrod

@mogelbrod mogelbrod commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Description

This PR updates the experimental extractor (lingui extract-experimental) to respect the macro.corePackage / macro.jsxPackage settings.

Up until now it only considers files that import directly from @lingui/*/macro for extraction using a hardcoded regex (/from ["']@lingui(\/.+)?\/macro["']/).

Fix

The pre-filter is now built from the configured macro packages (macro.corePackage + macro.jsxPackage) in addition to the built-in @lingui/*/macro entrypoints (kept for backwards compatibility, so the default config and the legacy @lingui/macro package keep working even when a project overrides corePackage/jsxPackage). The regex is also built once per plugin instance instead of per file, which removes a latent RegExp-with-/g + .test() lastIndex statefulness bug.

Tests

Added an integration test should extract messages imported from a configured custom macro package with a new fixture (packages/cli/test/extractor-experimental-custom-macro) that imports t, msg and <Trans> through a #macros subpath barrel declared in macro.corePackage / macro.jsxPackage, and asserts all three messages are extracted. The test fails on main (no messages extracted) and passes with this change. Existing extractor-experimental tests continue to pass, covering the backwards-compatible default behavior.

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

vercel Bot commented Jun 18, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
js-lingui Ready Ready Preview Jun 18, 2026 9:11am

Request Review

@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.79%. Comparing base (6bb8983) to head (136a9dd).
⚠️ Report is 354 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2579       +/-   ##
===========================================
+ Coverage   77.05%   89.79%   +12.74%     
===========================================
  Files          84      124       +40     
  Lines        2157     3694     +1537     
  Branches      555     1109      +554     
===========================================
+ Hits         1662     3317     +1655     
+ Misses        382      339       -43     
+ Partials      113       38       -75     

☔ View full report in Codecov by Harness.
📢 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.

@timofei-iatsenko

Copy link
Copy Markdown
Collaborator

This is already covered in this complete rework of experimental extractor: #2572

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