@nx/js 21.6.2 → 21.7.0-canary.20250930-e144408

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.
Files changed (28) hide show
  1. package/migrations.json +5 -0
  2. package/package.json +4 -4
  3. package/spec/src/migrations/update-22-0-0/remove-external-options-from-js-executors.spec.d.ts +2 -0
  4. package/spec/src/migrations/update-22-0-0/remove-external-options-from-js-executors.spec.d.ts.map +1 -0
  5. package/src/executors/swc/schema.json +0 -24
  6. package/src/executors/swc/swc.impl.d.ts.map +1 -1
  7. package/src/executors/swc/swc.impl.js +1 -33
  8. package/src/executors/tsc/lib/normalize-options.d.ts.map +1 -1
  9. package/src/executors/tsc/lib/normalize-options.js +0 -12
  10. package/src/executors/tsc/schema.json +0 -24
  11. package/src/executors/tsc/tsc.impl.d.ts.map +1 -1
  12. package/src/executors/tsc/tsc.impl.js +0 -6
  13. package/src/generators/library/library.d.ts.map +1 -1
  14. package/src/generators/library/library.js +1 -7
  15. package/src/generators/library/schema.d.ts +0 -1
  16. package/src/generators/library/schema.json +0 -6
  17. package/src/migrations/update-22-0-0/remove-external-options-from-js-executors.d.ts +4 -0
  18. package/src/migrations/update-22-0-0/remove-external-options-from-js-executors.d.ts.map +1 -0
  19. package/src/migrations/update-22-0-0/remove-external-options-from-js-executors.js +65 -0
  20. package/src/utils/schema.d.ts +0 -4
  21. package/src/utils/swc/compile-swc.d.ts.map +1 -1
  22. package/src/utils/swc/compile-swc.js +6 -12
  23. package/src/utils/inline.d.ts +0 -20
  24. package/src/utils/inline.d.ts.map +0 -1
  25. package/src/utils/inline.js +0 -209
  26. package/src/utils/swc/inline.d.ts +0 -3
  27. package/src/utils/swc/inline.d.ts.map +0 -1
  28. package/src/utils/swc/inline.js +0 -14
package/migrations.json CHANGED
@@ -4,6 +4,11 @@
4
4
  "version": "21.5.0-beta.2",
5
5
  "description": "Migrate the legacy 'development' custom condition to a workspace-unique custom condition name.",
6
6
  "factory": "./src/migrations/update-21-5-0/migrate-development-custom-condition"
7
+ },
8
+ "remove-external-options-from-js-executors": {
9
+ "version": "22.0.0-beta.0",
10
+ "description": "Remove the deprecated `external` and `externalBuildTargets` options from the `@nx/js:swc` and `@nx/js:tsc` executors.",
11
+ "factory": "./src/migrations/update-22-0-0/remove-external-options-from-js-executors"
7
12
  }
8
13
  },
9
14
  "packageJsonUpdates": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/js",
3
- "version": "21.6.2",
3
+ "version": "21.7.0-canary.20250930-e144408",
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": "21.6.2",
43
- "@nx/workspace": "21.6.2",
42
+ "@nx/devkit": "21.7.0-canary.20250930-e144408",
43
+ "@nx/workspace": "21.7.0-canary.20250930-e144408",
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",
@@ -63,7 +63,7 @@
63
63
  "tslib": "^2.3.0"
64
64
  },
65
65
  "devDependencies": {
66
- "nx": "21.6.2"
66
+ "nx": "21.7.0-canary.20250930-e144408"
67
67
  },
68
68
  "peerDependencies": {
69
69
  "verdaccio": "^6.0.5"
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=remove-external-options-from-js-executors.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-external-options-from-js-executors.spec.d.ts","sourceRoot":"","sources":["../../../../../../../packages/js/src/migrations/update-22-0-0/remove-external-options-from-js-executors.spec.ts"],"names":[],"mappings":""}
@@ -84,30 +84,6 @@
84
84
  ],
85
85
  "hidden": true
86
86
  },
