fix(angular): set tsconfig paths relative to the workspace root in target options (#20507)
This commit is contained in:
parent
15c2181664
commit
1692a54da6
@ -2,6 +2,7 @@ import type { BuilderContext } from '@angular-devkit/architect';
|
|||||||
import type { DevServerBuilderOptions } from '@angular-devkit/build-angular';
|
import type { DevServerBuilderOptions } from '@angular-devkit/build-angular';
|
||||||
import {
|
import {
|
||||||
joinPathFragments,
|
joinPathFragments,
|
||||||
|
normalizePath,
|
||||||
parseTargetString,
|
parseTargetString,
|
||||||
readCachedProjectGraph,
|
readCachedProjectGraph,
|
||||||
} from '@nx/devkit';
|
} from '@nx/devkit';
|
||||||
@ -11,6 +12,7 @@ import { WebpackNxBuildCoordinationPlugin } from '@nx/webpack/src/plugins/webpac
|
|||||||
import { existsSync } from 'fs';
|
import { existsSync } from 'fs';
|
||||||
import { isNpmProject } from 'nx/src/project-graph/operators';
|
import { isNpmProject } from 'nx/src/project-graph/operators';
|
||||||
import { readCachedProjectConfiguration } from 'nx/src/project-graph/project-graph';
|
import { readCachedProjectConfiguration } from 'nx/src/project-graph/project-graph';
|
||||||
|
import { relative } from 'path';
|
||||||
import { from } from 'rxjs';
|
import { from } from 'rxjs';
|
||||||
import { switchMap } from 'rxjs/operators';
|
import { switchMap } from 'rxjs/operators';
|
||||||
import { getInstalledAngularVersionInfo } from '../../executors/utilities/angular-version-utils';
|
import { getInstalledAngularVersionInfo } from '../../executors/utilities/angular-version-utils';
|
||||||
@ -104,6 +106,9 @@ export function executeDevServerBuilder(
|
|||||||
target: parsedBuildTarget.target,
|
target: parsedBuildTarget.target,
|
||||||
});
|
});
|
||||||
dependencies = foundDependencies;
|
dependencies = foundDependencies;
|
||||||
|
const relativeTsConfigPath = normalizePath(
|
||||||
|
relative(context.workspaceRoot, tsConfigPath)
|
||||||
|
);
|
||||||
|
|
||||||
// We can't just pass the tsconfig path in memory to the angular builder
|
// We can't just pass the tsconfig path in memory to the angular builder
|
||||||
// function because we can't pass the build target options to it, the build
|
// function because we can't pass the build target options to it, the build
|
||||||
@ -114,7 +119,7 @@ export function executeDevServerBuilder(
|
|||||||
const originalGetTargetOptions = context.getTargetOptions;
|
const originalGetTargetOptions = context.getTargetOptions;
|
||||||
context.getTargetOptions = async (target) => {
|
context.getTargetOptions = async (target) => {
|
||||||
const options = await originalGetTargetOptions(target);
|
const options = await originalGetTargetOptions(target);
|
||||||
options.tsConfig = tsConfigPath;
|
options.tsConfig = relativeTsConfigPath;
|
||||||
return options;
|
return options;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -122,7 +127,7 @@ export function executeDevServerBuilder(
|
|||||||
// otherwise the build will fail if customWebpack function/file is referencing
|
// otherwise the build will fail if customWebpack function/file is referencing
|
||||||
// local libs. This synchronize the behavior with webpack-browser and
|
// local libs. This synchronize the behavior with webpack-browser and
|
||||||
// webpack-server implementation.
|
// webpack-server implementation.
|
||||||
buildTargetOptions.tsConfig = tsConfigPath;
|
buildTargetOptions.tsConfig = relativeTsConfigPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
const delegateBuilderOptions = getDelegateBuilderOptions(options);
|
const delegateBuilderOptions = getDelegateBuilderOptions(options);
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
joinPathFragments,
|
joinPathFragments,
|
||||||
|
normalizePath,
|
||||||
ProjectGraph,
|
ProjectGraph,
|
||||||
readCachedProjectGraph,
|
readCachedProjectGraph,
|
||||||
} from '@nx/devkit';
|
} from '@nx/devkit';
|
||||||
@ -9,7 +10,7 @@ import { existsSync } from 'fs';
|
|||||||
import { readNxJson } from 'nx/src/config/configuration';
|
import { readNxJson } from 'nx/src/config/configuration';
|
||||||
import { isNpmProject } from 'nx/src/project-graph/operators';
|
import { isNpmProject } from 'nx/src/project-graph/operators';
|
||||||
import { getDependencyConfigs } from 'nx/src/tasks-runner/utils';
|
import { getDependencyConfigs } from 'nx/src/tasks-runner/utils';
|
||||||
import { join } from 'path';
|
import { relative } from 'path';
|
||||||
import { from, Observable } from 'rxjs';
|
import { from, Observable } from 'rxjs';
|
||||||
import { switchMap } from 'rxjs/operators';
|
import { switchMap } from 'rxjs/operators';
|
||||||
import { createTmpTsConfigForBuildableLibs } from '../utilities/buildable-libs';
|
import { createTmpTsConfigForBuildableLibs } from '../utilities/buildable-libs';
|
||||||
@ -85,7 +86,9 @@ export function executeWebpackBrowserBuilder(
|
|||||||
{ projectGraph }
|
{ projectGraph }
|
||||||
);
|
);
|
||||||
dependencies = foundDependencies;
|
dependencies = foundDependencies;
|
||||||
delegateBuilderOptions.tsConfig = tsConfigPath;
|
delegateBuilderOptions.tsConfig = normalizePath(
|
||||||
|
relative(context.workspaceRoot, tsConfigPath)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return from(import('@angular-devkit/build-angular')).pipe(
|
return from(import('@angular-devkit/build-angular')).pipe(
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import { joinPathFragments } from '@nx/devkit';
|
import { joinPathFragments, normalizePath } from '@nx/devkit';
|
||||||
import { existsSync } from 'fs';
|
import { existsSync } from 'fs';
|
||||||
|
import { relative } from 'path';
|
||||||
import { Observable, from } from 'rxjs';
|
import { Observable, from } from 'rxjs';
|
||||||
import { switchMap } from 'rxjs/operators';
|
import { switchMap } from 'rxjs/operators';
|
||||||
import { createTmpTsConfigForBuildableLibs } from '../utilities/buildable-libs';
|
import { createTmpTsConfigForBuildableLibs } from '../utilities/buildable-libs';
|
||||||
@ -100,7 +101,9 @@ export function executeWebpackServerBuilder(
|
|||||||
options.tsConfig,
|
options.tsConfig,
|
||||||
context
|
context
|
||||||
);
|
);
|
||||||
options.tsConfig = tsConfigPath;
|
options.tsConfig = normalizePath(
|
||||||
|
relative(context.workspaceRoot, tsConfigPath)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return buildServerApp(options, context);
|
return buildServerApp(options, context);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user