@nx/js 20.2.1 → 20.3.0-beta.0

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": "20.2.1",
3
+ "version": "20.3.0-beta.0",
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": {
@@ -39,8 +39,8 @@
39
39
  "@babel/preset-env": "^7.23.2",
40
40
  "@babel/preset-typescript": "^7.22.5",
41
41
  "@babel/runtime": "^7.22.6",
42
- "@nx/devkit": "20.2.1",
43
- "@nx/workspace": "20.2.1",
42
+ "@nx/devkit": "20.3.0-beta.0",
43
+ "@nx/workspace": "20.3.0-beta.0",
44
44
  "@zkochan/js-yaml": "0.0.7",
45
45
  "babel-plugin-const-enum": "^1.0.1",
46
46
  "babel-plugin-macros": "^2.8.0",
@@ -49,7 +49,6 @@
49
49
  "columnify": "^1.6.0",
50
50
  "detect-port": "^1.5.1",
51
51
  "enquirer": "~2.3.6",
52
- "fast-glob": "3.2.7",
53
52
  "ignore": "^5.0.4",
54
53
  "js-tokens": "^4.0.0",
55
54
  "jsonc-parser": "3.2.0",
@@ -59,6 +58,7 @@
59
58
  "ora": "5.3.0",
60
59
  "semver": "^7.5.3",
61
60
  "source-map-support": "0.5.19",
61
+ "tinyglobby": "^0.2.10",
62
62
  "ts-node": "10.9.1",
63
63
  "tsconfig-paths": "^4.1.2",
64
64
  "tslib": "^2.3.0"
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.swcExecutor = swcExecutor;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const fast_glob_1 = require("fast-glob");
5
+ const tinyglobby_1 = require("tinyglobby");
6
6
  const node_fs_1 = require("node:fs");
7
7
  const path_1 = require("path");
8
8
  const assets_1 = require("../../utils/assets");
@@ -29,7 +29,7 @@ function normalizeOptions(options, root, sourceRoot, projectRoot) {
29
29
  }
30
30
  }
31
31
  const outputPath = (0, path_1.join)(root, options.outputPath);
32
- if (options.skipTypeCheck == null) {
32
+ if (options.skipTypeCheck == null && !isTsSolutionSetup) {
33
33
  options.skipTypeCheck = false;
34
34
  }
35
35
  if (options.watch == null) {
@@ -158,8 +158,9 @@ function removeTmpSwcrc(swcrcPath) {
158
158
  function createEntryPoints(options, context) {
159
159
  if (!options.additionalEntryPoints?.length)
160
160
  return [];
161
- return (0, fast_glob_1.sync)(options.additionalEntryPoints, {
161
+ return (0, tinyglobby_1.globSync)(options.additionalEntryPoints, {
162
162
  cwd: context.root,
163
+ expandDirectories: false,
163
164
  });
164
165
  }
165
166
  exports.default = swcExecutor;
@@ -182,7 +182,8 @@ async function configureProject(tree, options) {
182
182
  if (options.bundler === 'esbuild') {
183
183
  projectConfiguration.targets.build.options.format = ['cjs'];
184
184
  }
185
- if (options.bundler === 'swc' && options.skipTypeCheck) {
185
+ if (options.bundler === 'swc' &&
186
+ (options.skipTypeCheck || options.isUsingTsSolutionConfig)) {
186
187
  projectConfiguration.targets.build.options.skipTypeCheck = true;
187
188
  }
188
189
  if (options.isUsingTsSolutionConfig) {
@@ -548,7 +549,7 @@ async function normalizeOptions(tree, options) {
548
549
  options.bundler = 'none';
549
550
  }
550
551
  if ((options.bundler === 'swc' || options.bundler === 'rollup') &&
551
- options.skipTypeCheck == null) {
552
+ (options.skipTypeCheck == null || !isUsingTsSolutionConfig)) {
552
553
  options.skipTypeCheck = false;
553
554
  }
554
555
  const { projectName, names: projectNames, projectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
@@ -20,6 +20,12 @@ const npm_config_1 = require("../../utils/npm-config");
20
20
  const resolve_local_package_dependencies_1 = require("./utils/resolve-local-package-dependencies");
21
21
  const sort_projects_topologically_1 = require("./utils/sort-projects-topologically");
22
22
  const update_lock_file_1 = require("./utils/update-lock-file");
23
+ function resolvePreIdSpecifier(currentSpecifier, preid) {
24
+ if (!currentSpecifier.startsWith('pre') && preid) {
25
+ return `pre${currentSpecifier}`;
26
+ }
27
+ return currentSpecifier;
28
+ }
23
29
  async function releaseVersionGenerator(tree, options) {
24
30
  let logger;
25
31
  try {
@@ -46,7 +52,7 @@ Valid values are: ${version_1.validReleaseVersionPrefixes
46
52
  }
47
53
  // Set default for updateDependents
48
54
  const updateDependents = options.updateDependents ?? 'auto';
49
- const updateDependentsBump = 'patch';
55
+ const updateDependentsBump = resolvePreIdSpecifier('patch', options.preid);
50
56
  // Sort the projects topologically if update dependents is enabled
51
57
  // TODO: maybe move this sorting to the command level?
52
58
  const projects = updateDependents === 'never' ||
@@ -291,8 +297,9 @@ To fix this you will either need to add a package.json file at that location, or
291
297
  }
292
298
  else {
293
299
  let extraText = '';
294
- if (options.preid && !specifier.startsWith('pre')) {
295
- specifier = `pre${specifier}`;
300
+ const prereleaseSpecifier = resolvePreIdSpecifier(specifier, options.preid);
301
+ if (prereleaseSpecifier !== specifier) {
302
+ specifier = prereleaseSpecifier;
296
303
  extraText = `, combined with your given preid "${options.preid}"`;
297
304
  }
298
305
  logger.buffer(`📄 Resolved the specifier as "${specifier}" using git history and the conventional commits standard${extraText}.`);
@@ -393,6 +400,7 @@ To fix this you will either need to add a package.json file at that location, or
393
400
  const localPackageDependencies = (0, resolve_local_package_dependencies_1.resolveLocalPackageDependencies)(tree, options.projectGraph, projects, projectNameToPackageRootMap, resolvePackageRoot,
394
401
  // includeAll when the release group is independent, as we may be filtering to a specific subset of projects, but we still want to update their dependents
395
402
  options.releaseGroup.projectsRelationship === 'independent');
403
+ // list of projects that depend on the current package
396
404
  const allDependentProjects = Object.values(localPackageDependencies)
397
405
  .flat()
398
406
  .filter((localPackageDependency) => {
@@ -4,11 +4,13 @@
4
4
  * @param storage the storage location for the local registry
5
5
  * @param verbose whether to log verbose output
6
6
  * @param clearStorage whether to clear the verdaccio storage before running the registry
7
+ * @param listenAddress the address that verdaccio should listen to (default to `localhost`)
7
8
  */
8
- export declare function startLocalRegistry({ localRegistryTarget, storage, verbose, clearStorage, }: {
9
+ export declare function startLocalRegistry({ localRegistryTarget, storage, verbose, clearStorage, listenAddress, }: {
9
10
  localRegistryTarget: string;
10
11
  storage?: string;
11
12
  verbose?: boolean;
12
13
  clearStorage?: boolean;
14
+ listenAddress?: string;
13
15
  }): Promise<() => void>;
14
16
  export default startLocalRegistry;
@@ -8,8 +8,10 @@ const child_process_1 = require("child_process");
8
8
  * @param storage the storage location for the local registry
9
9
  * @param verbose whether to log verbose output
10
10
  * @param clearStorage whether to clear the verdaccio storage before running the registry
11
+ * @param listenAddress the address that verdaccio should listen to (default to `localhost`)
11
12
  */
12
- function startLocalRegistry({ localRegistryTarget, storage, verbose, clearStorage, }) {
13
+ function startLocalRegistry({ localRegistryTarget, storage, verbose, clearStorage, listenAddress, }) {
14
+ listenAddress ??= 'localhost';
13
15
  if (!localRegistryTarget) {
14
16
  throw new Error(`localRegistryTarget is required`);
15
17
  }
@@ -21,24 +23,26 @@ function startLocalRegistry({ localRegistryTarget, storage, verbose, clearStorag
21
23
  const listener = (data) => {
22
24
  if (verbose) {
23
25
  process.stdout.write(data);
26
+ console.log('Waiting for local registry to start...');
24
27
  }
25
- if (data.toString().includes('http://localhost:')) {
26
- const port = parseInt(data.toString().match(/localhost:(?<port>\d+)/)?.groups?.port);
27
- console.log('Local registry started on port ' + port);
28
- const registry = `http://localhost:${port}`;
28
+ if (data.toString().includes(`http://${listenAddress}:`)) {
29
+ const port = parseInt(data.toString().match(new RegExp(`${listenAddress}:(?<port>\\d+)`))
30
+ ?.groups?.port);
31
+ const registry = `http://${listenAddress}:${port}`;
32
+ console.log(`Local registry started on ${registry}`);
29
33
  process.env.npm_config_registry = registry;
30
- (0, child_process_1.execSync)(`npm config set //localhost:${port}/:_authToken "secretVerdaccioToken"`, {
34
+ (0, child_process_1.execSync)(`npm config set //${listenAddress}:${port}/:_authToken "secretVerdaccioToken"`, {
31
35
  windowsHide: false,
32
36
  });
33
37
  // yarnv1
34
38
  process.env.YARN_REGISTRY = registry;
35
39
  // yarnv2
36
40
  process.env.YARN_NPM_REGISTRY_SERVER = registry;
37
- process.env.YARN_UNSAFE_HTTP_WHITELIST = 'localhost';
41
+ process.env.YARN_UNSAFE_HTTP_WHITELIST = listenAddress;
38
42
  console.log('Set npm and yarn config registry to ' + registry);
39
43
  resolve(() => {
40
44
  childProcess.kill();
41
- (0, child_process_1.execSync)(`npm config delete //localhost:${port}/:_authToken`, {
45
+ (0, child_process_1.execSync)(`npm config delete //${listenAddress}:${port}/:_authToken`, {
42
46
  windowsHide: false,
43
47
  });
44
48
  });
@@ -1,15 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.assetGlobsToFiles = assetGlobsToFiles;
4
- const fastGlob = require("fast-glob");
4
+ const tinyglobby_1 = require("tinyglobby");
5
5
  const path_1 = require("path");
6
6
  function assetGlobsToFiles(assets, rootDir, outDir) {
7
7
  const files = [];
8
8
  const globbedFiles = (pattern, input = '', ignore = [], dot = false) => {
9
- return fastGlob.sync(pattern, {
9
+ return (0, tinyglobby_1.globSync)(pattern, {
10
10
  cwd: input,
11
11
  onlyFiles: true,
12
12
  dot,
13
+ expandDirectories: false,
13
14
  ignore,
14
15
  });
15
16
  };
@@ -6,7 +6,7 @@ const node_fs_1 = require("node:fs");
6
6
  const pathPosix = require("node:path/posix");
7
7
  const path = require("node:path");
8
8
  const ignore_1 = require("ignore");
9
- const fg = require("fast-glob");
9
+ const tinyglobby_1 = require("tinyglobby");
10
10
  const devkit_1 = require("@nx/devkit");
11
11
  const client_1 = require("nx/src/daemon/client/client");
12
12
  const defaultFileEventHandler = (events) => {
@@ -73,10 +73,11 @@ class CopyAssetsHandler {
73
73
  async processAllAssetsOnce() {
74
74
  await Promise.all(this.assetGlobs.map(async (ag) => {
75
75
  const pattern = this.normalizeAssetPattern(ag);
76
- // fast-glob only supports Unix paths
77
- const files = await fg(pattern.replace(/\\/g, '/'), {
76
+ // globbing only supports Unix paths
77
+ const files = await (0, tinyglobby_1.globSync)(pattern.replace(/\\/g, '/'), {
78
78
  cwd: this.rootDir,
79
79
  dot: true, // enable hidden files
80
+ expandDirectories: false,
80
81
  });
81
82
  this.callback(this.filesToEvent(files, ag));
82
83
  }));
@@ -84,10 +85,11 @@ class CopyAssetsHandler {
84
85
  processAllAssetsOnceSync() {
85
86
  this.assetGlobs.forEach((ag) => {
86
87
  const pattern = this.normalizeAssetPattern(ag);
87
- // fast-glob only supports Unix paths
88
- const files = fg.sync(pattern.replace(/\\/g, '/'), {
88
+ // globbing only supports Unix paths
89
+ const files = (0, tinyglobby_1.globSync)(pattern.replace(/\\/g, '/'), {
89
90
  cwd: this.rootDir,
90
91
  dot: true, // enable hidden files
92
+ expandDirectories: false,
91
93
  });
92
94
  this.callback(this.filesToEvent(files, ag));
93
95
  });
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createEntryPoints = createEntryPoints;
4
- const fast_glob_1 = require("fast-glob");
4
+ const tinyglobby_1 = require("tinyglobby");
5
5
  const devkit_1 = require("@nx/devkit");
6
6
  function createEntryPoints(additionalEntryPoints, root) {
7
7
  if (!additionalEntryPoints?.length)
@@ -13,7 +13,10 @@ function createEntryPoints(additionalEntryPoints, root) {
13
13
  // Performance impact should be negligible since there shouldn't be that many entry points.
14
14
  // Benchmarks show only 1-3% difference in execution time.
15
15
  for (const pattern of additionalEntryPoints) {
16
- const matched = (0, fast_glob_1.sync)([pattern], { cwd: root });
16
+ const matched = (0, tinyglobby_1.globSync)([pattern], {
17
+ cwd: root,
18
+ expandDirectories: false,
19
+ });
17
20
  if (!matched.length)
18
21
  devkit_1.logger.warn(`The pattern ${pattern} did not match any files.`);
19
22
  files.push(...matched);
@@ -29,8 +29,11 @@ function isWorkspacesEnabled(tree
29
29
  return tree.exists('pnpm-workspace.yaml');
30
30
  }
31
31
  // yarn and npm both use the same 'workspaces' property in package.json
32
- const packageJson = (0, devkit_1.readJson)(tree, 'package.json');
33
- return !!packageJson?.workspaces;
32
+ if (tree.exists('package.json')) {
33
+ const packageJson = (0, devkit_1.readJson)(tree, 'package.json');
34
+ return !!packageJson?.workspaces;
35
+ }
36
+ return false;
34
37
  }
35
38
  function getProjectPackageManagerWorkspaceStateWarningTask(projectPackageManagerWorkspaceState, workspaceRoot) {
36
39
  return () => {
@@ -66,7 +66,7 @@ async function compileSwc(context, normalizedOptions, postCompilationCallback) {
66
66
  });
67
67
  devkit_1.logger.log(swcCmdLog.replace(/\n/, ''));
68
68
  const isCompileSuccess = swcCmdLog.includes('Successfully compiled');
69
- if (normalizedOptions.skipTypeCheck) {
69
+ if (normalizedOptions.skipTypeCheck || normalizedOptions.isTsSolutionSetup) {
70
70
  await postCompilationCallback();
71
71
  return { success: isCompileSuccess };
72
72
  }
@@ -116,7 +116,8 @@ async function* compileSwcWatch(context, normalizedOptions, postCompilationCallb
116
116
  await postCompilationCallback();
117
117
  initialPostCompile = false;
118
118
  }
119
- if (normalizedOptions.skipTypeCheck) {
119
+ if (normalizedOptions.skipTypeCheck ||
120
+ normalizedOptions.isTsSolutionSetup) {
120
121
  next(getResult(swcStatus));
121
122
  return;
122
123
  }