Moving components into packages of a monorepo breaks the babelifiedMessages
See original GitHub issueHi @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:
- Created a year ago
- Comments:29 (15 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@TomFreudenberg I’ll close this issue for now, please ping me on Twitter or open up another discussion if you need anything.
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!