@nx/js 22.1.0 → 22.2.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": "22.1.0",
3
+ "version": "22.2.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": "22.1.0",
43
- "@nx/workspace": "22.1.0",
42
+ "@nx/devkit": "22.2.0-beta.0",
43
+ "@nx/workspace": "22.2.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": "^3.1.0",
@@ -60,7 +60,7 @@
60
60
  "tslib": "^2.3.0"
61
61
  },
62
62
  "devDependencies": {
63
- "nx": "22.1.0"
63
+ "nx": "22.2.0-beta.0"
64
64
  },
65
65
  "peerDependencies": {
66
66
  "verdaccio": "^6.0.5"
@@ -1 +1 @@
1
- {"version":3,"file":"copy-workspace-modules.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/executors/copy-workspace-modules/copy-workspace-modules.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EAMrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAO5D,wBAA8B,oBAAoB,CAChD,MAAM,EAAE,2BAA2B,EACnC,OAAO,EAAE,eAAe;;GASzB"}
1
+ {"version":3,"file":"copy-workspace-modules.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/executors/copy-workspace-modules/copy-workspace-modules.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EAMrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAa5D,wBAA8B,oBAAoB,CAChD,MAAM,EAAE,2BAA2B,EACnC,OAAO,EAAE,eAAe;;GASzB"}
@@ -22,19 +22,65 @@ function handleWorkspaceModules(outputDirectory, packageJson, projectGraph) {
22
22
  return;
23
23
  }
24
24
  const workspaceModules = (0, get_workspace_packages_from_graph_1.getWorkspacePackagesFromGraph)(projectGraph);
25
- for (const [pkgName] of Object.entries(packageJson.dependencies)) {
26
- if (workspaceModules.has(pkgName)) {
27
- devkit_1.logger.verbose(`Copying ${pkgName}.`);
28
- const workspaceModuleProject = workspaceModules.get(pkgName);
29
- const workspaceModuleRoot = workspaceModuleProject.data.root;
30
- const newWorkspaceModulePath = (0, path_1.join)(outputDirectory, 'workspace_modules', pkgName);
31
- (0, node_fs_1.mkdirSync)(newWorkspaceModulePath, { recursive: true });
32
- (0, node_fs_1.cpSync)(workspaceModuleRoot, newWorkspaceModulePath, {
33
- filter: (src) => !src.includes('node_modules'),
34
- recursive: true,
35
- });
36
- devkit_1.logger.verbose(`Copied ${pkgName} successfully.`);
25
+ const processedModules = new Set();
26
+ const workspaceModulesDir = (0, path_1.join)(outputDirectory, 'workspace_modules');
27
+ function calculateRelativePath(fromPkgName, toPkgName) {
28
+ const fromPath = (0, path_1.join)(workspaceModulesDir, fromPkgName);
29
+ const toPath = (0, path_1.join)(workspaceModulesDir, toPkgName);
30
+ const relativePath = (0, path_1.relative)(fromPath, toPath);
31
+ // Ensure forward slashes for file: protocol (Windows compatibility)
32
+ return relativePath.split(path_1.sep).join('/');
33
+ }
34
+ function processModule(pkgName) {
35
+ if (processedModules.has(pkgName)) {
36
+ devkit_1.logger.verbose(`Skipping ${pkgName} (already processed).`);
37
+ return;
38
+ }
39
+ if (!workspaceModules.has(pkgName)) {
40
+ return;
41
+ }
42
+ processedModules.add(pkgName);
43
+ devkit_1.logger.verbose(`Copying ${pkgName}.`);
44
+ const workspaceModuleProject = workspaceModules.get(pkgName);
45
+ const workspaceModuleRoot = workspaceModuleProject.data.root;
46
+ const newWorkspaceModulePath = (0, path_1.join)(workspaceModulesDir, pkgName);
47
+ // Copy the module
48
+ (0, node_fs_1.mkdirSync)(newWorkspaceModulePath, { recursive: true });
49
+ (0, node_fs_1.cpSync)(workspaceModuleRoot, newWorkspaceModulePath, {
50
+ filter: (src) => !src.includes('node_modules'),
51
+ recursive: true,
52
+ });
53
+ devkit_1.logger.verbose(`Copied ${pkgName} successfully.`);
54
+ // Read the copied module's package.json to process its dependencies
55
+ const copiedPackageJsonPath = (0, path_1.join)(newWorkspaceModulePath, 'package.json');
56
+ let copiedPackageJson;
57
+ try {
58
+ copiedPackageJson = JSON.parse((0, node_fs_1.readFileSync)(copiedPackageJsonPath, 'utf-8'));
37
59
  }
60
+ catch (e) {
61
+ devkit_1.logger.warn(`Could not read package.json for ${pkgName}: ${e.message}`);
62
+ return;
63
+ }
64
+ // Process and update dependencies
65
+ if (copiedPackageJson.dependencies) {
66
+ let packageJsonModified = false;
67
+ for (const [depName, depVersion] of Object.entries(copiedPackageJson.dependencies)) {
68
+ if (workspaceModules.has(depName)) {
69
+ const relativePath = calculateRelativePath(pkgName, depName);
70
+ copiedPackageJson.dependencies[depName] = `file:${relativePath}`;
71
+ packageJsonModified = true;
72
+ processModule(depName);
73
+ }
74
+ }
75
+ if (packageJsonModified) {
76
+ (0, node_fs_1.writeFileSync)(copiedPackageJsonPath, JSON.stringify(copiedPackageJson, null, 2));
77
+ devkit_1.logger.verbose(`Updated package.json for ${pkgName} with relative workspace module paths.`);
78
+ }
79
+ }
80
+ }
81
+ // Process all top-level dependencies
82
+ for (const [pkgName] of Object.entries(packageJson.dependencies)) {
83
+ processModule(pkgName);
38
84
  }
39
85
  }
40
86
  function createWorkspaceModules(outputDirectory) {
@@ -1 +1 @@
1
- {"version":3,"file":"library.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/generators/library/library.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,iBAAiB,EAUjB,IAAI,EAKL,MAAM,YAAY,CAAC;AAyCpB,OAAO,KAAK,EAEV,sBAAsB,EACtB,iCAAiC,EAClC,MAAM,UAAU,CAAC;AASlB,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,sBAAsB,8BAO/B;AAED,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,sBAAsB,8BA+K/B;AA2HD,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,iCAAiC,EAC/B,MAAM,GACN,QAAQ,GACR,aAAa,GACb,gBAAgB,GAChB,IAAI,GACJ,yBAAyB,GACzB,aAAa,GACb,SAAS,GACT,WAAW,GACX,yBAAyB,CAC5B,CAAC;AAEF,wBAAsB,OAAO,CAC3B,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,iBAAiB,CAAC,CA4G5B;AA6uBD,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"library.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/generators/library/library.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,iBAAiB,EAUjB,IAAI,EAKL,MAAM,YAAY,CAAC;AAyCpB,OAAO,KAAK,EAEV,sBAAsB,EACtB,iCAAiC,EAClC,MAAM,UAAU,CAAC;AASlB,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,sBAAsB,8BAO/B;AAED,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,sBAAsB,8BAgL/B;AA2HD,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,iCAAiC,EAC/B,MAAM,GACN,QAAQ,GACR,aAAa,GACb,gBAAgB,GAChB,IAAI,GACJ,yBAAyB,GACzB,aAAa,GACb,SAAS,GACT,WAAW,GACX,yBAAyB,CAC5B,CAAC;AAEF,wBAAsB,OAAO,CAC3B,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,iBAAiB,CAAC,CA4G5B;AA6uBD,eAAe,gBAAgB,CAAC"}
@@ -81,6 +81,7 @@ async function libraryGeneratorInternal(tree, schema) {
81
81
  includeLib: true,
82
82
  includeVitest: options.unitTestRunner === 'vitest',
83
83
  testEnvironment: options.testEnvironment,
84
+ useEsmExtension: true,
84
85
  }, false);
85
86
  }
86
87
  if (options.linter !== 'none') {