@nx/js 18.1.0-beta.2 → 18.1.0-beta.3

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": "18.1.0-beta.2",
3
+ "version": "18.1.0-beta.3",
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": {
@@ -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": "18.1.0-beta.2",
61
- "@nx/workspace": "18.1.0-beta.2",
62
- "@nrwl/js": "18.1.0-beta.2"
60
+ "@nx/devkit": "18.1.0-beta.3",
61
+ "@nx/workspace": "18.1.0-beta.3",
62
+ "@nrwl/js": "18.1.0-beta.3"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "verdaccio": "^5.0.4"
@@ -25,7 +25,6 @@ async function libraryGenerator(tree, schema) {
25
25
  }
26
26
  exports.libraryGenerator = libraryGenerator;
27
27
  async function libraryGeneratorInternal(tree, schema) {
28
- const filesDir = (0, path_1.join)(__dirname, './files');
29
28
  const tasks = [];
30
29
  tasks.push(await (0, init_1.default)(tree, {
31
30
  ...schema,
@@ -33,7 +32,7 @@ async function libraryGeneratorInternal(tree, schema) {
33
32
  tsConfigName: schema.rootProject ? 'tsconfig.json' : 'tsconfig.base.json',
34
33
  }));
35
34
  const options = await normalizeOptions(tree, schema);
36
- createFiles(tree, options, `${filesDir}/lib`);
35
+ createFiles(tree, options);
37
36
  addProject(tree, options);
38
37
  if (!options.skipPackageJson) {
39
38
  tasks.push(addProjectDependencies(tree, options));
@@ -69,7 +68,7 @@ async function libraryGeneratorInternal(tree, schema) {
69
68
  const jestCallback = await addJest(tree, options);
70
69
  tasks.push(jestCallback);
71
70
  if (options.bundler === 'swc' || options.bundler === 'rollup') {
72
- replaceJestConfig(tree, options, `${filesDir}/jest-config`);
71
+ replaceJestConfig(tree, options);
73
72
  }
74
73
  }
75
74
  else if (options.unitTestRunner === 'vitest' &&
@@ -284,10 +283,10 @@ function addBabelRc(tree, options) {
284
283
  };
285
284
  (0, devkit_1.writeJson)(tree, (0, path_1.join)(options.projectRoot, filename), babelrc);
286
285
  }
287
- function createFiles(tree, options, filesDir) {
286
+ function createFiles(tree, options) {
288
287
  const { className, name, propertyName } = (0, devkit_1.names)(options.projectNames.projectFileName);
289
288
  createProjectTsConfigJson(tree, options);
290
- (0, devkit_1.generateFiles)(tree, filesDir, options.projectRoot, {
289
+ (0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files/lib'), options.projectRoot, {
291
290
  ...options,
292
291
  dot: '.',
293
292
  className,
@@ -301,6 +300,22 @@ function createFiles(tree, options, filesDir) {
301
300
  buildable: options.bundler && options.bundler !== 'none',
302
301
  hasUnitTestRunner: options.unitTestRunner !== 'none',
303
302
  });
303
+ if (!options.rootProject) {
304
+ (0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files/readme'), options.projectRoot, {
305
+ ...options,
306
+ dot: '.',
307
+ className,
308
+ name,
309
+ propertyName,
310
+ js: !!options.js,
311
+ cliCommand: 'nx',
312
+ strict: undefined,
313
+ tmpl: '',
314
+ offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.projectRoot),
315
+ buildable: options.bundler && options.bundler !== 'none',
316
+ hasUnitTestRunner: options.unitTestRunner !== 'none',
317
+ });
318
+ }
304
319
  if (options.bundler === 'swc' || options.bundler === 'rollup') {
305
320
  (0, add_swc_dependencies_1.addSwcDependencies)(tree);
306
321
  (0, add_swc_config_1.addSwcConfig)(tree, options.projectRoot, options.bundler === 'swc' ? 'commonjs' : 'es6');
@@ -377,7 +392,8 @@ async function addJest(tree, options) {
377
392
  : undefined,
378
393
  });
379
394
  }
380
- function replaceJestConfig(tree, options, filesDir) {
395
+ function replaceJestConfig(tree, options) {
396
+ const filesDir = (0, path_1.join)(__dirname, './files/jest-config');
381
397
  // the existing config has to be deleted otherwise the new config won't overwrite it
382
398
  const existingJestConfig = (0, devkit_1.joinPathFragments)(filesDir, `jest.config.${options.js ? 'js' : 'ts'}`);
383
399
  if (tree.exists(existingJestConfig)) {
@@ -394,7 +410,10 @@ function replaceJestConfig(tree, options, filesDir) {
394
410
  });
395
411
  }
396
412
  async function normalizeOptions(tree, options) {
397
- options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
413
+ const nxJson = (0, devkit_1.readNxJson)(tree);
414
+ const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
415
+ nxJson.useInferencePlugins !== false;
416
+ options.addPlugin ??= addPlugin;
398
417
  /**
399
418
  * We are deprecating the compiler and the buildable options.
400
419
  * However, we want to keep the existing behavior for now.
@@ -23,6 +23,13 @@ async function updateLockFile(cwd, { dryRun, verbose, generatorOptions, }) {
23
23
  }
24
24
  return [];
25
25
  }
26
+ const workspacesEnabled = (0, devkit_1.isWorkspacesEnabled)(packageManager, cwd);
27
+ if (!workspacesEnabled) {
28
+ if (verbose) {
29
+ console.log(`\nSkipped lock file update because ${packageManager} workspaces are not enabled.`);
30
+ }
31
+ return [];
32
+ }
26
33
  const isDaemonEnabled = client_1.daemonClient.enabled();
27
34
  if (!dryRun && isDaemonEnabled) {
28
35
  // if not in dry-run temporarily stop the daemon, as it will error if the lock file is updated
@@ -127,7 +127,7 @@ function calculateDependenciesFromTaskGraph(taskGraph, projectGraph, root, proje
127
127
  const depTask = taskGraph.tasks[taskName];
128
128
  const depProjectNode = projectGraph.nodes?.[depTask.target.project];
129
129
  if (depProjectNode?.type !== 'lib') {
130
- return null;
130
+ continue;
131
131
  }
132
132
  let outputs = (0, devkit_1.getOutputsForTargetAndConfiguration)(depTask.target, depTask.overrides, depProjectNode);
133
133
  if (outputs.length === 0) {