Skip to content

Commit

Permalink
fix(js): esbuild should not throw when a project depends on non-js de…
Browse files Browse the repository at this point in the history
…pendencies
  • Loading branch information
AgentEnder committed Sep 7, 2023
1 parent 2bc7031 commit 4020a55
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/js/src/utils/package-json/update-package-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ import {
writeJsonFile,
} from '@nx/devkit';
import { DependentBuildableProjectNode } from '../buildable-libs-utils';
import { basename, join, parse, relative } from 'path';
import { basename, join, parse } from 'path';
import { writeFileSync } from 'fs-extra';
import { isNpmProject } from 'nx/src/project-graph/operators';
import {
isNpmProject,
isWorkspaceProject,
} from 'nx/src/project-graph/operators';
import { fileExists } from 'nx/src/utils/fileutils';
import type { PackageJson } from 'nx/src/utils/package-json';
import { existsSync } from 'fs';
import { readProjectFileMapCache } from 'nx/src/project-graph/nx-deps-cache';
import * as fastGlob from 'fast-glob';

import { getRelativeDirectoryToProjectRoot } from '../get-main-file-dir';

Expand Down Expand Up @@ -142,7 +144,7 @@ function addMissingDependencies(

packageJson[propType] ??= {};
packageJson[propType][packageName] = version;
} else {
} else if (isWorkspaceProject(entry.node)) {
const packageName = entry.name;
if (
!packageJson.dependencies?.[packageName] &&
Expand Down
6 changes: 6 additions & 0 deletions packages/nx/src/project-graph/operators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ export function isNpmProject(
return project?.type === 'npm';
}

export function isWorkspaceProject(
project: ProjectGraphProjectNode | ProjectGraphExternalNode
): project is ProjectGraphProjectNode {
return ['app', 'lib', 'e2e'].includes(project.type);
}

export const pruneExternalNodes = filterNodes();

export function withDeps(
Expand Down

0 comments on commit 4020a55

Please sign in to comment.