Giter Club home page Giter Club logo

Comments (7)

thekip avatar thekip commented on June 28, 2024

You need babel-plugin-macros to be installed and added to babel config. You do use macro. Any import from @lingui/macro is a macro (virtual methods which get transpiled to something else during build)

from js-lingui.

stoefln avatar stoefln commented on June 28, 2024

@thekip thanks for your quick help!
I installed the plugin and added it to the .babelrc, now I am getting this error

ERROR in ./app/main.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: /Users/steph/Workspace/myapp-studio/app/main.js: Cannot find module '@lingui/macro' from '/Users/steph/Workspace/myapp-studio/app'
    at Function.resolveSync [as sync] (/Users/steph/Workspace/myapp-studio/node_modules/resolve/lib/sync.js:111:15)
    at nodeResolvePath (/Users/steph/Workspace/myapp-studio/node_modules/babel-plugin-macros/dist/index.js:62:18)
    at applyMacros (/Users/steph/Workspace/myapp-studio/node_modules/babel-plugin-macros/dist/index.js:203:23)
    at ImportDeclaration (/Users/steph/Workspace/myapp-studio/node_modules/babel-plugin-macros/dist/index.js:110:28)
    at NodePath._call (/Users/steph/Workspace/myapp-studio/node_modules/@babel/traverse/lib/path/context.js:46:20)
    at NodePath.call (/Users/steph/Workspace/myapp-studio/node_modules/@babel/traverse/lib/path/context.js:36:17)
    at NodePath.visit (/Users/steph/Workspace/myapp-studio/node_modules/@babel/traverse/lib/path/context.js:82:31)
    at TraversalContext.visitQueue (/Users/steph/Workspace/myapp-studio/node_modules/@babel/traverse/lib/context.js:86:16)
    at TraversalContext.visitMultiple (/Users/steph/Workspace/myapp-studio/node_modules/@babel/traverse/lib/context.js:61:17)
    at TraversalContext.visit (/Users/steph/Workspace/myapp-studio/node_modules/@babel/traverse/lib/context.js:107:19)
    at traverseNode (/Users/steph/Workspace/myapp-studio/node_modules/@babel/traverse/lib/traverse-node.js:22:17)
    at traverse (/Users/steph/Workspace/myapp-studio/node_modules/@babel/traverse/lib/index.js:52:34)
    at NodePath.traverse (/Users/steph/Workspace/myapp-studio/node_modules/@babel/traverse/lib/path/index.js:101:24)
    at PluginPass.Program (/Users/steph/Workspace/myapp-studio/node_modules/babel-plugin-macros/dist/index.js:91:18)
    at newFn (/Users/steph/Workspace/myapp-studio/node_modules/@babel/traverse/lib/visitors.js:160:14)
    at NodePath._call (/Users/steph/Workspace/myapp-studio/node_modules/@babel/traverse/lib/path/context.js:46:20)
    at NodePath.call (/Users/steph/Workspace/myapp-studio/node_modules/@babel/traverse/lib/path/context.js:36:17)
    at NodePath.visit (/Users/steph/Workspace/myapp-studio/node_modules/@babel/traverse/lib/path/context.js:82:31)
    at TraversalContext.visitQueue (/Users/steph/Workspace/myapp-studio/node_modules/@babel/traverse/lib/context.js:86:16)
    at TraversalContext.visitSingle (/Users/steph/Workspace/myapp-studio/node_modules/@babel/traverse/lib/context.js:65:19)
    at TraversalContext.visit (/Users/steph/Workspace/myapp-studio/node_modules/@babel/traverse/lib/context.js:109:19)
    at traverseNode (/Users/steph/Workspace/myapp-studio/node_modules/@babel/traverse/lib/traverse-node.js:22:17)
    at traverse (/Users/steph/Workspace/myapp-studio/node_modules/@babel/traverse/lib/index.js:52:34)
    at transformFile (/Users/steph/Workspace/myapp-studio/node_modules/@babel/core/lib/transformation/index.js:82:31)
    at transformFile.next (<anonymous>)
    at run (/Users/steph/Workspace/myapp-studio/node_modules/@babel/core/lib/transformation/index.js:24:12)
    at run.next (<anonymous>)
    at transform (/Users/steph/Workspace/myapp-studio/node_modules/@babel/core/lib/transform.js:22:33)
    at transform.next (<anonymous>)
    at step (/Users/steph/Workspace/myapp-studio/node_modules/gensync/index.js:261:32)
    at /Users/steph/Workspace/myapp-studio/node_modules/gensync/index.js:273:13
    at async.call.result.err.err (/Users/steph/Workspace/myapp-studio/node_modules/gensync/index.js:223:11)
    at /Users/steph/Workspace/myapp-studio/node_modules/gensync/index.js:189:28
    at /Users/steph/Workspace/myapp-studio/node_modules/@babel/core/lib/gensync-utils/async.js:67:7
    at /Users/steph/Workspace/myapp-studio/node_modules/gensync/index.js:113:33
    at step (/Users/steph/Workspace/myapp-studio/node_modules/gensync/index.js:287:14)
    at /Users/steph/Workspace/myapp-studio/node_modules/gensync/index.js:273:13
    at async.call.result.err.err (/Users/steph/Workspace/myapp-studio/node_modules/gensync/index.js:223:11)
 @ multi ./node_modules/@pmmmwh/react-refresh-webpack-plugin/client/ReactRefreshEntry.js ./node_modules/@pmmmwh/react-refresh-webpack-plugin/client/ErrorOverlayEntry.js?sockHost=localhost&sockPort=3000&sockProtocol=http ./node_modules/@pmmmwh/react-refresh-webpack-plugin/client/ReactRefreshEntry.js ./node_modules/@pmmmwh/react-refresh-webpack-plugin/client/ErrorOverlayEntry.js?sockHost=localhost&sockPort=3000&sockProtocol=http @babel/polyfill ./app/main.js main[5]

