nx 20.4.0-canary.20250109-0edd110 → 20.4.0-canary.20250111-bbbfd9f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "20.4.0-canary.20250109-0edd110",
3
+ "version": "20.4.0-canary.20250111-bbbfd9f",
4
4
  "private": false,
5
5
  "description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
6
6
  "repository": {
@@ -82,16 +82,16 @@
82
82
  }
83
83
  },
84
84
  "optionalDependencies": {
85
- "@nx/nx-darwin-arm64": "20.4.0-canary.20250109-0edd110",
86
- "@nx/nx-darwin-x64": "20.4.0-canary.20250109-0edd110",
87
- "@nx/nx-freebsd-x64": "20.4.0-canary.20250109-0edd110",
88
- "@nx/nx-linux-arm-gnueabihf": "20.4.0-canary.20250109-0edd110",
89
- "@nx/nx-linux-arm64-gnu": "20.4.0-canary.20250109-0edd110",
90
- "@nx/nx-linux-arm64-musl": "20.4.0-canary.20250109-0edd110",
91
- "@nx/nx-linux-x64-gnu": "20.4.0-canary.20250109-0edd110",
92
- "@nx/nx-linux-x64-musl": "20.4.0-canary.20250109-0edd110",
93
- "@nx/nx-win32-arm64-msvc": "20.4.0-canary.20250109-0edd110",
94
- "@nx/nx-win32-x64-msvc": "20.4.0-canary.20250109-0edd110"
85
+ "@nx/nx-darwin-arm64": "20.4.0-canary.20250111-bbbfd9f",
86
+ "@nx/nx-darwin-x64": "20.4.0-canary.20250111-bbbfd9f",
87
+ "@nx/nx-freebsd-x64": "20.4.0-canary.20250111-bbbfd9f",
88
+ "@nx/nx-linux-arm-gnueabihf": "20.4.0-canary.20250111-bbbfd9f",
89
+ "@nx/nx-linux-arm64-gnu": "20.4.0-canary.20250111-bbbfd9f",
90
+ "@nx/nx-linux-arm64-musl": "20.4.0-canary.20250111-bbbfd9f",
91
+ "@nx/nx-linux-x64-gnu": "20.4.0-canary.20250111-bbbfd9f",
92
+ "@nx/nx-linux-x64-musl": "20.4.0-canary.20250111-bbbfd9f",
93
+ "@nx/nx-win32-arm64-msvc": "20.4.0-canary.20250111-bbbfd9f",
94
+ "@nx/nx-win32-x64-msvc": "20.4.0-canary.20250111-bbbfd9f"
95
95
  },
