fix(core): allow tsConfig without compilerOptions to work (#8119)
This commit is contained in:
parent
590577010d
commit
d6307181ab
@ -1,9 +1,11 @@
|
||||
import { NxJsonConfiguration, WorkspaceJsonConfiguration } from '@nrwl/devkit';
|
||||
import {
|
||||
createCache as _createCache,
|
||||
extractCachedFileData,
|
||||
ProjectGraphCache,
|
||||
shouldRecomputeWholeGraph,
|
||||
} from './nx-deps-cache';
|
||||
import { createCache } from './nx-deps-cache';
|
||||
|
||||
describe('nx deps utils', () => {
|
||||
describe('shouldRecomputeWholeGraph', () => {
|
||||
@ -277,6 +279,17 @@ describe('nx deps utils', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('createCache', () => {
|
||||
it('should work with empty tsConfig', () => {
|
||||
_createCache(
|
||||
createNxJson({}),
|
||||
createPackageJsonDeps({}),
|
||||
createCache({}),
|
||||
{}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
function createCache(p: Partial<ProjectGraphCache>): ProjectGraphCache {
|
||||
const defaults: ProjectGraphCache = {
|
||||
version: '3.0',
|
||||
|
||||
@ -90,7 +90,7 @@ export function createCache(
|
||||
nxJson: NxJsonConfiguration<'*' | string[]>,
|
||||
packageJsonDeps: Record<string, string>,
|
||||
projectGraph: ProjectGraph<any>,
|
||||
tsConfig: { compilerOptions: { paths?: { [p: string]: any } } }
|
||||
tsConfig: { compilerOptions?: { paths?: { [p: string]: any } } }
|
||||
) {
|
||||
const nxJsonPlugins = (nxJson.plugins || []).map((p) => ({
|
||||
name: p,
|
||||
@ -99,7 +99,8 @@ export function createCache(
|
||||
const newValue: ProjectGraphCache = {
|
||||
version: projectGraph.version || '5.0',
|
||||
deps: packageJsonDeps,
|
||||
pathMappings: tsConfig.compilerOptions.paths || {},
|
||||
// compilerOptions may not exist, especially for repos converted through add-nx-to-monorepo
|
||||
pathMappings: tsConfig.compilerOptions?.paths || {},
|
||||
nxJsonPlugins,
|
||||
nodes: projectGraph.nodes,
|
||||
externalNodes: projectGraph.externalNodes,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user