87
- "external": {
88
- "description": "A list projects to be treated as external. This feature is experimental",
89
- "oneOf": [
90
- {
91
- "type": "string",
92
- "enum": ["all", "none"]
93
- },
94
- {
95
- "type": "array",
96
- "items": {
97
- "type": "string"
98
- }
99
- }
100
- ],
101
- "x-deprecated": "Make sure all dependencies are buildable by running `nx g @nx/js:setup-build`. This option will be removed in Nx 20."
102
- },
103
- "externalBuildTargets": {
104
- "type": "array",
105
- "items": {
106
- "type": "string"
107
- },
108
- "description": "List of target names that annotate a build target for a project",
109
- "default": ["build"]
110
- },
111
87
  "generateLockfile": {
112
88
  "type": "boolean",
113
89
  "description": "Generate a lockfile (e.g. package-lock.json) that matches the workspace lockfile to ensure package versions match.",
@@ -1 +1 @@
1
- {"version":3,"file":"swc.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/executors/swc/swc.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAwB,MAAM,YAAY,CAAC;AAsBnE,OAAO,EAEL,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AA0F5B,wBAAuB,WAAW,CAChC,QAAQ,EAAE,kBAAkB,EAC5B,OAAO,EAAE,eAAe;;;;;;aAuHzB;AAsBD,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"swc.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/executors/swc/swc.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAgB,MAAM,YAAY,CAAC;AAgB3D,OAAO,EAEL,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AA2E5B,wBAAuB,WAAW,CAChC,QAAQ,EAAE,kBAAkB,EAC5B,OAAO,EAAE,eAAe;;;;;;aAiFzB;AAsBD,eAAe,WAAW,CAAC"}
@@ -2,18 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.swcExecutor = swcExecutor;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const tinyglobby_1 = require("tinyglobby");
6
5
  const node_fs_1 = require("node:fs");
7
6
  const path_1 = require("path");
7
+ const tinyglobby_1 = require("tinyglobby");
8
8
  const assets_1 = require("../../utils/assets");
9
9
  const assets_2 = require("../../utils/assets/assets");
10
10
  const check_dependencies_1 = require("../../utils/check-dependencies");
11
11
  const compiler_helper_dependency_1 = require("../../utils/compiler-helper-dependency");
12
- const inline_1 = require("../../utils/inline");
13
12
  const package_json_1 = require("../../utils/package-json");
14
13
  const compile_swc_1 = require("../../utils/swc/compile-swc");
15
14
  const get_swcrc_path_1 = require("../../utils/swc/get-swcrc-path");
16
- const inline_2 = require("../../utils/swc/inline");
17
15
  const ts_solution_setup_1 = require("../../utils/typescript/ts-solution-setup");
18
16
  function normalizeOptions(options, root, sourceRoot, projectRoot) {
19
17
  const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)();
@@ -33,18 +31,6 @@ function normalizeOptions(options, root, sourceRoot, projectRoot) {
33
31
  if (options.watch == null) {
34
32
  options.watch = false;
35
33
  }
36
- // TODO: put back when inlining story is more stable
37
- // if (options.external == null) {
38
- // options.external = 'all';
39
- // } else if (Array.isArray(options.external) && options.external.length === 0) {
40
- // options.external = 'none';
41
- // }
42
- if (Array.isArray(options.external) && options.external.length > 0) {
43
- const firstItem = options.external[0];
44
- if (firstItem === 'all' || firstItem === 'none') {
45
- options.external = firstItem;
46
- }
47
- }
48
34
  const files = (0, assets_2.assetGlobsToFiles)(options.assets, root, outputPath);
49
35
  // Always execute from root of project, same as with SWC CLI.
50
36
  const swcCwd = (0, path_1.join)(root, projectRoot);
@@ -75,7 +61,6 @@ async function* swcExecutor(_options, context) {
75
61
  const { sourceRoot, root } = context.projectsConfigurations.projects[context.projectName];
76
62
  const options = normalizeOptions(_options, context.root, sourceRoot, root);
77
63
  let swcHelperDependency;
78
- let inlineProjectGraph;
79
64
  if (!options.isTsSolutionSetup) {
80
65
  const { tmpTsConfig, dependencies } = (0, check_dependencies_1.checkDependencies)(context, options.tsConfig);
81
66
  if (tmpTsConfig) {
@@ -85,22 +70,6 @@ async function* swcExecutor(_options, context) {
85
70
  if (swcHelperDependency) {
86
71
  dependencies.push(swcHelperDependency);
87
72
  }
88
- inlineProjectGraph = (0, inline_1.handleInliningBuild)(context, options, options.tsConfig);
89
- if (!(0, inline_1.isInlineGraphEmpty)(inlineProjectGraph)) {
90
- if (options.stripLeadingPaths) {
91
- throw new Error(`Cannot use --strip-leading-paths with inlining.`);
92
- }
93
- options.projectRoot = '.'; // set to root of workspace to include other libs for type check
94
- // remap paths for SWC compilation
95
- options.inline = true;
96
- options.swcCliOptions.swcCwd = '.';
97
- options.swcCliOptions.srcPath = options.swcCliOptions.swcCwd;
98
- options.swcCliOptions.destPath = (0, path_1.join)(options.swcCliOptions.destPath.split((0, path_1.normalize)('../')).at(-1), options.swcCliOptions.srcPath);
99
- // tmp swcrc with dependencies to exclude
100
- // - buildable libraries
101
- // - other libraries that are not dependent on the current project
102
- options.swcCliOptions.swcrcPath = (0, inline_2.generateTmpSwcrc)(inlineProjectGraph, options.swcCliOptions.swcrcPath, options.tmpSwcrcPath);
103
- }
104
73
  }
105
74
  function determineModuleFormatFromSwcrc(absolutePathToSwcrc) {
106
75
  const swcrc = (0, devkit_1.readJsonFile)(absolutePathToSwcrc);
@@ -141,7 +110,6 @@ async function* swcExecutor(_options, context) {
141
110
  ],
142
111
  extraDependencies: swcHelperDependency ? [swcHelperDependency] : [],
143
112
  }, context);
144
- (0, inline_1.postProcessInlinedDependencies)(options.outputPath, options.originalProjectRoot, inlineProjectGraph);
145
113
  }
146
114
  removeTmpSwcrc(options.swcCliOptions.swcrcPath);
147
115
  });
@@ -1 +1 @@
1
- {"version":3,"file":"normalize-options.d.ts","sourceRoot":"","sources":["../../../../../../../packages/js/src/executors/tsc/lib/normalize-options.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,yBAAyB,EAC1B,MAAM,uBAAuB,CAAC;AAM/B,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,eAAe,EACxB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAClB,yBAAyB,CA8C3B"}
1
+ {"version":3,"file":"normalize-options.d.ts","sourceRoot":"","sources":["../../../../../../../packages/js/src/executors/tsc/lib/normalize-options.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,yBAAyB,EAC1B,MAAM,uBAAuB,CAAC;AAM/B,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,eAAe,EACxB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAClB,yBAAyB,CAgC3B"}
@@ -11,18 +11,6 @@ function normalizeOptions(options, contextRoot, sourceRoot, projectRoot) {
11
11
  if (options.watch == null) {
12
12
  options.watch = false;
13
13
  }
14
- // TODO: put back when inlining story is more stable
15
- // if (options.external == null) {
16
- // options.external = 'all';
17
- // } else if (Array.isArray(options.external) && options.external.length === 0) {
18
- // options.external = 'none';
19
- // }
20
- if (Array.isArray(options.external) && options.external.length > 0) {
21
- const firstItem = options.external[0];
22
- if (firstItem === 'all' || firstItem === 'none') {
23
- options.external = firstItem;
24
- }
25
- }
26
14
  options.assets ??= [];
27
15
  const files = (0, assets_1.assetGlobsToFiles)(options.assets, contextRoot, outputPath);
28
16
  return {
@@ -77,30 +77,6 @@
77
77
  },
78
78
  "x-priority": "important"
79
79
  },
80
- "external": {
81
- "description": "A list projects to be treated as external. This feature is experimental",
82
- "oneOf": [
83
- {
84
- "type": "string",
85
- "enum": ["all", "none"]
86
- },
87
- {
88
- "type": "array",
89
- "items": {
90
- "type": "string"
91
- }
92
- }
93
- ],
94
- "x-deprecated": "Make sure all dependencies are buildable by running `nx g @nx/js:setup-build`. This option will be removed in Nx 20."
95
- },
96
- "externalBuildTargets": {
97
- "type": "array",
98
- "items": {
99
- "type": "string"
100
- },
101
- "description": "List of target names that annotate a build target for a project",
102
- "default": ["build"]
103
- },
104
80
  "generateLockfile": {
105
81
  "type": "boolean",
106
82
  "description": "Generate a lockfile (e.g. package-lock.json) that matches the workspace lockfile to ensure package versions match. Ignored when `generatePackageJson` is set to `false`.",
@@ -1 +1 @@
1
- {"version":3,"file":"tsc.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/executors/tsc/tsc.impl.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EAIhB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oDAAoD,CAAC;AAavG,OAAO,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAOhF,wBAAgB,iCAAiC,CAC/C,sBAAsB,EAAE,MAAM,GAC7B,KAAK,GAAG,KAAK,CAYf;AAED,wBAAgB,kCAAkC,CAChD,iBAAiB,EAAE,yBAAyB,EAC5C,OAAO,EAAE,eAAe,GACvB,4BAA4B,CAa9B;AAED,wBAAuB,WAAW,CAChC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,eAAe,mHAwHzB;AAED,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"tsc.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/executors/tsc/tsc.impl.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EAIhB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oDAAoD,CAAC;AAQvG,OAAO,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAOhF,wBAAgB,iCAAiC,CAC/C,sBAAsB,EAAE,MAAM,GAC7B,KAAK,GAAG,KAAK,CAYf;AAED,wBAAgB,kCAAkC,CAChD,iBAAiB,EAAE,yBAAyB,EAC5C,OAAO,EAAE,eAAe,GACvB,4BAA4B,CAa9B;AAED,wBAAuB,WAAW,CAChC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,eAAe,mHAyGzB;AAED,eAAe,WAAW,CAAC"}
@@ -8,7 +8,6 @@ const devkit_1 = require("@nx/devkit");
8
8
  const copy_assets_handler_1 = require("../../utils/assets/copy-assets-handler");
9
9
  const check_dependencies_1 = require("../../utils/check-dependencies");
10
10
  const compiler_helper_dependency_1 = require("../../utils/compiler-helper-dependency");
11
- const inline_1 = require("../../utils/inline");
12
11
  const update_package_json_1 = require("../../utils/package-json/update-package-json");
13
12
  const compile_typescript_files_1 = require("../../utils/typescript/compile-typescript-files");
14
13
  const watch_for_single_file_changes_1 = require("../../utils/watch-for-single-file-changes");
@@ -58,10 +57,6 @@ async function* tscExecutor(_options, context) {
58
57
  includeIgnoredFiles: _options.includeIgnoredAssetFiles,
59
58
  });
60
59
  const tsCompilationOptions = createTypeScriptCompilationOptions(options, context);
61
- const inlineProjectGraph = (0, inline_1.handleInliningBuild)(context, options, tsCompilationOptions.tsConfig);
62
- if (!(0, inline_1.isInlineGraphEmpty)(inlineProjectGraph)) {
63
- tsCompilationOptions.rootDir = '.';
64
- }
65
60
  const typescriptCompilation = (0, compile_typescript_files_1.compileTypeScriptFiles)(options, tsCompilationOptions, async () => {
66
61
  await assetHandler.processAllAssetsOnce();
67
62
  if (options.generatePackageJson) {
@@ -71,7 +66,6 @@ async function* tscExecutor(_options, context) {
71
66
  format: [determineModuleFormatFromTsConfig(options.tsConfig)],
72
67
  }, context, target, dependencies);
73
68
  }
74
- (0, inline_1.postProcessInlinedDependencies)(tsCompilationOptions.outputPath, tsCompilationOptions.projectRoot, inlineProjectGraph);
75
69
  });
76
70
  if (!(0, devkit_1.isDaemonEnabled)() && options.watch) {
77
71
  devkit_1.output.warn({
@@ -1 +1 @@
1
- {"version":3,"file":"library.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/generators/library/library.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,iBAAiB,EAYjB,IAAI,EAKL,MAAM,YAAY,CAAC;AA0CpB,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,8BAsL/B;AA4HD,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;AAivBD,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,EAYjB,IAAI,EAKL,MAAM,YAAY,CAAC;AA0CpB,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;AA4HD,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"}
@@ -45,10 +45,6 @@ async function libraryGeneratorInternal(tree, schema) {
45
45
  formatter: (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree) ? 'none' : 'prettier',
46
46
  }));
47
47
  const options = await normalizeOptions(tree, schema);
48
- if (schema.simpleName !== undefined && schema.simpleName !== false) {
49
- // TODO(v22): Remove simpleName as user should be using name.
50
- devkit_1.logger.warn(`The "--simpleName" option is deprecated and will be removed in Nx 22. Please use the "--name" option to provide the exact name you want for the library.`);
51
- }
52
48
  createFiles(tree, options);
53
49
  await configureProject(tree, options);
54
50
  if (!options.skipPackageJson) {
@@ -629,9 +625,7 @@ async function normalizeOptions(tree, options) {
629
625
  rootProject: options.rootProject,
630
626
  });
631
627
  options.rootProject = projectRoot === '.';
632
- const fileName = (0, devkit_1.names)(options.simpleName
633
- ? projectNames.projectSimpleName
634
- : projectNames.projectFileName).fileName;
628
+ const fileName = (0, devkit_1.names)(projectNames.projectFileName).fileName;
635
629
  const parsedTags = options.tags
636
630
  ? options.tags.split(',').map((s) => s.trim())
637
631
  : [];
@@ -30,7 +30,6 @@ export interface LibraryGeneratorSchema {
30
30
  skipTypeCheck?: boolean;
31
31
  minimal?: boolean;
32
32
  rootProject?: boolean;
33
- simpleName?: boolean;
34
33
  addPlugin?: boolean;
35
34
  useProjectJson?: boolean;
36
35
  useTscExecutor?: boolean;
@@ -127,12 +127,6 @@
127
127
  "description": "Generate a library with a minimal setup. No README.md generated.",
128
128
  "default": false
129
129
  },
130
- "simpleName": {
131
- "description": "Don't include the directory in the generated file name.",
132
- "type": "boolean",
133
- "default": false,
134
- "x-deprecated": "Use the --name option to provide the exact name instead. This option will be removed in Nx 22."
135
- },
136
130
  "useProjectJson": {
137
131
  "type": "boolean",
138
132
  "description": "Use a `project.json` configuration file instead of inlining the Nx configuration in the `package.json` file."
@@ -0,0 +1,4 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export declare const executors: string[];
3
+ export default function (tree: Tree): Promise<void>;
4
+ //# sourceMappingURL=remove-external-options-from-js-executors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-external-options-from-js-executors.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/migrations/update-22-0-0/remove-external-options-from-js-executors.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAGpB,eAAO,MAAM,SAAS,UAA+B,CAAC;AAEtD,yBAA+B,IAAI,EAAE,IAAI,iBA+ExC"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executors = void 0;
4
+ exports.default = default_1;
5
+ const devkit_1 = require("@nx/devkit");
6
+ const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
7
+ exports.executors = ['@nx/js:swc', '@nx/js:tsc'];
8
+ async function default_1(tree) {
9
+ // update options from project configs
10
+ exports.executors.forEach((executor) => {
11
+ (0, executor_options_utils_1.forEachExecutorOptions)(tree, executor, (options, project, target, configuration) => {
12
+ if (options.external === undefined &&
13
+ options.externalBuildTargets === undefined) {
14
+ return;
15
+ }
16
+ const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, project);
17
+ if (configuration) {
18
+ const config = projectConfiguration.targets[target].configurations[configuration];
19
+ delete config.external;
20
+ delete config.externalBuildTargets;
21
+ }
22
+ else {
23
+ const config = projectConfiguration.targets[target].options;
24
+ delete config.external;
25
+ delete config.externalBuildTargets;
26
+ if (!Object.keys(config).length) {
27
+ delete projectConfiguration.targets[target].options;
28
+ }
29
+ }
30
+ (0, devkit_1.updateProjectConfiguration)(tree, project, projectConfiguration);
31
+ });
32
+ });
33
+ // update options from nx.json target defaults
34
+ const nxJson = (0, devkit_1.readNxJson)(tree);
35
+ if (!nxJson.targetDefaults) {
36
+ return;
37
+ }
38
+ for (const [targetOrExecutor, targetConfig] of Object.entries(nxJson.targetDefaults)) {
39
+ if (!exports.executors.includes(targetOrExecutor) &&
40
+ !exports.executors.includes(targetConfig.executor)) {
41
+ continue;
42
+ }
43
+ if (targetConfig.options) {
44
+ delete targetConfig.options.external;
45
+ delete targetConfig.options.externalBuildTargets;
46
+ if (!Object.keys(targetConfig.options).length) {
47
+ delete targetConfig.options;
48
+ }
49
+ }
50
+ Object.entries(targetConfig.configurations ?? {}).forEach(([, config]) => {
51
+ delete config.external;
52
+ delete config.externalBuildTargets;
53
+ });
54
+ if (!Object.keys(targetConfig).length ||
55
+ (Object.keys(targetConfig).length === 1 &&
56
+ Object.keys(targetConfig)[0] === 'executor')) {
57
+ delete nxJson.targetDefaults[targetOrExecutor];
58
+ }
59
+ if (!Object.keys(nxJson.targetDefaults).length) {
60
+ delete nxJson.targetDefaults;
61
+ }
62
+ }
63
+ (0, devkit_1.updateNxJson)(tree, nxJson);
64
+ await (0, devkit_1.formatFiles)(tree);
65
+ }
@@ -15,8 +15,6 @@ export interface ExecutorOptions {
15
15
  watch: boolean;
16
16
  clean?: boolean;
17
17
  transformers: TransformerEntry[];
18
- external?: 'all' | 'none' | string[];
19
- externalBuildTargets?: string[];
20
18
  generateLockfile?: boolean;
21
19
  stripLeadingPaths?: boolean;
22
20
  generatePackageJson?: boolean;
@@ -58,6 +56,4 @@ export interface NormalizedSwcExecutorOptions
58
56
  tmpSwcrcPath: string;
59
57
  isTsSolutionSetup: boolean;
60
58
  sourceRoot?: string;
61
- // TODO(v21): remove inline feature
62
- inline?: boolean;
63
59
  }
@@ -1 +1 @@
1
- {"version":3,"file":"compile-swc.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/swc/compile-swc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,eAAe,EAAU,MAAM,YAAY,CAAC;AAK/D,OAAO,EAAE,4BAA4B,EAAiB,MAAM,WAAW,CAAC;AAwExE,wBAAsB,UAAU,CAC9B,OAAO,EAAE,eAAe,EACxB,iBAAiB,EAAE,4BAA4B,EAC/C,uBAAuB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC;;;;;;GA4C7C;AAED,wBAAuB,eAAe,CACpC,OAAO,EAAE,eAAe,EACxB,iBAAiB,EAAE,4BAA4B,EAC/C,uBAAuB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC;aAcC,OAAO;aAAW,MAAM;aA+FtE"}
1
+ {"version":3,"file":"compile-swc.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/swc/compile-swc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,eAAe,EAAU,MAAM,YAAY,CAAC;AAK/D,OAAO,EAAE,4BAA4B,EAAE,MAAM,WAAW,CAAC;AAkEzD,wBAAsB,UAAU,CAC9B,OAAO,EAAE,eAAe,EACxB,iBAAiB,EAAE,4BAA4B,EAC/C,uBAAuB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC;;;;;;GA4C7C;AAED,wBAAuB,eAAe,CACpC,OAAO,EAAE,eAAe,EACxB,iBAAiB,EAAE,4BAA4B,EAC/C,uBAAuB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC;aAcC,OAAO;aAAW,MAAM;aA+FtE"}
@@ -10,22 +10,16 @@ const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
10
10
  const print_diagnostics_1 = require("../typescript/print-diagnostics");
11
11
  const run_type_check_1 = require("../typescript/run-type-check");
12
12
  const path_1 = require("path");
13
- function getSwcCmd({ swcCliOptions: { swcrcPath, destPath, stripLeadingPaths }, root, projectRoot, originalProjectRoot, sourceRoot, inline, }, watch = false) {
13
+ function getSwcCmd({ swcCliOptions: { swcrcPath, destPath, stripLeadingPaths }, root, projectRoot, sourceRoot, }, watch = false) {
14
14
  const swcCLI = require.resolve('@swc/cli/bin/swc.js');
15
15
  let inputDir;
16
- // TODO(v22): remove inline feature
17
- if (inline) {
18
- inputDir = originalProjectRoot.split('/')[0];
16
+ if (sourceRoot) {
17
+ inputDir = (0, path_1.relative)(projectRoot, sourceRoot);
19
18
  }
20
19
  else {
21
- if (sourceRoot) {
22
- inputDir = (0, path_1.relative)(projectRoot, sourceRoot);
23
- }
24
- else {
25
- // If sourceRoot is not provided, check if `src` exists and use that instead.
26
- // This is important for root projects to avoid compiling too many directories.
27
- inputDir = (0, node_fs_1.existsSync)((0, node_path_1.join)(root, projectRoot, 'src')) ? 'src' : '.';
28
- }
20
+ // If sourceRoot is not provided, check if `src` exists and use that instead.
21
+ // This is important for root projects to avoid compiling too many directories.
22
+ inputDir = (0, node_fs_1.existsSync)((0, node_path_1.join)(root, projectRoot, 'src')) ? 'src' : '.';
29
23
  }
30
24
  let swcCmd = `node ${swcCLI} ${inputDir || '.'} -d ${destPath} --config-file=${swcrcPath} ${stripLeadingPaths ? '--strip-leading-paths' : ''}`;
31
25
  return watch ? swcCmd.concat(' --watch') : swcCmd;
@@ -1,20 +0,0 @@
1
- import type { ExecutorContext } from '@nx/devkit';
2
- import type { NormalizedExecutorOptions } from './schema';
3
- interface InlineProjectNode {
4
- name: string;
5
- root: string;
6
- sourceRoot: string;
7
- pathAlias: string;
8
- buildOutputPath?: string;
9
- }
10
- export interface InlineProjectGraph {
11
- nodes: Record<string, InlineProjectNode>;
12
- externals: Record<string, InlineProjectNode>;
13
- dependencies: Record<string, string[]>;
14
- }
15
- export declare function isInlineGraphEmpty(inlineGraph: InlineProjectGraph): boolean;
16
- export declare function handleInliningBuild(context: ExecutorContext, options: NormalizedExecutorOptions, tsConfigPath: string, projectName?: string): InlineProjectGraph;
17
- export declare function postProcessInlinedDependencies(outputPath: string, parentOutputPath: string, inlineGraph: InlineProjectGraph): void;
18
- export declare function getRootTsConfigPath(context: ExecutorContext): string | null;
19
- export {};
20
- //# sourceMappingURL=inline.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"inline.d.ts","sourceRoot":"","sources":["../../../../../packages/js/src/utils/inline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAA2B,MAAM,YAAY,CAAC;AAW3E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAG1D,UAAU,iBAAiB;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IACzC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC7C,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CACxC;AAED,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,kBAAkB,GAAG,OAAO,CAE3E;AAED,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,yBAAyB,EAClC,YAAY,EAAE,MAAM,EACpB,WAAW,GAAE,MAA4B,GACxC,kBAAkB,CAkBpB;AAED,wBAAgB,8BAA8B,CAC5C,UAAU,EAAE,MAAM,EAClB,gBAAgB,EAAE,MAAM,EACxB,WAAW,EAAE,kBAAkB,QA4ChC;AAQD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,GAAG,IAAI,CAW3E"}
@@ -1,209 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isInlineGraphEmpty = isInlineGraphEmpty;
4
- exports.handleInliningBuild = handleInliningBuild;
5
- exports.postProcessInlinedDependencies = postProcessInlinedDependencies;
6
- exports.getRootTsConfigPath = getRootTsConfigPath;
7
- const devkit_1 = require("@nx/devkit");
8
- const node_fs_1 = require("node:fs");
9
- const path_1 = require("path");
10
- const ts_solution_setup_1 = require("./typescript/ts-solution-setup");
11
- function isInlineGraphEmpty(inlineGraph) {
12
- return Object.keys(inlineGraph.nodes).length === 0;
13
- }
14
- function handleInliningBuild(context, options, tsConfigPath, projectName = context.projectName) {
15
- const tsConfigJson = (0, devkit_1.readJsonFile)(tsConfigPath);
16
- const pathAliases = tsConfigJson['compilerOptions']?.['paths'] || readBasePathAliases(context);
17
- const inlineGraph = createInlineGraph(context, options, pathAliases, projectName);
18
- if (isInlineGraphEmpty(inlineGraph)) {
19
- return inlineGraph;
20
- }
21
- buildInlineGraphExternals(context, inlineGraph, pathAliases);
22
- return inlineGraph;
23
- }
24
- function postProcessInlinedDependencies(outputPath, parentOutputPath, inlineGraph) {
25
- if (isInlineGraphEmpty(inlineGraph)) {
26
- return;
27
- }
28
- const parentDistPath = (0, path_1.join)(outputPath, parentOutputPath);
29
- const markedForDeletion = new Set();
30
- // move parentOutput
31
- movePackage(parentDistPath, outputPath);
32
- markedForDeletion.add(parentDistPath);
33
- const inlinedDepsDestOutputRecord = {};
34
- // move inlined outputs
35
- for (const inlineDependenciesNames of Object.values(inlineGraph.dependencies)) {
36
- for (const inlineDependenciesName of inlineDependenciesNames) {
37
- const inlineDependency = inlineGraph.nodes[inlineDependenciesName];
38
- const depOutputPath = inlineDependency.buildOutputPath ||
39
- (0, path_1.join)(outputPath, inlineDependency.root);
40
- const destDepOutputPath = (0, path_1.join)(outputPath, inlineDependency.name);
41
- const isBuildable = !!inlineDependency.buildOutputPath;
42
- if (isBuildable) {
43
- (0, node_fs_1.cpSync)(depOutputPath, destDepOutputPath, { recursive: true });
44
- }
45
- else {
46
- movePackage(depOutputPath, destDepOutputPath);
47
- markedForDeletion.add(depOutputPath);
48
- }
49
- // TODO: hard-coded "src"
50
- inlinedDepsDestOutputRecord[inlineDependency.pathAlias] =
51
- destDepOutputPath + '/src';
52
- }
53
- }
54
- markedForDeletion.forEach((path) => (0, node_fs_1.rmSync)(path, { recursive: true, force: true }));
55
- updateImports(outputPath, inlinedDepsDestOutputRecord);
56
- }
57
- function readBasePathAliases(context) {
58
- return (0, devkit_1.readJsonFile)(getRootTsConfigPath(context))?.['compilerOptions']['paths'];
59
- }
60
- function getRootTsConfigPath(context) {
61
- for (const tsConfigName of ['tsconfig.base.json', 'tsconfig.json']) {
62
- const tsConfigPath = (0, path_1.join)(context.root, tsConfigName);
63
- if ((0, node_fs_1.existsSync)(tsConfigPath)) {
64
- return tsConfigPath;
65
- }
66
- }
67
- throw new Error('Could not find a root tsconfig.json or tsconfig.base.json file.');
68
- }
69
- function emptyInlineGraph() {
70
- return { nodes: {}, externals: {}, dependencies: {} };
71
- }
72
- function projectNodeToInlineProjectNode(projectNode, pathAlias = '', buildOutputPath = '') {
73
- return {
74
- name: projectNode.name,
75
- root: projectNode.data.root,
76
- sourceRoot: (0, ts_solution_setup_1.getProjectSourceRoot)(projectNode.data),
77
- pathAlias,
78
- buildOutputPath,
79
- };
80
- }
81
- function createInlineGraph(context, options, pathAliases, projectName, inlineGraph = emptyInlineGraph()) {
82
- if (options.external == null)
83
- return inlineGraph;
84
- const projectDependencies = context.projectGraph.dependencies[projectName] || [];
85
- if (projectDependencies.length === 0)
86
- return inlineGraph;
87
- if (!inlineGraph.nodes[projectName]) {
88
- inlineGraph.nodes[projectName] = projectNodeToInlineProjectNode(context.projectGraph.nodes[projectName]);
89
- }
90
- const implicitDependencies = context.projectGraph.nodes[projectName].data.implicitDependencies || [];
91
- for (const projectDependency of projectDependencies) {
92
- // skip npm packages
93
- if (projectDependency.target.startsWith('npm')) {
94
- continue;
95
- }
96
- // skip implicitDependencies
97
- if (implicitDependencies.includes(projectDependency.target)) {
98
- continue;
99
- }
100
- const pathAlias = getPathAliasForPackage(context.projectGraph.nodes[projectDependency.target], pathAliases);
101
- const buildOutputPath = getBuildOutputPath(projectDependency.target, context, options);
102
- const shouldInline =
103
- /**
104
- * if all buildable libraries are marked as external,
105
- * then push the project dependency that doesn't have a build target
106
- */
107
- (options.external === 'all' && !buildOutputPath) ||
108
- /**
109
- * if all buildable libraries are marked as internal,
110
- * then push every project dependency to be inlined
111
- */
112
- options.external === 'none' ||
113
- /**
114
- * if some buildable libraries are marked as external,
115
- * then push the project dependency that IS NOT marked as external OR doesn't have a build target
116
- */
117
- (Array.isArray(options.external) &&
118
- options.external.length > 0 &&
119
- !options.external.includes(projectDependency.target)) ||
120
- !buildOutputPath;
121
- if (shouldInline) {
122
- inlineGraph.dependencies[projectName] ??= [];
123
- inlineGraph.dependencies[projectName].push(projectDependency.target);
124
- }
125
- inlineGraph.nodes[projectDependency.target] =
126
- projectNodeToInlineProjectNode(context.projectGraph.nodes[projectDependency.target], pathAlias, buildOutputPath);
127
- if (context.projectGraph.dependencies[projectDependency.target].length > 0) {
128
- inlineGraph = createInlineGraph(context, options, pathAliases, projectDependency.target, inlineGraph);
129
- }
130
- }
131
- return inlineGraph;
132
- }
133
- function buildInlineGraphExternals(context, inlineProjectGraph, pathAliases) {
134
- const allNodes = { ...context.projectGraph.nodes };
135
- for (const [parent, dependencies] of Object.entries(inlineProjectGraph.dependencies)) {
136
- if (allNodes[parent]) {
137
- delete allNodes[parent];
138
- }
139
- for (const dependencyName of dependencies) {
140
- const dependencyNode = inlineProjectGraph.nodes[dependencyName];
141
- // buildable is still external even if it is a dependency
142
- if (dependencyNode.buildOutputPath) {
143
- continue;
144
- }
145
- if (allNodes[dependencyName]) {
146
- delete allNodes[dependencyName];
147
- }
148
- }
149
- }
150
- for (const [projectName, projectNode] of Object.entries(allNodes)) {
151
- if (!inlineProjectGraph.externals[projectName]) {
152
- inlineProjectGraph.externals[projectName] =
153
- projectNodeToInlineProjectNode(projectNode, getPathAliasForPackage(projectNode, pathAliases));
154
- }
155
- }
156
- }
157
- function movePackage(from, to) {
158
- if (from === to)
159
- return;
160
- (0, node_fs_1.cpSync)(from, to, { recursive: true });
161
- }
162
- function updateImports(destOutputPath, inlinedDepsDestOutputRecord) {
163
- const pathAliases = Object.keys(inlinedDepsDestOutputRecord);
164
- if (pathAliases.length == 0) {
165
- return;
166
- }
167
- const importRegex = new RegExp(pathAliases.map((pathAlias) => `["'](${pathAlias})["']`).join('|'), 'g');
168
- recursiveUpdateImport(destOutputPath, importRegex, inlinedDepsDestOutputRecord);
169
- }
170
- function recursiveUpdateImport(dirPath, importRegex, inlinedDepsDestOutputRecord, rootParentDir) {
171
- const files = (0, node_fs_1.readdirSync)(dirPath, { withFileTypes: true });
172
- for (const file of files) {
173
- // only check .js and .d.ts files
174
- if (file.isFile() &&
175
- (file.name.endsWith('.js') || file.name.endsWith('.d.ts'))) {
176
- const filePath = (0, path_1.join)(dirPath, file.name);
177
- const fileContent = (0, node_fs_1.readFileSync)(filePath, 'utf-8');
178
- const updatedContent = fileContent.replace(importRegex, (matched) => {
179
- const result = matched.replace(/['"]/g, '');
180
- // If a match is the same as the rootParentDir, we're checking its own files so we return the matched as in no changes.
181
- if (result === rootParentDir || !inlinedDepsDestOutputRecord[result])
182
- return matched;
183
- const importPath = `"${(0, path_1.relative)(dirPath, inlinedDepsDestOutputRecord[result])}"`;
184
- return (0, devkit_1.normalizePath)(importPath);
185
- });
186
- (0, node_fs_1.writeFileSync)(filePath, updatedContent);
187
- }
188
- else if (file.isDirectory()) {
189
- recursiveUpdateImport((0, path_1.join)(dirPath, file.name), importRegex, inlinedDepsDestOutputRecord, rootParentDir || file.name);
190
- }
191
- }
192
- }
193
- function getPathAliasForPackage(packageNode, pathAliases) {
194
- if (!packageNode)
195
- return '';
196
- for (const [alias, paths] of Object.entries(pathAliases)) {
197
- if (paths.some((path) => path.includes(packageNode.data.root))) {
198
- return alias;
199
- }
200
- }
201
- return '';
202
- }
203
- function getBuildOutputPath(projectName, context, options) {
204
- const projectTargets = context.projectGraph.nodes[projectName]?.data?.targets;
205
- if (!projectTargets)
206
- return '';
207
- const buildTarget = options.externalBuildTargets.find((buildTarget) => projectTargets[buildTarget]);
208
- return buildTarget ? projectTargets[buildTarget].options['outputPath'] : '';
209
- }
@@ -1,3 +0,0 @@
1
- import type { InlineProjectGraph } from '../inline';
2
- export declare function generateTmpSwcrc(inlineProjectGraph: InlineProjectGraph, swcrcPath: string, tmpSwcrcPath: string): string;
3
- //# sourceMappingURL=inline.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"inline.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/swc/inline.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAEpD,wBAAgB,gBAAgB,CAC9B,kBAAkB,EAAE,kBAAkB,EACtC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,UAmBrB"}
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateTmpSwcrc = generateTmpSwcrc;
4
- const devkit_1 = require("@nx/devkit");
5
- function generateTmpSwcrc(inlineProjectGraph, swcrcPath, tmpSwcrcPath) {
6
- const swcrc = (0, devkit_1.readJsonFile)(swcrcPath);
7
- swcrc['exclude'] ??= [];
8
- if (!Array.isArray(swcrc['exclude'])) {
9
- swcrc['exclude'] = [swcrc['exclude']];
10
- }
11
- swcrc['exclude'] = swcrc['exclude'].concat(Object.values(inlineProjectGraph.externals).map((external) => `${external.root}/**/.*.ts$`), 'node_modules/**/*.ts$');
12
- (0, devkit_1.writeJsonFile)(tmpSwcrcPath, swcrc);
13
- return tmpSwcrcPath;
14
- }