Skip to content

Commit

Permalink
fix(core): optional dependencies should be tracked by project graph
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentEnder committed Apr 18, 2023
1 parent 5a0a4e8 commit 1b3587d
Showing 1 changed file with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { defaultFileRead } from '../../../../project-graph/file-utils';
import { join } from 'path';
import {
DependencyType,
ProjectFileMap,
ProjectGraph,
} from '../../../../config/project-graph';
import { parseJson } from '../../../../utils/json';
import { getImportPath, joinPathFragments } from '../../../../utils/path';
import { ProjectsConfigurations } from '../../../../config/workspace-json-project-json';
import { NxJsonConfiguration } from '../../../../config/nx-json';
import { ExplicitDependency } from './explicit-project-dependencies';
import { PackageJson } from '../../../../utils/package-json';
import { readJsonFile } from '../../../../utils/fileutils';

class ProjectGraphNodeRecords {}

Expand Down Expand Up @@ -47,13 +47,8 @@ function createPackageNameMap(
const res = {};
for (let projectName of Object.keys(projectsConfigurations.projects)) {
try {
const packageJson = parseJson(
defaultFileRead(
join(
projectsConfigurations.projects[projectName].root,
'package.json'
)
)
const packageJson = readJsonFile(
join(projectsConfigurations.projects[projectName].root, 'package.json')
);
res[
packageJson.name ??
Expand Down Expand Up @@ -83,7 +78,7 @@ function processPackageJson(
packageNameMap: { [packageName: string]: string }
) {
try {
const deps = readDeps(parseJson(defaultFileRead(fileName)));
const deps = readJsonFile(fileName);
// the name matches the import path
deps.forEach((d) => {
// package.json refers to another project in the monorepo
Expand All @@ -110,10 +105,11 @@ function processPackageJson(
}
}

function readDeps(packageJsonDeps: any) {
function readDeps(packageJson: PackageJson) {
return [
...Object.keys(packageJsonDeps?.dependencies ?? {}),
...Object.keys(packageJsonDeps?.devDependencies ?? {}),
...Object.keys(packageJsonDeps?.peerDependencies ?? {}),
...Object.keys(packageJson?.dependencies ?? {}),
...Object.keys(packageJson?.devDependencies ?? {}),
...Object.keys(packageJson?.peerDependencies ?? {}),
...Object.keys(packageJson?.optionalDependencies ?? {}),
];
}

0 comments on commit 1b3587d

Please sign in to comment.