@nx/js 17.3.0-rc.1 → 17.3.1

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/babel.js CHANGED
@@ -12,10 +12,10 @@ module.exports = function (api, options = {}) {
12
12
  const emitDecoratorMetadata = api.caller((caller) => caller?.emitDecoratorMetadata ?? true);
13
13
  // Determine settings for `@babel//babel-plugin-transform-class-properties`,
14
14
  // so that we can sync the `loose` option with `@babel/preset-env`.
15
- // TODO(v18): Remove classProperties since it's no longer needed, now that the class props transform is in preset-env.
15
+ // TODO(v19): Remove classProperties since it's no longer needed, now that the class props transform is in preset-env.
16
16
  const loose = options.classProperties?.loose ?? options.loose ?? true;
17
17
  if (options.classProperties) {
18
- devkit_1.logger.warn(`Use =\`loose\` option instead of \`classProperties.loose\`. The \`classProperties\` option will be removed in Nx 18`);
18
+ devkit_1.logger.warn(`Use =\`loose\` option instead of \`classProperties.loose\`. The \`classProperties\` option will be removed in Nx 19`);
19
19
  }
20
20
  return {
21
21
  presets: [
package/executors.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "executors": {
4
4
  "tsc": {
5
5
  "implementation": "./src/executors/tsc/tsc.impl",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/js",
3
- "version": "17.3.0-rc.1",
3
+ "version": "17.3.1",
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": {
@@ -30,11 +30,11 @@
30
30
  "generators": "./generators.json",
31
31
  "executors": "./executors.json",
32
32
  "dependencies": {
33
- "@babel/core": "^7.22.9",
33
+ "@babel/core": "^7.23.2",
34
34
  "@babel/plugin-proposal-decorators": "^7.22.7",
35
- "@babel/plugin-transform-runtime": "^7.22.9",
35
+ "@babel/plugin-transform-runtime": "^7.23.2",
36
36
  "@babel/plugin-transform-class-properties": "^7.22.5",
37
- "@babel/preset-env": "^7.22.9",
37
+ "@babel/preset-env": "^7.23.2",
38
38
  "@babel/preset-typescript": "^7.22.5",
39
39
  "@babel/runtime": "^7.22.6",
40
40
  "@phenomnomnominal/tsquery": "~5.0.1",
@@ -57,9 +57,9 @@
57
57
  "semver": "7.5.3",
58
58
  "source-map-support": "0.5.19",
59
59
  "tslib": "^2.3.0",
60
- "@nx/devkit": "17.3.0-rc.1",
61
- "@nx/workspace": "17.3.0-rc.1",
62
- "@nrwl/js": "17.3.0-rc.1"
60
+ "@nx/devkit": "17.3.1",
61
+ "@nx/workspace": "17.3.1",
62
+ "@nrwl/js": "17.3.1"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "verdaccio": "^5.0.4"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 2,
3
3
  "outputCapture": "direct-nodejs",
4
- "$schema": "http://json-schema.org/schema",
4
+ "$schema": "https://json-schema.org/schema",
5
5
  "cli": "nx",
6
6
  "title": "Node executor",
7
7
  "description": "Execute Nodejs applications.",
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "version": 2,
4
4
  "title": "Implementation details of `nx release publish`",
5
5
  "description": "DO NOT INVOKE DIRECTLY WITH `nx run`. Use `nx release publish` instead.",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 2,
3
3
  "outputCapture": "direct-nodejs",
4
- "$schema": "http://json-schema.org/schema",
4
+ "$schema": "https://json-schema.org/schema",
5
5
  "cli": "nx",
6
6
  "title": "Typescript Build Target",
7
7
  "description": "Builds using SWC.",
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "version": 2,
4
4
  "title": "Verdaccio Local Registry",
5
5
  "description": "Start a local registry with Verdaccio.",
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "$id": "NxTypescriptLibrary",
4
4
  "cli": "nx",
5
5
  "title": "Convert a TSC library to SWC",
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "$id": "NxTypescriptInit",
4
4
  "cli": "nx",
5
5
  "title": "Init nx/js",
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "$id": "NxTypescriptLibrary",
4
4
  "cli": "nx",
5
5
  "title": "Create a TypeScript Library",
@@ -9,7 +9,6 @@ const git_1 = require("nx/src/command-line/release/utils/git");
9
9
  const resolve_semver_specifier_1 = require("nx/src/command-line/release/utils/resolve-semver-specifier");
10
10
  const semver_1 = require("nx/src/command-line/release/utils/semver");
11
11
  const version_1 = require("nx/src/command-line/release/version");
12
- const client_1 = require("nx/src/daemon/client/client");
13
12
  const utils_1 = require("nx/src/tasks-runner/utils");
14
13
  const ora = require("ora");
15
14
  const path_1 = require("path");
@@ -314,26 +313,7 @@ To fix this you will either need to add a package.json file at that location, or
314
313
  data: versionData,
315
314
  callback: async (tree, opts) => {
316
315
  const cwd = tree.root;
317
- const isDaemonEnabled = client_1.daemonClient.enabled();
318
- if (isDaemonEnabled) {
319
- // temporarily stop the daemon, as it will error if the lock file is updated
320
- await client_1.daemonClient.stop();
321
- }
322
- const updatedFiles = (0, update_lock_file_1.updateLockFile)(cwd, opts);
323
- if (isDaemonEnabled) {
324
- try {
325
- await client_1.daemonClient.startInBackground();
326
- }
327
- catch (e) {
328
- // If the daemon fails to start, we don't want to prevent the user from continuing, so we just log the error and move on
329
- if (opts.verbose) {
330
- devkit_1.output.warn({
331
- title: 'Unable to restart the Nx Daemon. It will be disabled until you run "nx reset"',
332
- bodyLines: [e.message],
333
- });
334
- }
335
- }
336
- }
316
+ const updatedFiles = await (0, update_lock_file_1.updateLockFile)(cwd, opts);
337
317
  return updatedFiles;
338
318
  },
339
319
  };
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "$id": "NxJSReleaseVersionGenerator",
4
4
  "cli": "nx",
5
5
  "title": "Implementation details of `nx release version`",
@@ -2,4 +2,4 @@ export declare function updateLockFile(cwd: string, { dryRun, verbose, generator
2
2
  dryRun?: boolean;
3
3
  verbose?: boolean;
4
4
  generatorOptions?: Record<string, unknown>;
5
- }): string[];
5
+ }): Promise<string[]>;
@@ -3,16 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateLockFile = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const child_process_1 = require("child_process");
6
+ const client_1 = require("nx/src/daemon/client/client");
6
7
  // eslint-disable-next-line @typescript-eslint/no-restricted-imports
7
8
  const lock_file_1 = require("nx/src/plugins/js/lock-file/lock-file");
8
9
  const semver_1 = require("semver");
9
- function updateLockFile(cwd, { dryRun, verbose, generatorOptions, }) {
10
+ async function updateLockFile(cwd, { dryRun, verbose, generatorOptions, }) {
10
11
  if (generatorOptions?.skipLockFileUpdate) {
11
12
  if (verbose) {
12
13
  console.log('\nSkipped lock file update because skipLockFileUpdate was set.');
13
14
  }
14
15
  return [];
15
16
  }
17
+ const isDaemonEnabled = client_1.daemonClient.enabled();
18
+ if (isDaemonEnabled) {
19
+ // temporarily stop the daemon, as it will error if the lock file is updated
20
+ await client_1.daemonClient.stop();
21
+ }
16
22
  const packageManager = (0, devkit_1.detectPackageManager)(cwd);
17
23
  const packageManagerCommands = (0, devkit_1.getPackageManagerCommand)(packageManager);
18
24
  let installArgs = generatorOptions?.installArgs || '';
@@ -43,6 +49,20 @@ function updateLockFile(cwd, { dryRun, verbose, generatorOptions, }) {
43
49
  return [];
44
50
  }
45
51
  execLockFileUpdate(command, cwd, env);
52
+ if (isDaemonEnabled) {
53
+ try {
54
+ await client_1.daemonClient.startInBackground();
55
+ }
56
+ catch (e) {
57
+ // If the daemon fails to start, we don't want to prevent the user from continuing, so we just log the error and move on
58
+ if (verbose) {
59
+ devkit_1.output.warn({
60
+ title: 'Unable to restart the Nx Daemon. It will be disabled until you run "nx reset"',
61
+ bodyLines: [e.message],
62
+ });
63
+ }
64
+ }
65
+ }
46
66
  return [lockFile];
47
67
  }
48
68
  exports.updateLockFile = updateLockFile;
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "$id": "SetupBuild",
4
4
  "title": "Setup Build",
5
5
  "description": "Sets up build target for a project.",
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "$id": "SetupVerdaccio",
4
4
  "title": "Setup Verdaccio",
5
5
  "description": "Setup Verdaccio local-registry.",
@@ -84,7 +84,8 @@ function calculateProjectDependencies(projGraph, root, projectName, targetName,
84
84
  exports.calculateProjectDependencies = calculateProjectDependencies;
85
85
  function collectDependencies(project, projGraph, acc, shallow, areTopLevelDeps = true) {
86
86
  (projGraph.dependencies[project] || []).forEach((dependency) => {
87
- if (!acc.some((dep) => dep.name === dependency.target)) {
87
+ const existingEntry = acc.find((dep) => dep.name === dependency.target);
88
+ if (!existingEntry) {
88
89
  // Temporary skip this. Currently the set of external nodes is built from package.json, not lock file.
89
90
  // As a result, some nodes might be missing. This should not cause any issues, we can just skip them.
90
91
  if (dependency.target.startsWith('npm:') &&
@@ -96,6 +97,9 @@ function collectDependencies(project, projGraph, acc, shallow, areTopLevelDeps =
96
97
  collectDependencies(dependency.target, projGraph, acc, shallow, false);
97
98
  }
98
99
  }
100
+ else if (areTopLevelDeps && !existingEntry.isTopLevel) {
101
+ existingEntry.isTopLevel = true;
102
+ }
99
103
  });
100
104
  return acc;
101
105
  }
@@ -161,9 +161,11 @@ function movePackage(from, to) {
161
161
  (0, fs_extra_1.copySync)(from, to, { overwrite: true });
162
162
  }
163
163
  function updateImports(destOutputPath, inlinedDepsDestOutputRecord) {
164
- const importRegex = new RegExp(Object.keys(inlinedDepsDestOutputRecord)
165
- .map((pathAlias) => `["'](${pathAlias})["']`)
166
- .join('|'), 'g');
164
+ const pathAliases = Object.keys(inlinedDepsDestOutputRecord);
165
+ if (pathAliases.length == 0) {
166
+ return;
167
+ }
168
+ const importRegex = new RegExp(pathAliases.map((pathAlias) => `["'](${pathAlias})["']`).join('|'), 'g');
167
169
  recursiveUpdateImport(destOutputPath, importRegex, inlinedDepsDestOutputRecord);
168
170
  }
169
171
  function recursiveUpdateImport(dirPath, importRegex, inlinedDepsDestOutputRecord, rootParentDir) {
@@ -46,6 +46,7 @@ function getRootTsConfigFileName(tree) {
46
46
  exports.getRootTsConfigFileName = getRootTsConfigFileName;
47
47
  function addTsConfigPath(tree, importPath, lookupPaths) {
48
48
  (0, devkit_1.updateJson)(tree, getRootTsConfigPathInTree(tree), (json) => {
49
+ json.compilerOptions ??= {};
49
50
  const c = json.compilerOptions;
50
51
  c.paths ??= {};
51
52
  if (c.paths[importPath]) {