## Current Behavior Module Federation collectRemotes util looks for a hardcoded `build` target. ## Expected Behavior Read the remote's targets and find the correct `buildTarget` option for the module-federation-dev-server to use ## Related Issue(s) Fixes #30808
This commit is contained in:
parent
7affa87af9
commit
0c63624407
@ -1,4 +1,4 @@
|
|||||||
import { logger, type ProjectGraph } from '@nx/devkit';
|
import { logger, parseTargetString, type ProjectGraph } from '@nx/devkit';
|
||||||
import { registerTsProject } from '@nx/js/src/internal';
|
import { registerTsProject } from '@nx/js/src/internal';
|
||||||
import { findMatchingProjects } from 'nx/src/utils/find-matching-projects';
|
import { findMatchingProjects } from 'nx/src/utils/find-matching-projects';
|
||||||
import * as pc from 'picocolors';
|
import * as pc from 'picocolors';
|
||||||
@ -59,8 +59,35 @@ function collectRemoteProjects(
|
|||||||
collected.add(remote);
|
collected.add(remote);
|
||||||
|
|
||||||
const remoteProjectRoot = remoteProject.root;
|
const remoteProjectRoot = remoteProject.root;
|
||||||
|
|
||||||
|
// Find the target that uses the module-federation-dev-server executor
|
||||||
|
let buildTargetName = 'build';
|
||||||
|
if (remoteProject.targets) {
|
||||||
|
for (const [targetKey, targetConfig] of Object.entries(
|
||||||
|
remoteProject.targets
|
||||||
|
)) {
|
||||||
|
const executor = targetConfig.executor || '';
|
||||||
|
// Extract the portion after the `:` in the executor name
|
||||||
|
const executorParts = executor.split(':');
|
||||||
|
const executorName =
|
||||||
|
executorParts.length > 1 ? executorParts[1] : executor;
|
||||||
|
|
||||||
|
if (executorName === 'module-federation-dev-server') {
|
||||||
|
// Extract the buildTarget from the options
|
||||||
|
if (targetConfig.options?.buildTarget) {
|
||||||
|
const parsedTarget = parseTargetString(
|
||||||
|
targetConfig.options.buildTarget,
|
||||||
|
context.projectGraph
|
||||||
|
);
|
||||||
|
buildTargetName = parsedTarget.target;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let remoteProjectTsConfig =
|
let remoteProjectTsConfig =
|
||||||
remoteProject.targets['build'].options.tsConfig ??
|
remoteProject.targets?.[buildTargetName]?.options?.tsConfig ??
|
||||||
[
|
[
|
||||||
join(remoteProjectRoot, 'tsconfig.app.json'),
|
join(remoteProjectRoot, 'tsconfig.app.json'),
|
||||||
join(remoteProjectRoot, 'tsconfig.json'),
|
join(remoteProjectRoot, 'tsconfig.json'),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user