@nx/js 19.0.0-beta.7 → 19.0.0-beta.9

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,11 +1,5 @@
1
1
  {
2
2
  "generators": {
3
- "rename-swcrc-config": {
4
- "cli": "nx",
5
- "version": "15.8.0-beta.0",
6
- "description": "Rename .lib.swcrc to .swcrc for better SWC support throughout the workspace",
7
- "factory": "./src/migrations/update-15-8-0/rename-swcrc-config"
8
- },
9
3
  "update-16-0-0-add-nx-packages": {
10
4
  "cli": "nx",
11
5
  "version": "16.0.0-beta.1",
@@ -32,18 +26,6 @@
32
26
  }
33
27
  },
34
28
  "packageJsonUpdates": {
35
- "15.8.0": {
36
- "version": "15.8.0-beta.2",
37
- "x-prompt": "Do you want to update to TypeScript v4.9?",
38
- "requires": {
39
- "typescript": ">=4.8.2 <4.9.0"
40
- },
41
- "packages": {
42
- "typescript": {
43
- "version": "~4.9.5"
44
- }
45
- }
46
- },
47
29
  "16.0.0": {
48
30
  "version": "16.0.0-beta.3",
49
31
  "packages": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/js",
3
- "version": "19.0.0-beta.7",
3
+ "version": "19.0.0-beta.9",
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": {
@@ -37,7 +37,6 @@
37
37
  "@babel/preset-env": "^7.23.2",
38
38
  "@babel/preset-typescript": "^7.22.5",
39
39
  "@babel/runtime": "^7.22.6",
40
- "@phenomnomnominal/tsquery": "~5.0.1",
41
40
  "babel-plugin-const-enum": "^1.0.1",
42
41
  "babel-plugin-macros": "^2.8.0",
43
42
  "babel-plugin-transform-typescript-metadata": "^0.3.1",
@@ -57,9 +56,9 @@
57
56
  "semver": "^7.5.3",
58
57
  "source-map-support": "0.5.19",
59
58
  "tslib": "^2.3.0",
60
- "@nx/devkit": "19.0.0-beta.7",
61
- "@nx/workspace": "19.0.0-beta.7",
62
- "@nrwl/js": "19.0.0-beta.7"
59
+ "@nx/devkit": "19.0.0-beta.9",
60
+ "@nx/workspace": "19.0.0-beta.9",
61
+ "@nrwl/js": "19.0.0-beta.9"
63
62
  },
64
63
  "peerDependencies": {
65
64
  "verdaccio": "^5.0.4"
@@ -297,7 +297,7 @@ function getFileToRun(context, project, buildOptions, buildTargetExecutor) {
297
297
  function fileToRunCorrectPath(fileToRun) {
298
298
  if ((0, fileutils_1.fileExists)(fileToRun))
299
299
  return fileToRun;
300
- const extensionsToTry = ['.cjs', '.mjs', 'cjs.js', '.esm.js'];
300
+ const extensionsToTry = ['.cjs', '.mjs', '.cjs.js', '.esm.js'];
301
301
  for (const ext of extensionsToTry) {
302
302
  const file = fileToRun.replace(/\.js$/, ext);
303
303
  if ((0, fileutils_1.fileExists)(file))
@@ -43,11 +43,13 @@ exports.createNodes = [
43
43
  !siblingFiles.includes('tsconfig.json')) {
44
44
  return {};
45
45
  }
46
- const hash = (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, pluginOptions, context, [(0, lock_file_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot))]);
47
- const targets = targetsCache[hash]
48
- ? targetsCache[hash]
46
+ const nodeHash = (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, pluginOptions, context, [(0, lock_file_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot))]);
47
+ // The hash is calculated at the node/project level, so we add the config file path to avoid conflicts when caching
48
+ const cacheKey = `${nodeHash}_${configFilePath}`;
49
+ const targets = targetsCache[cacheKey]
50
+ ? targetsCache[cacheKey]
49
51
  : buildTscTargets(fullConfigPath, projectRoot, pluginOptions, context);
50
- calculatedTargets[hash] = targets;
52
+ calculatedTargets[cacheKey] = targets;
51
53
  return {
52
54
  projects: {
53
55
  [projectRoot]: {
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CopyAssetsHandler = exports.defaultFileEventHandler = void 0;
4
4
  const minimatch_1 = require("minimatch");
5
- const path = require("path");
5
+ const path = require("node:path/posix");
6
6
  const fse = require("fs-extra");
7
7
  const ignore_1 = require("ignore");
8
8
  const fg = require("fast-glob");
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export default function (tree: Tree): Promise<void>;
@@ -1,77 +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 tsquery_1 = require("@phenomnomnominal/tsquery");
6
- async function default_1(tree) {
7
- let changesMade = false;
8
- const projects = (0, devkit_1.getProjects)(tree);
9
- (0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/js:swc', (_, projectName, target, configurationName) => {
10
- const projectConfiguration = projects.get(projectName);
11
- const executorOptions = configurationName
12
- ? projectConfiguration.targets[target].configurations[configurationName]
13
- : projectConfiguration.targets[target].options;
14
- // if the project uses a custom path to swcrc file
15
- // and only if it's the default name
16
- if (executorOptions.swcrc &&
17
- executorOptions.swcrc.includes('.lib.swcrc')) {
18
- const newSwcrc = executorOptions.swcrc.replace('.lib.swcrc', '.swcrc');
19
- // rename the swcrc file first
20
- tree.rename(executorOptions.swcrc, newSwcrc);
21
- // then update the executor options
22
- executorOptions.swcrc = newSwcrc;
23
- changesMade = true;
24
- }
25
- const libSwcrcPath = (0, devkit_1.joinPathFragments)(projectConfiguration.root, '.lib.swcrc') ||
26
- (0, devkit_1.joinPathFragments)(projectConfiguration.sourceRoot, '.lib.swcrc');
27
- const isLibSwcrcExist = tree.exists(libSwcrcPath);
28
- if (isLibSwcrcExist) {
29
- tree.rename(libSwcrcPath, libSwcrcPath.replace('.lib.swcrc', '.swcrc'));
30
- changesMade = true;
31
- }
32
- (0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfiguration);
33
- });
34
- (0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/jest:jest', (_, projectName, target, configurationName) => {
35
- const projectConfiguration = projects.get(projectName);
36
- const executorOptions = configurationName
37
- ? projectConfiguration.targets[target].configurations[configurationName]
38
- : projectConfiguration.targets[target].options;
39
- const isJestConfigExist = executorOptions.jestConfig && tree.exists(executorOptions.jestConfig);
40
- if (isJestConfigExist) {
41
- const jestConfig = tree.read(executorOptions.jestConfig, 'utf-8');
42
- const jsonParseNodes = tsquery_1.tsquery.query(jestConfig, ':matches(CallExpression:has(Identifier[name="JSON"]):has(Identifier[name="parse"]))');
43
- if (jsonParseNodes.length) {
44
- // if we already assign false to swcrc, skip
45
- if (jestConfig.includes('.swcrc = false')) {
46
- return;
47
- }
48
- let updatedJestConfig = tsquery_1.tsquery.replace(jestConfig, 'CallExpression:has(Identifier[name="JSON"]):has(Identifier[name="parse"]) TemplateSpan', (templateSpan) => {
49
- if (templateSpan.literal.text === '/.lib.swcrc') {
50
- return templateSpan
51
- .getFullText()
52
- .replace('.lib.swcrc', '.swcrc');
53
- }
54
- return '';
55
- });
56
- updatedJestConfig = tsquery_1.tsquery.replace(updatedJestConfig, ':matches(ExportAssignment, BinaryExpression:has(Identifier[name="module"]):has(Identifier[name="exports"]))', (node) => {
57
- return `
58
-
59
- // disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves.
60
- // If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude"
61
- if (swcJestConfig.swcrc === undefined) {
62
- swcJestConfig.swcrc = false;
63
- }
64
-
65
- ${node.getFullText()}
66
- `;
67
- });
68
- tree.write(executorOptions.jestConfig, updatedJestConfig);
69
- changesMade = true;
70
- }
71
- }
72
- });
73
- if (changesMade) {
74
- await (0, devkit_1.formatFiles)(tree);
75
- }
76
- }
77
- exports.default = default_1;