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 5ba58b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 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,14 @@ 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;
mappedRemotes[remoteName] = remoteLocation.match(/([^\/]+(\.(js|mjs)))*/)
? 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 @@ -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,7 @@ function mapRemotes(remotes: Remotes) {
for (const remote of remotes) {
if (Array.isArray(remote)) {
let [remoteName, remoteLocation] = remote;
if (!remoteLocation.match(/remoteEntry\.(js|mjs)$/)) {
if (!remoteLocation.match(/([^\/]+(\.(js|mjs)))*/)) {
remoteLocation = `${
remoteLocation.endsWith('/')
? remoteLocation.slice(0, -1)
Expand Down

0 comments on commit 5ba58b7

Please sign in to comment.