Skip to content

yarn extract errors when using next/babel preset and JSX inside .js files. #1638

@adamsoderstrom

Description

@adamsoderstrom

Describe the bug
yarn extract errors when using next/babel babel preset and JSX inside .js files.

To Reproduce
Steps to reproduce the behavior, possibly with minimal code sample, e.g:

  1. Navigate to the nextjs-babel directory in this repo.
  2. Create a JSX file with extension .js
// Button.js
export default function Button() {
   return <button>Click me</button>
}
  1. Run yarn extract
  2. You get the following error:
Add @babel/preset-react (https://github.com/babel/babel/tree/main/packages/babel-preset-react) to the 'presets' section of your Babel config to enable transformation.
If you want to leave it as-is, add @babel/plugin-syntax-jsx (https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-jsx) to the 'plugins' section to enable parsing.

✖
Catalog statistics for src/locales/{locale}:
┌──────────┬─────────────┬─────────┐
│ Language │ Total count │ Missing │
└──────────┴─────────────┴─────────┘

(use "yarn extract" to update catalogs with new messages)
(use "yarn compile" to compile catalogs for production)

Expected behavior
yarn extract shouldn't render the

Additional context
Add any other context about the problem here.

  • jsLingui version lingui --version -
    4.0.0-next.3

  • Babel version npm list @babel/core
    ext-js-babel@0.1.0
    └─┬ @lingui/cli@4.0.0-next.3
    └─┬ @babel/core@7.21.3
    └─┬ @babel/helper-compilation-targets@7.20.7
    └── @babel/core@7.21.3 deduped

  • Macro support:

  • I'm using SWC with @lingui/swc-plugin

  • I'm using Babel with babel-macro-plugin

  • I'm not using macro

  • NextJs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions