@nx/js 16.10.0 → 17.0.0-beta.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/migrations.json CHANGED
@@ -1,35 +1,5 @@
1
1
  {
2
2
  "generators": {
3
- "update-node-executor": {
4
- "cli": "nx",
5
- "version": "13.8.5-beta.1",
6
- "description": "Renames @nrwl/js:node to @nrwl/node:node",
7
- "factory": "./src/migrations/update-13-8-5/update-node-executor"
8
- },
9
- "update-swcrc": {
10
- "cli": "nx",
11
- "version": "13.8.5-beta.1",
12
- "description": "Adjust .swcrc to .lib.swcrc",
13
- "factory": "./src/migrations/update-13-8-5/update-swcrc"
14
- },
15
- "update-swcrc-exclude": {
16
- "cli": "nx",
17
- "version": "13.10.1-beta.1",
18
- "description": "Update .lib.swcrc to exclude missing test files",
19
- "factory": "./src/migrations/update-13-10-1/update-lib-swcrc-exclude"
20
- },
21
- "exclude-jest-config-swcrc": {
22
- "cli": "nx",
23
- "version": "14.0.0-beta.2",
24
- "description": "Exclude jest config from .lib.swcrc",
25
- "factory": "./src/migrations/update-14-0-0/exclude-jest-config-swcrc"
26
- },
27
- "update-swcrc-path": {
28
- "cli": "nx",
29
- "version": "14.1.5-beta.0",
30
- "description": "Rename option swcrcPath to swcrc, and resolve relative to workspace root",
31
- "factory": "./src/migrations/update-14-1-5/update-swcrc-path"
32
- },
33
3
  "rename-swcrc-config": {
34
4
  "cli": "nx",
35
5
  "version": "15.8.0-beta.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/js",
3
- "version": "16.10.0",
3
+ "version": "17.0.0-beta.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": {
@@ -59,9 +59,9 @@
59
59
  "semver": "7.5.3",
60
60
  "source-map-support": "0.5.19",
61
61
  "tslib": "^2.3.0",
62
- "@nx/devkit": "16.10.0",
63
- "@nx/workspace": "16.10.0",
64
- "@nrwl/js": "16.10.0"
62
+ "@nx/devkit": "17.0.0-beta.1",
63
+ "@nx/workspace": "17.0.0-beta.1",
64
+ "@nrwl/js": "17.0.0-beta.1"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "verdaccio": "^5.0.4"
@@ -134,6 +134,7 @@ function setupNpm(options) {
134
134
  }
135
135
  else {
136
136
  (0, child_process_1.execSync)(`npm config delete registry --location ${options.location}`);
137
+ devkit_1.logger.info('Cleared custom npm registry');
137
138
  }
138
139
  (0, child_process_1.execSync)(`npm config delete //localhost:${options.port}/:_authToken --location ${options.location}`);
139
140
  }
@@ -196,6 +197,7 @@ function setupYarn(options) {
196
197
  else {
197
198
  (0, child_process_1.execSync)(`yarn config ${isYarnV1 ? 'delete' : 'unset'} ${registryConfigName}` +
198
199
  (options.location === 'user' ? ' --home' : ''));
200
+ devkit_1.logger.info(`Cleared custom yarn ${registryConfigName}`);
199
201
  }
200
202
  if (whitelistedLocalhost) {
201
203
  const currentWhitelist = getYarnUnsafeHttpWhitelist(isYarnV1);
@@ -45,6 +45,10 @@ async function initGenerator(tree, schema) {
45
45
  const devDependencies = {
46
46
  '@nx/js': versions_1.nxVersion,
47
47
  prettier: versions_1.prettierVersion,
48
+ // When loading .ts config files (e.g. webpack.config.ts, jest.config.ts, etc.)
49
+ // we prefer to use SWC, and fallback to ts-node for workspaces that don't use SWC.
50
+ '@swc-node/register': versions_1.swcNodeVersion,
51
+ '@swc/core': versions_1.swcCoreVersion,
48
52
  };
49
53
  if (!schema.js) {
50
54
  const installedTsVersion = await getInstalledTypescriptVersion(tree);
@@ -78,6 +82,7 @@ async function initGenerator(tree, schema) {
78
82
  # Add files here to ignore them from prettier formatting
79
83
  /dist
80
84
  /coverage
85
+ /.nx/cache
81
86
  `);
82
87
  }
83
88
  if (tree.exists('.vscode/extensions.json')) {
@@ -148,6 +148,9 @@ function addProject(tree, options) {
148
148
  }
149
149
  async function addLint(tree, options) {
150
150
  const { lintProjectGenerator } = (0, devkit_1.ensurePackage)('@nx/linter', versions_1.nxVersion);
151
+ const { mapLintPattern } =
152
+ // nx-ignore-next-line
153
+ require('@nx/linter/src/generators/lint-project/lint-project');
151
154
  const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, options.name);
152
155
  const task = lintProjectGenerator(tree, {
153
156
  project: options.name,
@@ -158,7 +161,7 @@ async function addLint(tree, options) {
158
161
  ],
159
162
  unitTestRunner: options.unitTestRunner,
160
163
  eslintFilePatterns: [
161
- `${options.projectRoot}/**/*.${options.js ? 'js' : 'ts'}`,
164
+ mapLintPattern(options.projectRoot, options.js ? 'js' : 'ts', options.rootProject),
162
165
  ],
163
166
  setParserOptionsProject: options.setParserOptionsProject,
164
167
  rootProject: options.rootProject,
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export default function updateSwcRcExclude(tree: Tree): void;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const devkit_1 = require("@nx/devkit");
4
- const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
5
- const path_1 = require("path");
6
- const add_swc_config_1 = require("../../utils/swc/add-swc-config");
7
- function updateSwcRcExclude(tree) {
8
- (0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/js:swc', (config, projectName) => {
9
- const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
10
- const libSwcPath = (0, path_1.join)(projectConfig.root, '.lib.swcrc');
11
- if (!tree.exists(libSwcPath))
12
- return;
13
- (0, devkit_1.updateJson)(tree, libSwcPath, (json) => {
14
- if (json.exclude) {
15
- const excludePatterns = new Set([
16
- ...add_swc_config_1.defaultExclude,
17
- ...json.exclude,
18
- ]);
19
- // remove old patterns that are duplicate for new patterns
20
- // defined in defaultExclude
21
- excludePatterns.delete('./**/.*.spec.ts$');
22
- excludePatterns.delete('./src/**/.*.spec.ts$');
23
- excludePatterns.delete('./**/.*.js$');
24
- excludePatterns.delete('./src/**/jest-setup.ts$');
25
- json.exclude = [...excludePatterns];
26
- }
27
- return json;
28
- }, { expectComments: true });
29
- });
30
- }
31
- exports.default = updateSwcRcExclude;
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export default function update(host: Tree): Promise<import("@nx/devkit").GeneratorCallback>;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const devkit_1 = require("@nx/devkit");
4
- const versions_1 = require("@nx/workspace/src/utils/versions");
5
- async function update(host) {
6
- const projects = (0, devkit_1.getProjects)(host);
7
- let installNeeded = false;
8
- for (const [name, config] of projects.entries()) {
9
- if (config?.targets?.serve?.executor !== '@nrwl/js:node')
10
- continue;
11
- config.targets.serve.executor = '@nrwl/node:node';
12
- installNeeded = true;
13
- (0, devkit_1.updateProjectConfiguration)(host, name, config);
14
- }
15
- const task = installNeeded
16
- ? (0, devkit_1.addDependenciesToPackageJson)(host, {}, {
17
- '@nrwl/node': versions_1.nxVersion,
18
- })
19
- : undefined;
20
- await (0, devkit_1.formatFiles)(host);
21
- return task;
22
- }
23
- exports.default = update;
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export default function update(host: Tree): Promise<void>;
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const devkit_1 = require("@nx/devkit");
4
- const path_1 = require("path");
5
- const add_swc_config_1 = require("../../utils/swc/add-swc-config");
6
- async function update(host) {
7
- const projects = (0, devkit_1.getProjects)(host);
8
- for (const config of projects.values()) {
9
- if (config?.targets?.build?.executor !== '@nrwl/js:swc')
10
- continue;
11
- const swcrcPath = (0, path_1.join)(config.root, '.swcrc');
12
- if (!host.exists(swcrcPath))
13
- continue;
14
- // rename
15
- const libSwcrcPath = (0, path_1.join)(config.root, '.lib.swcrc');
16
- host.rename(swcrcPath, libSwcrcPath);
17
- const swcrcContent = (0, devkit_1.readJson)(host, libSwcrcPath);
18
- // skip if swcrc already has "exclude" field
19
- if (swcrcContent['exclude'])
20
- continue;
21
- // check swcExclude build options
22
- const exclude = config?.targets?.build?.options?.['swcExclude'] || add_swc_config_1.defaultExclude;
23
- (0, devkit_1.updateJson)(host, libSwcrcPath, (swcrc) => {
24
- swcrc['exclude'] = exclude;
25
- return swcrc;
26
- });
27
- }
28
- await (0, devkit_1.formatFiles)(host);
29
- }
30
- exports.default = update;
@@ -1,3 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export declare function excludeJestConfigSwcrc(tree: Tree): void;
3
- export default excludeJestConfigSwcrc;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.excludeJestConfigSwcrc = void 0;
4
- const devkit_1 = require("@nx/devkit");
5
- const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
6
- const path_1 = require("path");
7
- function excludeJestConfigSwcrc(tree) {
8
- (0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/js:swc', (config, projectName) => {
9
- const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
10
- const libSwcPath = (0, path_1.join)(projectConfig.root, '.lib.swcrc');
11
- if (!tree.exists(libSwcPath))
12
- return;
13
- (0, devkit_1.updateJson)(tree, libSwcPath, (json) => {
14
- if (json.exclude) {
15
- const excludePatterns = new Set([
16
- 'jest.config.js',
17
- ...json.exclude,
18
- ]);
19
- json.exclude = [...excludePatterns];
20
- }
21
- return json;
22
- }, { expectComments: true });
23
- });
24
- }
25
- exports.excludeJestConfigSwcrc = excludeJestConfigSwcrc;
26
- exports.default = excludeJestConfigSwcrc;
@@ -1,3 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export declare function updateSwcrcPath(tree: Tree): Promise<void>;
3
- export default updateSwcrcPath;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateSwcrcPath = void 0;
4
- const devkit_1 = require("@nx/devkit");
5
- const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
6
- async function updateSwcrcPath(tree) {
7
- let changesMade = false;
8
- (0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/js:swc', (_, projectName, targetName, configurationName) => {
9
- const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
10
- const executorOptions = configurationName
11
- ? projectConfig.targets[targetName].configurations[configurationName]
12
- : projectConfig.targets[targetName].options;
13
- if (!executorOptions.swcrcPath)
14
- return;
15
- const newSwcrcPath = (0, devkit_1.joinPathFragments)(projectConfig.root, executorOptions.swcrcPath);
16
- delete executorOptions.swcrcPath;
17
- executorOptions.swcrc = newSwcrcPath;
18
- (0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfig);
19
- changesMade = true;
20
- });
21
- if (changesMade) {
22
- await (0, devkit_1.formatFiles)(tree);
23
- }
24
- }
25
- exports.updateSwcrcPath = updateSwcrcPath;
26
- exports.default = updateSwcrcPath;