Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lingui extract ignores babel config #2003

Closed
3 tasks
valyagolev opened this issue Aug 16, 2024 · 2 comments · Fixed by #2009
Closed
3 tasks

Lingui extract ignores babel config #2003

valyagolev opened this issue Aug 16, 2024 · 2 comments · Fixed by #2009

Comments

@valyagolev
Copy link

Describe the bug
Lingui extract can't process some of my files, with an error telling me that I need to update babel config. However, it ignores babel config (both .babelrc and babel.config.json).

To Reproduce
Create .babelrc. Run BABEL_SHOW_CONFIG_FOR=some_file_in_repo lingui extract. Witness the config is not picked up.

Expected behavior
The babel config is respected, or - better - can be configured through lingui.config.json.

Additional context
Error:

Cannot process file .../src/lib/ai/strategies/events1.ts: Support for the experimental syntax 'importAttributes' isn't currently enabled (12:70):

> 12 | import ActionsSchema from "@/lib/ai/strategies/schemas/actions.json" assert { type: "json" };


Add @babel/plugin-syntax-import-attributes (https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-import-attributes) to the 'plugins' section of your Babel config to enable parsing.

If you already added the plugin for this syntax to your config, it's possible that your config isn't being loaded.
You can re-run Babel with the BABEL_SHOW_CONFIG_FOR environment variable to show the loaded configuration:
        npx cross-env BABEL_SHOW_CONFIG_FOR=.../src/lib/ai/strategies/events1.ts <your build command>
See https://babeljs.io/docs/configuration#print-effective-configs for more info.

SyntaxError: .../src/lib/ai/strategies/events1.ts: Support for the experimental syntax 'importAttributes' isn't currently enabled (12:70):
  • jsLingui version lingui --version: 9.3.1
  • Babel version npm list @babel/core @babel/core@7.25.2
  • Macro support:
  • I'm using SWC with @lingui/swc-plugin
  • I'm using Babel with babel-macro-plugin
  • I'm not using macro
  • Your Babel config (e.g. .babelrc) or framework you use (Create React App, NextJs, Vite)
@timofei-iatsenko
Copy link
Collaborator

That's intended, more info here:

https://lingui.dev/guides/message-extraction#supported-source-types
#1367
#1719

I think you have a newer import syntax in your files which is not supported by babel version used in lingui. What we can do in that case is update babel to support new features which became stage3

@valyagolev
Copy link
Author

@thekip I see, thanks. I'll just ignore those files for now, but will happily try the version with the updated babel

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 a pull request may close this issue.

2 participants