Skip to content

Commit

Permalink
fix(module-federation): ensure mf-manifest supported and tspaths are …
Browse files Browse the repository at this point in the history
…added with snake_case
  • Loading branch information
Coly010 committed Oct 2, 2024
1 parent 5a41154 commit 37b05cd
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,11 @@ function addLazyLoadedRouteToHostAppModule(
: 'RemoteEntryModule';
const routeToAdd =
hostFederationType === 'dynamic'
? `loadRemoteModule('${options.appName}', './${routePathName}')`
: `import('${options.appName}/${routePathName}')`;
? `loadRemoteModule('${options.appName.replace(
/-/g,
'_'
)}', './${routePathName}')`
: `import('${options.appName.replace(/-/g, '_')}/${routePathName}')`;

addRoute(
tree,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function setupTspathForRemote(tree: Tree, options: Schema) {

const exportName = options.standalone ? 'Routes' : 'Module';

addTsConfigPath(tree, `${options.appName}/${exportName}`, [
addTsConfigPath(tree, `${options.appName.replace(/-/g, '_')}/${exportName}`, [
joinPathFragments(project.root, exportPath),
]);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ export function setupTspathForRemote(tree: Tree, options: NormalizedSchema) {

const exportName = 'Module';

addTsConfigPath(tree, `${options.projectName}/${exportName}`, [
joinPathFragments(project.root, exportPath),
]);
addTsConfigPath(
tree,
`${options.projectName.replace(/-/g, '_')}/${exportName}`,
[joinPathFragments(project.root, exportPath)]
);
}
2 changes: 1 addition & 1 deletion packages/rspack/src/utils/module-federation/remotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function handleArrayRemote(
const remoteLocationExt = extname(remoteLocation);

// If remote location already has .js or .mjs extension
if (['.js', '.mjs'].includes(remoteLocationExt)) {
if (['.js', '.mjs', '.json'].includes(remoteLocationExt)) {
return remoteLocation;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/webpack/src/utils/module-federation/remotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function handleArrayRemote(
const remoteLocationExt = extname(remoteLocation);

// If remote location already has .js or .mjs extension
if (['.js', '.mjs'].includes(remoteLocationExt)) {
if (['.js', '.mjs', '.json'].includes(remoteLocationExt)) {
return remoteLocation;
}

Expand Down Expand Up @@ -102,7 +102,7 @@ export function mapRemotesForSSR(
remoteName = normalizeRemoteName(remoteName);
const remoteLocationExt = extname(remoteLocation);
mappedRemotes[remoteName] = `${remoteName}@${
['.js', '.mjs'].includes(remoteLocationExt)
['.js', '.mjs', '.json'].includes(remoteLocationExt)
? remoteLocation
: `${
remoteLocation.endsWith('/')
Expand Down

0 comments on commit 37b05cd

Please sign in to comment.