@nx/js 22.7.0-rc.0 → 22.7.0-rc.2

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/js",
3
- "version": "22.7.0-rc.0",
3
+ "version": "22.7.0-rc.2",
4
4
  "private": false,
5
5
  "description": "The JS plugin for Nx contains executors and generators that provide the best experience for developing JavaScript and TypeScript projects. ",
6
6
  "repository": {
@@ -40,8 +40,8 @@
40
40
  "@babel/preset-env": "^7.23.2",
41
41
  "@babel/preset-typescript": "^7.22.5",
42
42
  "@babel/runtime": "^7.22.6",
43
- "@nx/devkit": "22.7.0-rc.0",
44
- "@nx/workspace": "22.7.0-rc.0",
43
+ "@nx/devkit": "22.7.0-rc.2",
44
+ "@nx/workspace": "22.7.0-rc.2",
45
45
  "@zkochan/js-yaml": "0.0.7",
46
46
  "babel-plugin-const-enum": "^1.0.1",
47
47
  "babel-plugin-macros": "^3.1.0",
@@ -61,7 +61,7 @@
61
61
  "tslib": "^2.3.0"
62
62
  },
63
63
  "devDependencies": {
64
- "nx": "22.7.0-rc.0"
64
+ "nx": "22.7.0-rc.2"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "verdaccio": "^6.0.5"
@@ -0,0 +1,9 @@
1
+ interface OutputFileNameOptions {
2
+ buildTargetExecutor: string;
3
+ main: string;
4
+ outputPath: string;
5
+ rootDir: string;
6
+ }
7
+ export declare function getOutputFileName({ buildTargetExecutor, main, outputPath, rootDir, }: OutputFileNameOptions): string;
8
+ export {};
9
+ //# sourceMappingURL=output-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-file.d.ts","sourceRoot":"","sources":["../../../../../../../packages/js/src/executors/node/lib/output-file.ts"],"names":[],"mappings":"AAIA,UAAU,qBAAqB;IAC7B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,iBAAiB,CAAC,EAChC,mBAAmB,EACnB,IAAI,EACJ,UAAU,EACV,OAAO,GACR,EAAE,qBAAqB,GAAG,MAAM,CAqBhC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getOutputFileName = getOutputFileName;
4
+ const path_1 = require("path");
5
+ const path_2 = require("nx/src/utils/path");
6
+ const get_main_file_dir_1 = require("../../../utils/get-main-file-dir");
7
+ function getOutputFileName({ buildTargetExecutor, main, outputPath, rootDir, }) {
8
+ const fileName = `${(0, path_1.parse)(main).name}.js`;
9
+ if (buildTargetExecutor !== '@nx/js:tsc' &&
10
+ buildTargetExecutor !== '@nx/js:swc') {
11
+ return fileName;
12
+ }
13
+ const mainDirectory = (0, path_2.normalizePath)((0, path_1.dirname)(main));
14
+ const normalizedOutputPath = (0, path_2.normalizePath)(outputPath);
15
+ const isMainInsideOutputPath = mainDirectory === normalizedOutputPath ||
16
+ mainDirectory.startsWith(`${normalizedOutputPath}/`);
17
+ const base = isMainInsideOutputPath ? normalizedOutputPath : rootDir;
18
+ return (0, path_2.joinPathFragments)((0, get_main_file_dir_1.getRelativeDirectoryToProjectRoot)(main, base), fileName);
19
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"node.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/executors/node/node.impl.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,eAAe,EAQhB,MAAM,YAAY,CAAC;AAOpB,OAAO,EAAe,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAqB5D,wBAAuB,YAAY,CACjC,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,eAAe;aAgEb,OAAO;cACN,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;cA6QhC;AAmJD,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"node.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/executors/node/node.impl.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,eAAe,EAQhB,MAAM,YAAY,CAAC;AAOpB,OAAO,EAAe,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAqB5D,wBAAuB,YAAY,CACjC,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,eAAe;aAgEb,OAAO;cACN,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;cA6QhC;AA6ID,eAAe,YAAY,CAAC"}
@@ -15,9 +15,9 @@ const kill_tree_1 = require("./lib/kill-tree");
15
15
  const line_aware_writer_1 = require("./lib/line-aware-writer");
16
16
  const coalescing_debounce_1 = require("./lib/coalescing-debounce");
17
17
  const fileutils_1 = require("nx/src/utils/fileutils");
18
- const get_main_file_dir_1 = require("../../utils/get-main-file-dir");
19
18
  const utils_1 = require("nx/src/tasks-runner/utils");
20
19
  const detect_module_format_1 = require("./lib/detect-module-format");
20
+ const output_file_1 = require("./lib/output-file");
21
21
  const globalLineAwareWriter = new line_aware_writer_1.LineAwareWriter();
22
22
  async function* nodeExecutor(options, context) {
23
23
  process.env.NODE_ENV ??= context?.configurationName ?? 'development';
@@ -347,14 +347,12 @@ function getFileToRun(context, project, buildOptions, buildTargetExecutor) {
347
347
  }
348
348
  let outputFileName = buildOptions.outputFileName;
349
349
  if (!outputFileName) {
350
- const fileName = `${path.parse(buildOptions.main).name}.js`;
351
- if (buildTargetExecutor === '@nx/js:tsc' ||
352
- buildTargetExecutor === '@nx/js:swc') {
353
- outputFileName = path.join((0, get_main_file_dir_1.getRelativeDirectoryToProjectRoot)(buildOptions.main, project.data.root), fileName);
354
- }
355
- else {
356
- outputFileName = fileName;
357
- }
350
+ outputFileName = (0, output_file_1.getOutputFileName)({
351
+ buildTargetExecutor,
352
+ main: buildOptions.main,
353
+ outputPath: buildOptions.outputPath,
354
+ rootDir: buildOptions.rootDir ?? project.data.root,
355
+ });
358
356
  }
359
357
  return (0, path_1.join)(context.root, buildOptions.outputPath, outputFileName);
360
358
  }
@@ -1 +1 @@
1
- {"version":3,"file":"prune-lockfile.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/executors/prune-lockfile/prune-lockfile.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EAMrB,MAAM,YAAY,CAAC;AAUpB,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAErD,wBAA8B,qBAAqB,CACjD,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,eAAe;;GAgCzB"}
1
+ {"version":3,"file":"prune-lockfile.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/executors/prune-lockfile/prune-lockfile.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EAMrB,MAAM,YAAY,CAAC;AAYpB,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAErD,wBAA8B,qBAAqB,CACjD,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,eAAe;;GAgCzB"}
@@ -7,6 +7,8 @@ const path_1 = require("path");
7
7
  const utils_1 = require("nx/src/tasks-runner/utils");
8
8
  // eslint-disable-next-line @typescript-eslint/no-restricted-imports
9
9
  const lock_file_1 = require("nx/src/plugins/js/lock-file/lock-file");
10
+ // eslint-disable-next-line @typescript-eslint/no-restricted-imports
11
+ const get_workspace_packages_from_graph_1 = require("nx/src/plugins/js/utils/get-workspace-packages-from-graph");
10
12
  async function pruneLockfileExecutor(schema, context) {
11
13
  devkit_1.logger.log('Pruning lockfile...');
12
14
  const outputDirectory = getOutputDir(schema, context);
@@ -31,10 +33,12 @@ function createPrunedLockfile(packageJson, graph) {
31
33
  const packageManager = (0, devkit_1.detectPackageManager)(devkit_1.workspaceRoot);
32
34
  const lockfileName = (0, lock_file_1.getLockFileName)(packageManager);
33
35
  const lockFile = (0, lock_file_1.createLockFile)(packageJson, graph, packageManager);
36
+ const workspacePackages = (0, get_workspace_packages_from_graph_1.getWorkspacePackagesFromGraph)(graph);
34
37
  for (const [pkgName, pkgVersion] of Object.entries(packageJson.dependencies ?? {})) {
35
38
  if (pkgVersion.startsWith('workspace:') ||
36
39
  pkgVersion.startsWith('file:') ||
37
- pkgVersion.startsWith('link:')) {
40
+ pkgVersion.startsWith('link:') ||
41
+ workspacePackages.has(pkgName)) {
38
42
  packageJson.dependencies[pkgName] = `file:./workspace_modules/${pkgName}`;
39
43
  }
40
44
  }
@@ -1 +1 @@
1
- {"version":3,"file":"typescript-sync.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/generators/typescript-sync/typescript-sync.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAIpB,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,8BAA8B,CAAC;AA2CtC,wBAAsB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAyQ5E;AAED,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"typescript-sync.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/generators/typescript-sync/typescript-sync.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAIpB,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,8BAA8B,CAAC;AA4CtC,wBAAsB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAyQ5E;AAED,eAAe,aAAa,CAAC"}
@@ -199,6 +199,7 @@ function updateTsConfigReferences(tree, tsSysFromTree, tsconfigInfoCaches, tsCon
199
199
  const stringifiedJsonContents = readRawTsconfigContents(tree, tsconfigInfoCaches, tsConfigPath);
200
200
  const tsConfig = (0, devkit_1.parseJson)(stringifiedJsonContents);
201
201
  const ignoredReferences = new Set(tsConfig.nx?.sync?.ignoredReferences ?? []);
202
+ const ignoredDependencies = new Set(tsConfig.nx?.sync?.ignoredDependencies ?? []);
202
203
  // We have at least one dependency so we can safely set it to an empty array if not already set
203
204
  const references = [];
204
205
  const originalReferencesSet = new Set();
@@ -236,6 +237,12 @@ function updateTsConfigReferences(tree, tsSysFromTree, tsconfigInfoCaches, tsCon
236
237
  }
237
238
  }
238
239
  for (const dep of dependencies) {
240
+ if (ignoredDependencies.has(dep.name)) {
241
+ // The user has explicitly opted out of this dependency edge, typically
242
+ // to break a circular project reference graph that the project graph
243
+ // intentionally allows.
244
+ continue;
245
+ }
239
246
  // Ensure the project reference for the target is set if we can find the
240
247
  // relevant tsconfig file
241
248
  let referencePath;