My .babelrc now:

{
  "presets": ["@babel/preset-env", "@babel/preset-react"],
  "env": {
    "production": {
      "plugins": [
        "macros",
        ["@babel/plugin-proposal-decorators", { "legacy": true }],
        "@babel/plugin-proposal-class-properties",
        "@babel/plugin-syntax-optional-chaining"
      ]
    },
    "development": {
      "plugins": [
        "macros",
        [ "@babel/plugin-proposal-decorators", { "legacy": true }],
        "@babel/plugin-proposal-class-properties",
        "@babel/plugin-syntax-optional-chaining",
        "react-refresh/babel",
        [
          "i18next-extract",
          {
            "locales": ["en", "de"],
            "defaultNS": "common",
            "keySeparator": null,
            "nsSeparator": "::",
            "defaultValue": null
          }
        ]
      ]
    },
    "test": {
      "plugins": [
        ["@babel/plugin-proposal-decorators", { "legacy": true }],
        "@babel/plugin-proposal-class-properties",
        "@babel/plugin-syntax-optional-chaining",
        "i18next-extract",
        [
          "@babel/plugin-transform-runtime",
          {
            "regenerator": true
          }
        ]
      ]
    }
  }
}

from js-lingui.

thekip avatar thekip commented on June 28, 2024

Have you installed @lingui/macro?

from js-lingui.

stoefln avatar stoefln commented on June 28, 2024

Yes, sure. v4.7.1

from js-lingui.

thekip avatar thekip commented on June 28, 2024

Unfortunately, i couldn't help with the issue without a reproduction repo.

from js-lingui.

stoefln avatar stoefln commented on June 28, 2024

Could you maybe still reopen the issue? Someone else might be able to help...

from js-lingui.

thekip avatar thekip commented on June 28, 2024

@stoefln check your configuration. It's 100% problem in your setup, not in the Lingui. Go through one of examples and compare to your setup. No one will to debug your code instead of you.

from js-lingui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.