We have a NX Monorepo for a complex application. Recent change request from our client introduced couple of changes and one micro FE application was practically duplicated.
It consists of multiple libraries, imported using lazy-loading approach. Everything works fine, but I wanted to move the translation files from APP space to SHARED libraries space. And I'm getting an error when I try to import the translation file.
@NgModule({
declarations: [],
imports: [CommonModule, RouterModule.forChild(routes)],
providers: [
{
provide: TRANSLOCO_SCOPE,
useValue: {
scope: 'etc',
// Error: Module not found: Error: Can't resolve '@clientName/shared/assets/i18n' in ...
// loader: InlineLoaderFactory((lang: string) => import(`@clientName/shared/assets/i18n/${lang}.json`)),
// Relative path works, but I don't like it
loader: InlineLoaderFactory((lang: string) => import(`../../../../../libs/shared/assets/i18n/${lang}.json`)),
alias: 'etc'
}
}
]
})
export class RemoteEntryModule {}
// InlineLoaderFactor
import { Translation } from '@ngneat/transloco';
const SUPPORTED_LANG = ['en', 'de'] as const;
export function InlineLoaderFactory(loader: (lang: string) => Promise<any>) {
return SUPPORTED_LANG.reduce((acc: Translation, lang: string) => {
acc[lang] = () => loader(lang);
return acc;
}, {});
}
Is there a way to use path alias the way I imagined, or is my idea doomed from the start?