Open timofei-iatsenko opened 1 month ago
Would really appreciate supress_stripping_message
because right now I'm having to patch this line in the @lingui/macro package const stripNonEssentialProps = false; // process.env.NODE_ENV == "production" && !opts.extract;
to keep the message values available so I can do something like this
const SOME_TEXT = msg`Some text`;
const object = {
originalValue: SOME_TEXT.message,
translatedValue: _(SOME_TEXT)
}
You don't need to patch, this is a configurable parameter. You can either use pre-release v5 version where macro is extracted to separate babel plugin and parameters could be passed directly to it, or use babel-plugin-macros
configuration as specified there: https://github.com/kentcdodds/babel-plugin-macros/blob/main/other/docs/user.md#config use lingui
for macro name
// babel-plugin-macros.config.js
module.exports = {
// ...
// Other macros config
lingui: {
extract: true,
},
}
hey @timofei-iatsenko, thanks for this info. Just curious, is using the babel-plugin-macros configuration for lingui and specifically that the extract property is an available property, documented anywhere in the documentation? I feel like I thoroughly reviewed it, and I didn't see this before.
It's not documented, it is used internally for extractor. Later I will create a documented parameter intended for public use as described here in the first message. But you can safely use this "extract" param, because it's not going to be changed any time soon.
Hmm I couldn't get it to work but maybe thats because I'm also in a monorepo and it's react native. I'll leave my patch in for now until you get the v5 fully released and tested 🙏
ToDo: motivation, related issues
Tasks:
Make configurable
strip_non_essential_fields
in the SWC plugin from outside. Now it's hardcoded to the ENV variablesupress_stripping_message
, which will allow strippingcontext
andcomment
but left message.Make the same options for Babel macro plugin
Make possible to register MessageCompiler in production, PR: https://github.com/lingui/js-lingui/pull/2035
Write the docs describing all configuration to achieve that.