When I run 'lingui extract' I receve this message error:
Error: Usingbabel-preset-react-apprequires that you specifyNODE_ENVorBABEL_ENVenvironment variables. Valid values are "development", "test", and "production". Instead, received: undefined.
'lingui extract' work only with this setup: 'NODE_ENV=production lingui extract'
Is it a bug?
What's the problem?
Hey @ccamusso,
what's your setup? I guess you're using CRA with own .babelrc? Could you please paste it here?
In attach you find my package.json
I dont'use .babelrc file, all babel configuration is in package.json
Hi @ccamusso,
sorry for delayed response. You're right, we need to set NODE_ENV manually in lingui extract.
As a workaround (as you said), run it with NODE_ENV=development lingui extract'
I will suggest to check if environment variables are set, if not, show a red warning and set production. Why production? You will be surprised early which is more friendly then late.
Create React App uses development env for everything except for build. Ideally we should handle this without a warning, because CRA handles it under the hood without user's interference.
I'm trying to come up with scenario, when extracting messages in development env would be harmful (or in production)... It seems that for our usecase (extracting messages from source), there's no difference. Setting env to production might be after all safer option.
Ideas welcome!
I want to close this with upcoming 3.0 release, which will have better support for CRA.
Update: The env will be set to development after all.
I'm working on new version of plugins/macros and in production mode they will remove all unnecessary attributes, like description and defaults. These attributes are used only offline (either in message catalogs as a hint for translators or during compile), but they aren't needed in production.
Released in v2.6.0
Most helpful comment
Create React App uses
developmentenv for everything except for build. Ideally we should handle this without a warning, because CRA handles it under the hood without user's interference.I'm trying to come up with scenario, when extracting messages in
developmentenv would be harmful (or inproduction)... It seems that for our usecase (extracting messages from source), there's no difference. Setting env toproductionmight be after all safer option.Ideas welcome!
I want to close this with upcoming 3.0 release, which will have better support for CRA.