Skip to content

Commit

Permalink
fix(react): update package.json only with shallow dependencies (#9297)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysoo committed Mar 11, 2022
1 parent 208d5c0 commit cd81a20
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 24 deletions.
13 changes: 2 additions & 11 deletions packages/web/src/executors/rollup/rollup.impl.ts
Expand Up @@ -55,18 +55,9 @@ export default async function* rollupExecutor(
context.root,
context.projectName,
context.targetName,
context.configurationName
context.configurationName,
true
);
if (
!checkDependentProjectsHaveBeenBuilt(
context.root,
context.projectName,
context.targetName,
dependencies
)
) {
throw new Error();
}

const options = normalizeWebRollupOptions(
rawOptions,
Expand Down
26 changes: 13 additions & 13 deletions packages/workspace/src/utilities/buildable-libs-utils.ts
@@ -1,13 +1,13 @@
import { isNpmProject, ProjectType } from '../core/project-graph';
import { join, resolve, dirname, relative } from 'path';
import { dirname, join, relative, resolve } from 'path';
import { directoryExists } from './fileutils';
import type { ProjectGraph, ProjectGraphProjectNode } from '@nrwl/devkit';
import {
stripIndents,
ProjectGraphExternalNode,
readJsonFile,
stripIndents,
writeJsonFile,
ProjectGraphExternalNode,
} from '@nrwl/devkit';
import type { ProjectGraph, ProjectGraphProjectNode } from '@nrwl/devkit';
import { getOutputsForTargetAndConfiguration } from '../tasks-runner/utils';
import * as ts from 'typescript';
import { unlinkSync } from 'fs';
Expand All @@ -32,7 +32,8 @@ export function calculateProjectDependencies(
root: string,
projectName: string,
targetName: string,
configurationName: string
configurationName: string,
shallow?: boolean
): {
target: ProjectGraphProjectNode;
dependencies: DependentBuildableProjectNode[];
Expand All @@ -41,11 +42,7 @@ export function calculateProjectDependencies(
const target = projGraph.nodes[projectName];
// gather the library dependencies
const nonBuildableDependencies = [];
const dependencies = recursivelyCollectDependencies(
projectName,
projGraph,
[]
)
const dependencies = collectDependencies(projectName, projGraph, [], shallow)
.map((dep) => {
const depNode = projGraph.nodes[dep] || projGraph.externalNodes[dep];
if (depNode.type === ProjectType.lib) {
Expand Down Expand Up @@ -86,15 +83,18 @@ export function calculateProjectDependencies(
return { target, dependencies, nonBuildableDependencies };
}

function recursivelyCollectDependencies(
function collectDependencies(
project: string,
projGraph: ProjectGraph,
acc: string[]
acc: string[],
shallow?: boolean
) {
(projGraph.dependencies[project] || []).forEach((dependency) => {
if (acc.indexOf(dependency.target) === -1) {
acc.push(dependency.target);
recursivelyCollectDependencies(dependency.target, projGraph, acc);
if (!shallow) {
collectDependencies(dependency.target, projGraph, acc);
}
}
});
return acc;
Expand Down

0 comments on commit cd81a20

Please sign in to comment.