@nx/js 18.0.0-beta.0 → 18.0.0-beta.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/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": "18.0.0-beta.0",
3
+ "version": "18.0.0-beta.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": {
@@ -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",
@@ -54,12 +54,12 @@
54
54
  "js-tokens": "^4.0.0",
55
55
  "minimatch": "9.0.3",
56
56
  "ora": "5.3.0",
57
- "semver": "7.5.3",
57
+ "semver": "^7.5.3",
58
58
  "source-map-support": "0.5.19",
59
59
  "tslib": "^2.3.0",
60
- "@nx/devkit": "18.0.0-beta.0",
61
- "@nx/workspace": "18.0.0-beta.0",
62
- "@nrwl/js": "18.0.0-beta.0"
60
+ "@nx/devkit": "18.0.0-beta.2",
61
+ "@nx/workspace": "18.0.0-beta.2",
62
+ "@nrwl/js": "18.0.0-beta.2"
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",
@@ -11,6 +11,6 @@ export interface NormalizedSchema extends LibraryGeneratorSchema {
11
11
  parsedTags: string[];
12
12
  importPath?: string;
13
13
  }
14
- export type AddLintOptions = Pick<NormalizedSchema, 'name' | 'linter' | 'projectRoot' | 'unitTestRunner' | 'js' | 'setParserOptionsProject' | 'rootProject' | 'bundler'>;
14
+ export type AddLintOptions = Pick<NormalizedSchema, 'name' | 'linter' | 'projectRoot' | 'unitTestRunner' | 'js' | 'setParserOptionsProject' | 'rootProject' | 'bundler' | 'addPlugin'>;
15
15
  export declare function addLint(tree: Tree, options: AddLintOptions): Promise<GeneratorCallback>;
16
16
  export default libraryGenerator;
@@ -12,8 +12,11 @@ const versions_1 = require("../../utils/versions");
12
12
  const init_1 = require("../init/init");
13
13
  const generator_1 = require("../setup-verdaccio/generator");
14
14
  const create_ts_config_1 = require("../../utils/typescript/create-ts-config");
15
+ const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
16
+ const add_build_target_defaults_1 = require("@nx/devkit/src/generators/add-build-target-defaults");
15
17
  async function libraryGenerator(tree, schema) {
16
18
  return await libraryGeneratorInternal(tree, {
19
+ addPlugin: false,
17
20
  // provide a default projectNameAndRootFormat to avoid breaking changes
18
21
  // to external generators invoking this one
19
22
  projectNameAndRootFormat: 'derived',
@@ -48,6 +51,7 @@ async function libraryGeneratorInternal(tree, schema) {
48
51
  includeLib: true,
49
52
  skipFormat: true,
50
53
  testEnvironment: options.testEnvironment,
54
+ addPlugin: options.addPlugin,
51
55
  });
52
56
  tasks.push(viteTask);
53
57
  createOrEditViteConfig(tree, {
@@ -98,6 +102,9 @@ async function libraryGeneratorInternal(tree, schema) {
98
102
  if (!options.skipFormat) {
99
103
  await (0, devkit_1.formatFiles)(tree);
100
104
  }
105
+ tasks.push(() => {
106
+ (0, log_show_project_command_1.logShowProjectCommand)(options.name);
107
+ });
101
108
  return (0, devkit_1.runTasksInSerial)(...tasks);
102
109
  }
103
110
  exports.libraryGeneratorInternal = libraryGeneratorInternal;
@@ -113,8 +120,10 @@ function addProject(tree, options) {
113
120
  options.bundler !== 'none' &&
114
121
  options.config !== 'npm-scripts') {
115
122
  const outputPath = getOutputPath(options);
123
+ const executor = getBuildExecutor(options.bundler);
124
+ (0, add_build_target_defaults_1.addBuildTargetDefaults)(tree, executor);
116
125
  projectConfiguration.targets.build = {
117
- executor: getBuildExecutor(options.bundler),
126
+ executor,
118
127
  outputs: ['{options.outputPath}'],
119
128
  options: {
120
129
  outputPath,
@@ -173,6 +182,7 @@ async function addLint(tree, options) {
173
182
  unitTestRunner: options.unitTestRunner,
174
183
  setParserOptionsProject: options.setParserOptionsProject,
175
184
  rootProject: options.rootProject,
185
+ addPlugin: options.addPlugin,
176
186
  });
177
187
  const { addOverrideToLintConfig, lintConfigHasOverride, isEslintConfigSupported, updateOverrideInLintConfig,
178
188
  // nx-ignore-next-line
@@ -384,6 +394,7 @@ function replaceJestConfig(tree, options, filesDir) {
384
394
  });
385
395
  }
386
396
  async function normalizeOptions(tree, options) {
397
+ options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
387
398
  /**
388
399
  * We are deprecating the compiler and the buildable options.
389
400
  * However, we want to keep the existing behavior for now.
@@ -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",
@@ -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`",
@@ -14,23 +14,30 @@ async function updateLockFile(cwd, { dryRun, verbose, generatorOptions, }) {
14
14
  }
15
15
  return [];
16
16
  }
17
+ const packageManager = (0, devkit_1.detectPackageManager)(cwd);
18
+ if (packageManager === 'yarn' &&
19
+ !(0, semver_1.gte)((0, devkit_1.getPackageManagerVersion)(packageManager), '2.0.0')) {
20
+ // yarn classic does not store workspace data in the lock file, so we don't need to update it
21
+ if (verbose) {
22
+ console.log('\nSkipped lock file update because it is not necessary for Yarn Classic.');
23
+ }
24
+ return [];
25
+ }
17
26
  const isDaemonEnabled = client_1.daemonClient.enabled();
18
27
  if (isDaemonEnabled) {
19
28
  // temporarily stop the daemon, as it will error if the lock file is updated
20
29
  await client_1.daemonClient.stop();
21
30
  }
22
- const packageManager = (0, devkit_1.detectPackageManager)(cwd);
23
31
  const packageManagerCommands = (0, devkit_1.getPackageManagerCommand)(packageManager);
24
32
  let installArgs = generatorOptions?.installArgs || '';
25
33
  devkit_1.output.logSingleLine(`Updating ${packageManager} lock file`);
26
34
  let env = {};
27
35
  if (generatorOptions?.installIgnoreScripts) {
28
- if (packageManager === 'yarn' &&
29
- (0, semver_1.gte)((0, devkit_1.getPackageManagerVersion)(packageManager), '2.0.0')) {
36
+ if (packageManager === 'yarn') {
30
37
  env = { YARN_ENABLE_SCRIPTS: 'false' };
31
38
  }
32
39
  else {
33
- // npm, pnpm, and yarn classic all use the same --ignore-scripts option
40
+ // npm and pnpm use the same --ignore-scripts option
34
41
  installArgs = `${installArgs} --ignore-scripts`.trim();
35
42
  }
36
43
  }
@@ -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.",
@@ -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) {
@@ -33,6 +33,7 @@ export interface LibraryGeneratorSchema {
33
33
  minimal?: boolean;
34
34
  rootProject?: boolean;
35
35
  simpleName?: boolean;
36
+ addPlugin?: boolean;
36
37
  }
37
38
 
38
39
  export interface ExecutorOptions {