96
96
  "nx-migrations": {
97
97
  "migrations": "./migrations.json",
@@ -12,6 +12,7 @@ const output_1 = require("../../utils/output");
12
12
  const configuration_1 = require("../../config/configuration");
13
13
  const calculate_default_project_name_1 = require("../../config/calculate-default-project-name");
14
14
  const graph_1 = require("../graph/graph");
15
+ const find_matching_projects_1 = require("../../utils/find-matching-projects");
15
16
  async function runOne(cwd, args, extraTargetDependencies = {}, extraOptions = {
16
17
  excludeTaskDependencies: args.excludeTaskDependencies,
17
18
  loadDotEnvFiles: process.env.NX_LOAD_DOT_ENV_FILES !== 'false',
@@ -31,7 +32,7 @@ async function runOne(cwd, args, extraTargetDependencies = {}, extraOptions = {
31
32
  process.exit(0);
32
33
  }
33
34
  await (0, connect_to_nx_cloud_1.connectToNxCloudIfExplicitlyAsked)(nxArgs);
34
- const { projects } = getProjects(projectGraph, opts.project);
35
+ const { projects, projectName } = getProjects(projectGraph, opts.project);
35
36
  if (nxArgs.graph) {
36
37
  const projectNames = projects.map((t) => t.name);
37
38
  const file = (0, command_line_utils_1.readGraphFileFromGraphArg)(nxArgs);
@@ -45,22 +46,45 @@ async function runOne(cwd, args, extraTargetDependencies = {}, extraOptions = {
45
46
  }, projectNames);
46
47
  }
47
48
  else {
48
- const status = await (0, run_command_1.runCommand)(projects, projectGraph, { nxJson }, nxArgs, overrides, opts.project, extraTargetDependencies, extraOptions);
49
+ const status = await (0, run_command_1.runCommand)(projects, projectGraph, { nxJson }, nxArgs, overrides, projectName, extraTargetDependencies, extraOptions);
49
50
  process.exit(status);
50
51
  }
51
52
  }
52
- function getProjects(projectGraph, project) {
53
- if (!projectGraph.nodes[project]) {
54
- output_1.output.error({
55
- title: `Cannot find project '${project}'`,
56
- });
57
- process.exit(1);
53
+ function getProjects(projectGraph, projectName) {
54
+ if (projectGraph.nodes[projectName]) {
55
+ return {
56
+ projectName: projectName,
57
+ projects: [projectGraph.nodes[projectName]],
58
+ projectsMap: {
59
+ [projectName]: projectGraph.nodes[projectName],
60
+ },
61
+ };
58
62
  }
59
- let projects = [projectGraph.nodes[project]];
60
- let projectsMap = {
61
- [project]: projectGraph.nodes[project],
62
- };
63
- return { projects, projectsMap };
63
+ else {
64
+ const projects = (0, find_matching_projects_1.findMatchingProjects)([projectName], projectGraph.nodes);
65
+ if (projects.length === 1) {
66
+ const projectName = projects[0];
67
+ const project = projectGraph.nodes[projectName];
68
+ return {
69
+ projectName,
70
+ projects: [project],
71
+ projectsMap: {
72
+ [project.data.name]: project,
73
+ },
74
+ };
75
+ }
76
+ else if (projects.length > 1) {
77
+ output_1.output.error({
78
+ title: `Multiple projects matched:`,
79
+ bodyLines: projects.length > 100 ? [...projects.slice(0, 100), '...'] : projects,
80
+ });
81
+ process.exit(1);
82
+ }
83
+ }
84
+ output_1.output.error({
85
+ title: `Cannot find project '${projectName}'`,
86
+ });
87
+ process.exit(1);
64
88
  }
65
89
  const targetAliases = {
66
90
  b: 'build',
@@ -4,14 +4,32 @@ exports.showProjectHandler = showProjectHandler;
4
4
  const output_1 = require("../../utils/output");
5
5
  const project_graph_1 = require("../../project-graph/project-graph");
6
6
  const graph_1 = require("../graph/graph");
7
+ const find_matching_projects_1 = require("../../utils/find-matching-projects");
7
8
  async function showProjectHandler(args) {
8
9
  performance.mark('code-loading:end');
9
10
  performance.measure('code-loading', 'init-local', 'code-loading:end');
10
11
  const graph = await (0, project_graph_1.createProjectGraphAsync)();
11
- const node = graph.nodes[args.projectName];
12
+ let node = graph.nodes[args.projectName];
12
13
  if (!node) {
13
- console.log(`Could not find project ${args.projectName}`);
14
- process.exit(1);
14
+ const projects = (0, find_matching_projects_1.findMatchingProjects)([args.projectName], graph.nodes);
15
+ if (projects.length === 1) {
16
+ const projectName = projects[0];
17
+ node = graph.nodes[projectName];
18
+ }
19
+ else if (projects.length > 1) {
20
+ output_1.output.error({
21
+ title: `Multiple projects matched:`,
22
+ bodyLines: projects.length > 100 ? [...projects.slice(0, 100), '...'] : projects,
23
+ });
24
+ console.log(`Multiple projects matched:\n ${(projects.length > 100
25
+ ? [...projects.slice(0, 100), '...']
26
+ : projects).join(' \n')}`);
27
+ process.exit(1);
28
+ }
29
+ else {
30
+ console.log(`Could not find project ${args.projectName}`);
31
+ process.exit(1);
32
+ }
15
33
  }
16
34
  if (args.json) {
17
35
  console.log(JSON.stringify(node.data));
Binary file
@@ -191,7 +191,10 @@ class TargetProjectLocator {
191
191
  }
192
192
  findDependencyInWorkspaceProjects(dep) {
193
193
  this.packageEntryPointsToProjectMap ??= (0, packages_1.getPackageEntryPointsToProjectMap)(this.nodes);
194
- return this.packageEntryPointsToProjectMap[dep]?.name ?? null;
194
+ return (this.packageEntryPointsToProjectMap[dep]?.name ??
195
+ // if the package exports do not include ".", look for subpath exports
196
+ Object.entries(this.packageEntryPointsToProjectMap).find(([entryPoint]) => dep.startsWith(`${entryPoint}/`))?.[1]?.name ??
197
+ null);
195
198
  }
196
199
  resolveImportWithTypescript(normalizedImportExpr, filePath) {
197
200
  let resolvedModule;
@@ -10,14 +10,28 @@ function getPackageEntryPointsToProjectMap(projects) {
10
10
  continue;
11
11
  }
12
12
  const { packageName, packageExports } = metadata.js;
13
- if (!packageExports || typeof packageExports === 'string') {
13
+ if (!packageExports ||
14
+ typeof packageExports === 'string' ||
15
+ !Object.keys(packageExports).length) {
14
16
  // no `exports` or it points to a file, which would be the equivalent of
15
17
  // an '.' export, in which case the package name is the entry point
16
18
  result[packageName] = project;
17
19
  }
18
20
  else {
19
21
  for (const entryPoint of Object.keys(packageExports)) {
20
- result[(0, posix_1.join)(packageName, entryPoint)] = project;
22
+ // if entrypoint begins with '.', it is a relative subpath export
23
+ // otherwise, it is a conditional export
24
+ // https://nodejs.org/api/packages.html#conditional-exports
25
+ if (entryPoint.startsWith('.')) {
26
+ result[(0, posix_1.join)(packageName, entryPoint)] = project;
27
+ }
28
+ else {
29
+ result[packageName] = project;
30
+ }
31
+ }
32
+ // if there was no '.' entrypoint, ensure the package name is matched with the project
33
+ if (!result[packageName]) {
34
+ result[packageName] = project;
21
35
  }
22
36
  }
23
37
  }
@@ -112,6 +112,17 @@ function addMatchingProjectsByName(projectNames, projects, pattern, matchedProje
112
112
  return;
113
113
  }
114
114
  if (!(0, globs_1.isGlobPattern)(pattern.value)) {
115
+ // Custom regex that is basically \b without underscores, so "foo" pattern matches "foo_bar".
116
+ const regex = new RegExp(`(?<![a-zA-Z0-9])${pattern.value}(?![a-zA-Z0-9])`, 'i');
117
+ const matchingProjects = Object.keys(projects).filter((name) => regex.test(name));
118
+ for (const projectName of matchingProjects) {
119
+ if (pattern.exclude) {
120
+ matchedProjects.delete(projectName);
121
+ }
122
+ else {
123
+ matchedProjects.add(projectName);
124
+ }
125
+ }
115
126
  return;
116
127
  }
117
128
  const matchedProjectNames = (0, exports.getMatchingStringsWithCache)(pattern.value, projectNames);
@@ -36,6 +36,7 @@ export interface PackageJson {
36
36
  require?: string;
37
37
  import?: string;
38
38
  development?: string;
39
+ default?: string;
39
40
  }>;
40
41
  dependencies?: Record<string, string>;
41
42
  devDependencies?: Record<string, string>;