You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Aliasing Trans import from '@lingui/react' when '@lingui/macro' is present produces the following error:
Uncaught ReferenceError: Trans is not defined
To Reproduce
Let's assume there is a component translating both direct text and some outside data. When aliasing runtime Trans the error is produced:
import{Trans}from'@lingui/macro';import{TransasTransRuntime}from'@lingui/react';// aliasing here so the names don't collideconstdata=[msg`Foo`,msg`Bar`];exportdefaultfunctionApp(){return(<div><Trans>Direct text</Trans> // <-UncaughtReferenceError: Transisnotdefined{data.map(el=><TransRuntimeid={el.id}/>)}</div>
);
}
From what I've tried, it happens only when runtime Trans is aliased:
import{TransasTransMacro}from'@lingui/macro';// aliased macro Trans instead, error is goneimport{Trans}from'@lingui/react';
// aliasing both, error is thrown by TransMacroimport{TransasTransMacro}from'@lingui/macro'import{TransasTransRuntime}from'@lingui/react';
Although there is a workaround, no explicit error is shown when we incorrectly alias the components, making it hard to fix. I think it should be possible to name both imports freely.
Additional context
jsLingui version: 4.7.0
Babel version: 7.23.9
Macro support:
I'm using SWC with @lingui/swc-plugin
I'm using Babel with babel-macro-plugin
I'm not using macro
Using Vite with babel, config: { plugins: ['macros'] }
The text was updated successfully, but these errors were encountered:
Describe the bug
Aliasing Trans import from '@lingui/react' when '@lingui/macro' is present produces the following error:
To Reproduce
Let's assume there is a component translating both direct text and some outside data. When aliasing runtime Trans the error is produced:
From what I've tried, it happens only when runtime Trans is aliased:
Although there is a workaround, no explicit error is shown when we incorrectly alias the components, making it hard to fix. I think it should be possible to name both imports freely.
Additional context
@lingui/swc-plugin
babel-macro-plugin
{ plugins: ['macros'] }
The text was updated successfully, but these errors were encountered: