fix(webpack): regression from #10432 to allow // prefix in remote (#12302)

This commit is contained in:
Wenchen Li 2022-09-29 23:16:50 +08:00 committed by GitHub
parent a592af1eb3
commit ba657da7c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View File

@ -4,7 +4,7 @@ import {
readCachedProjectGraph, readCachedProjectGraph,
} from '@nrwl/devkit'; } from '@nrwl/devkit';
import { readCachedProjectConfiguration } from 'nx/src/project-graph/project-graph'; import { readCachedProjectConfiguration } from 'nx/src/project-graph/project-graph';
import { extname, join } from 'path'; import { extname } from 'path';
import { import {
getNpmPackageSharedConfig, getNpmPackageSharedConfig,
SharedLibraryConfig, SharedLibraryConfig,
@ -59,7 +59,11 @@ function mapRemotes(remotes: MFRemotes) {
const remoteLocationExt = extname(remoteLocation); const remoteLocationExt = extname(remoteLocation);
mappedRemotes[remoteName] = ['.js', '.mjs'].includes(remoteLocationExt) mappedRemotes[remoteName] = ['.js', '.mjs'].includes(remoteLocationExt)
? remoteLocation ? remoteLocation
: join(remoteLocation, 'remoteEntry.mjs'); : `${
remoteLocation.endsWith('/')
? remoteLocation.slice(0, -1)
: remoteLocation
}/remoteEntry.mjs`;
} else if (typeof remote === 'string') { } else if (typeof remote === 'string') {
mappedRemotes[remote] = determineRemoteUrl(remote); mappedRemotes[remote] = determineRemoteUrl(remote);
} }

View File

@ -22,7 +22,7 @@ import {
SharedLibraryConfig, SharedLibraryConfig,
} from './models'; } from './models';
import { readRootPackageJson } from './package-json'; import { readRootPackageJson } from './package-json';
import { extname, join } from 'path'; import { extname } from 'path';
import ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin'); import ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin');
function collectDependencies( function collectDependencies(
@ -133,7 +133,11 @@ function mapRemotes(remotes: Remotes, projectGraph: ProjectGraph) {
const remoteLocationExt = extname(remoteLocation); const remoteLocationExt = extname(remoteLocation);
mappedRemotes[remoteName] = ['.js', '.mjs'].includes(remoteLocationExt) mappedRemotes[remoteName] = ['.js', '.mjs'].includes(remoteLocationExt)
? remoteLocation ? remoteLocation
: join(remoteLocation, 'remoteEntry.js'); : `${
remoteLocation.endsWith('/')
? remoteLocation.slice(0, -1)
: remoteLocation
}/remoteEntry.js`;
} else if (typeof remote === 'string') { } else if (typeof remote === 'string') {
mappedRemotes[remote] = determineRemoteUrl(remote, projectGraph); mappedRemotes[remote] = determineRemoteUrl(remote, projectGraph);
} }