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 { NxJsonConfiguration, WorkspaceJsonConfiguration } from '@nrwl/devkit';
|
||||||
import {
|
import {
|
||||||
|
createCache as _createCache,
|
||||||
extractCachedFileData,
|
extractCachedFileData,
|
||||||
ProjectGraphCache,
|
ProjectGraphCache,
|
||||||
shouldRecomputeWholeGraph,
|
shouldRecomputeWholeGraph,
|
||||||
} from './nx-deps-cache';
|
} from './nx-deps-cache';
|
||||||
|
import { createCache } from './nx-deps-cache';
|
||||||
|
|
||||||
describe('nx deps utils', () => {
|
describe('nx deps utils', () => {
|
||||||
describe('shouldRecomputeWholeGraph', () => {
|
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 {
|
function createCache(p: Partial<ProjectGraphCache>): ProjectGraphCache {
|
||||||
const defaults: ProjectGraphCache = {
|
const defaults: ProjectGraphCache = {
|
||||||
version: '3.0',
|
version: '3.0',
|
||||||
|
|||||||
@ -90,7 +90,7 @@ export function createCache(
|
|||||||
nxJson: NxJsonConfiguration<'*' | string[]>,
|
nxJson: NxJsonConfiguration<'*' | string[]>,
|
||||||
packageJsonDeps: Record<string, string>,
|
packageJsonDeps: Record<string, string>,
|
||||||
projectGraph: ProjectGraph<any>,
|
projectGraph: ProjectGraph<any>,
|
||||||
tsConfig: { compilerOptions: { paths?: { [p: string]: any } } }
|
tsConfig: { compilerOptions?: { paths?: { [p: string]: any } } }
|
||||||
) {
|
) {
|
||||||
const nxJsonPlugins = (nxJson.plugins || []).map((p) => ({
|
const nxJsonPlugins = (nxJson.plugins || []).map((p) => ({
|
||||||
name: p,
|
name: p,
|
||||||
@ -99,7 +99,8 @@ export function createCache(
|
|||||||
const newValue: ProjectGraphCache = {
|
const newValue: ProjectGraphCache = {
|
||||||
version: projectGraph.version || '5.0',
|
version: projectGraph.version || '5.0',
|
||||||
deps: packageJsonDeps,
|
deps: packageJsonDeps,
|
||||||
pathMappings: tsConfig.compilerOptions.paths || {},
|
// compilerOptions may not exist, especially for repos converted through add-nx-to-monorepo
|
||||||
|
pathMappings: tsConfig.compilerOptions?.paths || {},
|
||||||
nxJsonPlugins,
|
nxJsonPlugins,
|
||||||
nodes: projectGraph.nodes,
|
nodes: projectGraph.nodes,
|
||||||
externalNodes: projectGraph.externalNodes,
|
externalNodes: projectGraph.externalNodes,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user