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 babel config doesn't support experimental syntax 'decoratorAutoAccessors' #2057

Open
1 of 3 tasks
lscheibel opened this issue Oct 18, 2024 · 0 comments
Open
1 of 3 tasks

Comments

@lscheibel
Copy link

Describe the bug
When running lingui extract in a codebase that uses decoratorAutoAccessors, babel will throw a Syntax Error: Support for the experimental syntax 'decoratorAutoAccessors' isn't currently enabled.

Babel config used during extraction:

Babel configs on "<...>.ts" (ascending priority):
programmatic options
{
  "code": false,
  "babelrc": false,
  "configFile": false,
  "filename": "/Users/lscheibel/Projects/floor-plan-editor/src/tools/Poly.ts",
  "parserOpts": {
    "plugins": [
      "importAttributes",
      "explicitResourceManagement",
      "typescript",
      "decorators-legacy"
    ]
  },
  "plugins": [
    [
      "macros",
      {
        "lingui": {
          "extract": true,
          "linguiConfig": {
            "catalogs": [
              {
                "path": "/Users/lscheibel/Projects/floor-plan-editor/src/locales/{locale}",
                "include": [
                  "src"
                ]
              }
            ],
            "catalogsMergePath": "",
            "compileNamespace": "cjs",
            "compilerBabelOptions": {
              "minified": true,
              "jsescOption": {
                "minimal": true
              }
            },
            "extractorParserOptions": {
              "tsExperimentalDecorators": true
            },
            "fallbackLocales": {},
            "format": "po",
            "formatOptions": {
              "origins": true,
              "lineNumbers": true
            },
            "locales": [
              "en",
              "de"
            ],
            "orderBy": "messageId",
            "pseudoLocale": "",
            "rootDir": "/Users/lscheibel/Projects/floor-plan-editor",
            "runtimeConfigModule": {
              "i18nImportModule": "@lingui/core",
              "i18nImportName": "i18n",
              "TransImportModule": "@lingui/react",
              "TransImportName": "Trans"
            },
            "sourceLocale": "",
            "service": {
              "name": "",
              "apiKey": ""
            }
          }
        }
      }
    ],
    [
      "[Function: function index({ types: t }) {\n  let localTransCom ... ]",
      {}
    ]
  ]
}
-----End Babel configs-----

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

class Example {
    accessor myProperty = 5;
}

Expected behavior
In my case I'd simply expect lingui extract to properly handle accessor syntax, however in the bigger picture I'd expect the extracter to parse the code with the same config that I've defined in my vite.config.ts (in this case). At the very least allowing me to specify the babel config used during extraction would already go a long way.

Additional context
Note that the decoratorAutoAccessors syntax is popular with modern MobX codebases.

  • jsLingui version lingui --version: 4.13.0
  • Babel version npm list @babel/core
<...>@0.0.0 <...>
├─┬ @babel/[email protected]
│ ├─┬ @babel/[email protected]
│ │ └─┬ @babel/[email protected]
│ │   └── @babel/[email protected] deduped
│ ├─┬ @babel/[email protected]
│ │ ├── @babel/[email protected] deduped
│ │ └─┬ @babel/[email protected]
│ │   └── @babel/[email protected] deduped
│ └─┬ @babel/[email protected]
│   └── @babel/[email protected] deduped
├─┬ @lingui/[email protected]
│ └── @babel/[email protected] deduped
├─┬ @vitejs/[email protected]
│ ├── @babel/[email protected] deduped
│ ├─┬ @babel/[email protected]
│ │ └── @babel/[email protected] deduped
│ └─┬ @babel/[email protected]
│   └── @babel/[email protected] deduped
└─┬ [email protected]
  ├─┬ @svgr/[email protected]
  │ ├── @babel/[email protected] deduped
  │ └─┬ @svgr/[email protected]
  │   ├── @babel/[email protected] deduped
  │   ├─┬ @svgr/[email protected]
  │   │ └── @babel/[email protected] deduped
  │   ├─┬ @svgr/[email protected]
  │   │ └── @babel/[email protected] deduped
  │   ├─┬ @svgr/[email protected]
  │   │ └── @babel/[email protected] deduped
  │   ├─┬ @svgr/[email protected]
  │   │ └── @babel/[email protected] deduped
  │   ├─┬ @svgr/[email protected]
  │   │ └── @babel/[email protected] deduped
  │   ├─┬ @svgr/[email protected]
  │   │ └── @babel/[email protected] deduped
  │   ├─┬ @svgr/[email protected]
  │   │ └── @babel/[email protected] deduped
  │   └─┬ @svgr/[email protected]
  │     └── @babel/[email protected] deduped
  └─┬ @svgr/[email protected]
    └── @babel/[email protected] deduped
  • Macro support:
  • I'm using SWC with @lingui/swc-plugin
  • I'm using Babel with babel-macro-plugin: "babel-plugin-macros": "^3.1.0"
  • I'm not using macro
  • Your Babel config (e.g. .babelrc) or framework you use (Create React App, NextJs, Vite)
    Vite with plugin-react: react({ babel: { plugins: [['@babel/plugin-proposal-decorators', { version: '2023-11' }], 'macros'] } }),
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

No branches or pull requests

1 participant