Skip to content

Commit

Permalink
feat(angular): support alternate remote entry filenames nrwl#10206
Browse files Browse the repository at this point in the history
  • Loading branch information
Coly010 committed May 23, 2022
1 parent e439718 commit 98c14d9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
14 changes: 10 additions & 4 deletions packages/angular/src/utils/mfe/with-module-federation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,18 @@ function mapRemotes(remotes: MFERemotes) {

for (const remote of remotes) {
if (Array.isArray(remote)) {
const remoteLocation = remote[1].match(/remoteEntry\.(js|mjs)/)
? remote[1]
const [remoteName, remoteLocation] = remote;
const javascriptFileAfterLastSlashRegex =
/((.+(\.(js|mjs)))*)[\/]((.+(\.(js|mjs)))*)$/;
mappedRemotes[remoteName] = remoteLocation.match(
javascriptFileAfterLastSlashRegex
)
? remoteLocation
: `${
remote[1].endsWith('/') ? remote[1].slice(0, -1) : remote[1]
remoteLocation.endsWith('/')
? remoteLocation.slice(0, -1)
: remoteLocation
}/remoteEntry.mjs`;
mappedRemotes[remote[0]] = remoteLocation;
} else if (typeof remote === 'string') {
mappedRemotes[remote] = determineRemoteUrl(remote);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ export default async function* moduleFederationDevServer(
: [options.devRemotes];

for (const app of knownRemotes) {
const isDev = devServeApps.includes(app);
const [appName] = Array.isArray(app) ? app : [app];
const isDev = devServeApps.includes(appName);
iter = combineAsyncIterators(
iter,
await runExecutor(
{
project: app,
project: appName,
target: isDev ? 'serve' : 'serve-static',
configuration: context.configurationName,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import {
SharedFunction,
SharedLibraryConfig,
} from './models';
import ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin');
import { readRootPackageJson } from './package-json';
import ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin');

function collectDependencies(
projectGraph: ProjectGraph,
Expand Down Expand Up @@ -131,7 +131,9 @@ function mapRemotes(remotes: Remotes) {
for (const remote of remotes) {
if (Array.isArray(remote)) {
let [remoteName, remoteLocation] = remote;
if (!remoteLocation.match(/remoteEntry\.(js|mjs)$/)) {
const javascriptFileAfterLastSlashRegex =
/((.+(\.(js|mjs)))*)[\/]((.+(\.(js|mjs)))*)$/;
if (!remoteLocation.match(javascriptFileAfterLastSlashRegex)) {
remoteLocation = `${
remoteLocation.endsWith('/')
? remoteLocation.slice(0, -1)
Expand Down

0 comments on commit 98c14d9

Please sign in to comment.