refactor: proper macro browser shim#2433
Merged
andrii-bodnar merged 7 commits intonextfrom Feb 5, 2026
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
timofei-iatsenko
commented
Feb 4, 2026
Comment on lines
+39
to
+42
| "./macro": { | ||
| "browser": "./macro/browser.cjs", | ||
| "types": "./macro/index.d.cts", | ||
| "default": "./macro/index.cjs" |
Collaborator
Author
There was a problem hiding this comment.
since there are two diffrent implementations under conditions we have to sepcify type explicitly, otherwise typescript is confused
size-limit report 📦
|
timofei-iatsenko
commented
Feb 4, 2026
Comment on lines
-62
to
-69
| "peerDependencies": { | ||
| "babel-plugin-macros": "2 || 3" | ||
| }, | ||
| "peerDependenciesMeta": { | ||
| "babel-plugin-macros": { | ||
| "optional": true | ||
| } | ||
| }, |
Collaborator
Author
There was a problem hiding this comment.
i moved macro creation from this package to upstream core/react, they also defining the babel-plugin-macros as peer
timofei-iatsenko
commented
Feb 5, 2026
Comment on lines
+134
to
+137
| t: { | ||
| (descriptor: MacroMessageDescriptor): string | ||
| (literals: TemplateStringsArray, ...placeholders: any[]): string | ||
| } |
Collaborator
Author
There was a problem hiding this comment.
I found that _t function type declaration was public (available for import from the package) which is not correct as it's a helper type for useLingui, i changed the definition so it's no longer exported
andrii-bodnar
approved these changes
Feb 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Previously, the Vite plugin contained hacks to prevent macro implementation code from being pulled into the bundle. These hacks were also used to detect and warn when a macro was used incorrectly (eq. when the macro plugin was not configured).
In this PR, I replaced that approach with a more robust, bundler-agnostic solution for detecting incorrect macro usage. Instead of performing this check inside the Vite plugin, the logic is now implemented using package exports conditions:
This allows us to surface a clear warning when macros are used without proper setup, without relying on bundler-specific behavior.
As a result, the solution should work consistently across modern bundlers (Vite, Webpack, Rspack, esbuild, etc.), rather than being limited to Vite only.
Sidechange
I also found few more places where absolute version left instead of
workspace:*protocol.ESM Migration
This change deleted the last place in the
babel-plugin-lingui-macroused CJS syntax, and i was able to switch package to ESM only.Types of changes
Fixes # (issue)
Checklist