question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Moving components into packages of a monorepo breaks the babelifiedMessages

See original GitHub issue

Hi @nbouvrette Nicolas

have you ever done some work in a monorepo?

I have changed our codebase and some of the translated components are moved into a packages folder in second workplace.

If you use inside a component from packages/components:

import { getMessages } from 'next-multilingual/messages';

it will break the main process due to:

function getBabelifiedMessages(sourceFilePath) {
    var parsedSourceFile = path.parse(sourceFilePath);
    var sourceFileDirectoryPath = parsedSourceFile.dir;
...

while sourceFileDirectoryPath is relative (missing root).

I just made a quick fix into the node_modules js file

if (sourceFileDirectoryPath.startsWith('Users/')) sourceFileDirectoryPath = '/' + sourceFileDirectoryPath;

which does the work now on my machine.

I am thinking if a path translator should be added in the plugin configuration like imports from webpack or paths from tsconfig.json

like:

  pluginConfiguration: [
    "next-multilingual/messages/babel-plugin",
    {
      applicationId: appId,
      ...,
      paths: {
        "Users/"; "/Users/"
      }
    }
  ]

or if it just should check if relative path exists and if not try as full path.

Thanks for feedback and hopefully you are fine

Tom

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:29 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
nbouvrettecommented, Nov 14, 2022

@TomFreudenberg I’ll close this issue for now, please ping me on Twitter or open up another discussion if you need anything.

1reaction
nbouvrettecommented, Oct 30, 2022

OK cool and I still had a few thing in our backlog that we never got to. Not sure if they would help or not at this point but keep me posted!

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Example needed] i18n with Next.js 13 and `app` directory
TomFreudenberg mentioned this issue on Nov 3. Moving components into packages of a monorepo breaks the babelifiedMessages Avansai/next-multilingual#38.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found