Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(react): update package.json only with shallow dependencies #9297

Merged
merged 1 commit into from Mar 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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