@nx/js 16.4.0-beta.0 → 16.4.0-beta.10

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 (171) hide show
  1. package/babel.js +0 -1
  2. package/executors.json +1 -0
  3. package/generators.json +12 -0
  4. package/package.json +6 -5
  5. package/plugins/jest/local-registry.d.ts +1 -0
  6. package/plugins/jest/local-registry.js +4 -0
  7. package/src/executors/node/compat.js +0 -1
  8. package/src/executors/node/lib/kill-tree.js +0 -1
  9. package/src/executors/node/node-with-require-overrides.js +0 -1
  10. package/src/executors/node/node.impl.js +64 -13
  11. package/src/executors/swc/compat.js +0 -1
  12. package/src/executors/swc/swc.impl.js +0 -1
  13. package/src/executors/tsc/compat.js +0 -1
  14. package/src/executors/tsc/lib/batch/build-task-info-per-tsconfig-map.d.ts +4 -0
  15. package/src/executors/tsc/lib/batch/build-task-info-per-tsconfig-map.js +54 -0
  16. package/src/executors/tsc/lib/batch/generate-temp-tsconfig.d.ts +3 -0
  17. package/src/executors/tsc/lib/batch/generate-temp-tsconfig.js +52 -0
  18. package/src/executors/tsc/lib/batch/get-task-options.d.ts +3 -0
  19. package/src/executors/tsc/lib/batch/get-task-options.js +24 -0
  20. package/src/executors/tsc/lib/batch/index.d.ts +8 -0
  21. package/src/executors/tsc/lib/batch/index.js +11 -0
  22. package/src/executors/tsc/lib/batch/normalize-tasks-options.d.ts +3 -0
  23. package/src/executors/tsc/lib/batch/normalize-tasks-options.js +14 -0
  24. package/src/executors/tsc/lib/batch/types.d.ts +12 -0
  25. package/src/executors/tsc/lib/batch/types.js +2 -0
  26. package/src/executors/tsc/lib/batch/typescript-compilation.d.ts +7 -0
  27. package/src/executors/tsc/lib/batch/typescript-compilation.js +195 -0
  28. package/src/executors/tsc/lib/batch/typescript-diagnostic-reporters.d.ts +4 -0
  29. package/src/executors/tsc/lib/batch/typescript-diagnostic-reporters.js +44 -0
  30. package/src/executors/tsc/lib/batch/watch.d.ts +3 -0
  31. package/src/executors/tsc/lib/batch/watch.js +63 -0
  32. package/src/executors/tsc/lib/get-custom-transformers-factory.d.ts +3 -0
  33. package/src/executors/tsc/lib/get-custom-transformers-factory.js +13 -0
  34. package/src/executors/tsc/lib/index.d.ts +2 -0
  35. package/src/executors/tsc/lib/index.js +5 -0
  36. package/src/executors/tsc/lib/normalize-options.d.ts +2 -0
  37. package/src/executors/tsc/lib/normalize-options.js +32 -0
  38. package/src/executors/tsc/tsc.batch-impl.d.ts +4 -0
  39. package/src/executors/tsc/tsc.batch-impl.js +47 -0
  40. package/src/executors/tsc/tsc.impl.d.ts +0 -1
  41. package/src/executors/tsc/tsc.impl.js +4 -40
  42. package/src/executors/verdaccio/compat.js +0 -1
  43. package/src/executors/verdaccio/verdaccio.impl.d.ts +1 -0
  44. package/src/executors/verdaccio/verdaccio.impl.js +25 -23
  45. package/src/generators/convert-to-swc/convert-to-swc.js +0 -1
  46. package/src/generators/init/init.js +0 -1
  47. package/src/generators/library/library.js +2 -11
  48. package/src/generators/library/schema.json +7 -6
  49. package/src/generators/setup-build/generator.d.ts +5 -0
  50. package/src/generators/setup-build/generator.js +133 -0
  51. package/src/generators/setup-build/schema.d.ts +7 -0
  52. package/src/generators/setup-build/schema.json +42 -0
  53. package/src/generators/setup-verdaccio/files/config.yml +1 -1
  54. package/src/generators/setup-verdaccio/generator.js +5 -2
  55. package/src/index.d.ts +1 -0
  56. package/src/index.js +1 -1
  57. package/src/internal.js +0 -1
  58. package/src/migrations/update-13-10-1/update-lib-swcrc-exclude.js +0 -1
  59. package/src/migrations/update-13-8-5/update-node-executor.js +0 -1
  60. package/src/migrations/update-13-8-5/update-swcrc.js +0 -1
  61. package/src/migrations/update-14-0-0/exclude-jest-config-swcrc.js +0 -1
  62. package/src/migrations/update-14-1-5/update-swcrc-path.js +0 -1
  63. package/src/migrations/update-15-8-0/rename-swcrc-config.js +0 -1
  64. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +0 -1
  65. package/src/plugins/jest/start-local-registry.d.ts +12 -0
  66. package/src/plugins/jest/start-local-registry.js +61 -0
  67. package/src/utils/add-babel-inputs.d.ts +1 -0
  68. package/src/utils/add-babel-inputs.js +2 -1
  69. package/src/utils/add-local-registry-scripts.d.ts +5 -0
  70. package/src/utils/add-local-registry-scripts.js +57 -0
  71. package/src/utils/assets/assets.js +0 -1
  72. package/src/utils/assets/copy-assets-handler.d.ts +5 -1
  73. package/src/utils/assets/copy-assets-handler.js +34 -24
  74. package/src/utils/assets/index.js +0 -1
  75. package/src/utils/buildable-libs-utils.js +0 -1
  76. package/src/utils/check-dependencies.js +0 -1
  77. package/src/utils/code-frames/highlight.js +0 -1
  78. package/src/utils/code-frames/identifiers.js +0 -1
  79. package/src/utils/compiler-helper-dependency.js +0 -1
  80. package/src/utils/generate-globs.js +0 -1
  81. package/src/utils/get-import-path.js +0 -1
  82. package/src/utils/inline.d.ts +1 -1
  83. package/src/utils/inline.js +3 -4
  84. package/src/utils/minimal-publish-script.js +2 -6
  85. package/src/utils/package-json/get-npm-scope.js +0 -1
  86. package/src/utils/package-json/index.js +0 -1
  87. package/src/utils/package-json/update-package-json.js +0 -1
  88. package/src/utils/prettier.js +0 -1
  89. package/src/utils/schema.d.ts +3 -2
  90. package/src/utils/swc/add-swc-config.d.ts +1 -1
  91. package/src/utils/swc/add-swc-config.js +0 -1
  92. package/src/utils/swc/add-swc-dependencies.js +0 -1
  93. package/src/utils/swc/compile-swc.js +0 -1
  94. package/src/utils/swc/get-swcrc-path.js +0 -1
  95. package/src/utils/swc/inline.js +0 -1
  96. package/src/utils/typescript/__mocks__/plugin-a.js +0 -1
  97. package/src/utils/typescript/__mocks__/plugin-b.js +0 -1
  98. package/src/utils/typescript/add-tslib-dependencies.js +0 -1
  99. package/src/utils/typescript/ast-utils.js +0 -1
  100. package/src/utils/typescript/compile-typescript-files.js +0 -1
  101. package/src/utils/typescript/create-ts-config.js +0 -1
  102. package/src/utils/typescript/ensure-typescript.js +0 -1
  103. package/src/utils/typescript/get-source-nodes.js +0 -1
  104. package/src/utils/typescript/load-ts-transformers.js +0 -1
  105. package/src/utils/typescript/print-diagnostics.js +0 -1
  106. package/src/utils/typescript/run-type-check.js +0 -1
  107. package/src/utils/typescript/ts-config.js +0 -1
  108. package/src/utils/typescript/types.js +0 -1
  109. package/src/utils/versions.js +0 -1
  110. package/src/utils/watch-for-single-file-changes.js +0 -1
  111. package/babel.js.map +0 -1
  112. package/src/executors/node/compat.js.map +0 -1
  113. package/src/executors/node/lib/kill-tree.js.map +0 -1
  114. package/src/executors/node/node-with-require-overrides.js.map +0 -1
  115. package/src/executors/node/node.impl.js.map +0 -1
  116. package/src/executors/swc/compat.js.map +0 -1
  117. package/src/executors/swc/swc.impl.js.map +0 -1
  118. package/src/executors/tsc/compat.js.map +0 -1
  119. package/src/executors/tsc/tsc.impl.js.map +0 -1
  120. package/src/executors/verdaccio/compat.js.map +0 -1
  121. package/src/executors/verdaccio/verdaccio.impl.js.map +0 -1
  122. package/src/generators/convert-to-swc/convert-to-swc.js.map +0 -1
  123. package/src/generators/init/init.js.map +0 -1
  124. package/src/generators/library/library.js.map +0 -1
  125. package/src/generators/setup-verdaccio/generator.js.map +0 -1
  126. package/src/index.js.map +0 -1
  127. package/src/internal.js.map +0 -1
  128. package/src/migrations/update-13-10-1/update-lib-swcrc-exclude.js.map +0 -1
  129. package/src/migrations/update-13-8-5/update-node-executor.js.map +0 -1
  130. package/src/migrations/update-13-8-5/update-swcrc.js.map +0 -1
  131. package/src/migrations/update-14-0-0/exclude-jest-config-swcrc.js.map +0 -1
  132. package/src/migrations/update-14-1-5/update-swcrc-path.js.map +0 -1
  133. package/src/migrations/update-15-8-0/rename-swcrc-config.js.map +0 -1
  134. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js.map +0 -1
  135. package/src/utils/add-babel-inputs.js.map +0 -1
  136. package/src/utils/assets/assets.js.map +0 -1
  137. package/src/utils/assets/copy-assets-handler.js.map +0 -1
  138. package/src/utils/assets/index.js.map +0 -1
  139. package/src/utils/buildable-libs-utils.js.map +0 -1
  140. package/src/utils/check-dependencies.js.map +0 -1
  141. package/src/utils/code-frames/highlight.js.map +0 -1
  142. package/src/utils/code-frames/identifiers.js.map +0 -1
  143. package/src/utils/compiler-helper-dependency.js.map +0 -1
  144. package/src/utils/generate-globs.js.map +0 -1
  145. package/src/utils/get-import-path.js.map +0 -1
  146. package/src/utils/inline.js.map +0 -1
  147. package/src/utils/minimal-publish-script.js.map +0 -1
  148. package/src/utils/package-json/get-npm-scope.js.map +0 -1
  149. package/src/utils/package-json/index.js.map +0 -1
  150. package/src/utils/package-json/update-package-json.js.map +0 -1
  151. package/src/utils/prettier.js.map +0 -1
  152. package/src/utils/swc/add-swc-config.js.map +0 -1
  153. package/src/utils/swc/add-swc-dependencies.js.map +0 -1
  154. package/src/utils/swc/compile-swc.js.map +0 -1
  155. package/src/utils/swc/get-swcrc-path.js.map +0 -1
  156. package/src/utils/swc/inline.js.map +0 -1
  157. package/src/utils/typescript/__mocks__/plugin-a.js.map +0 -1
  158. package/src/utils/typescript/__mocks__/plugin-b.js.map +0 -1
  159. package/src/utils/typescript/add-tslib-dependencies.js.map +0 -1
  160. package/src/utils/typescript/ast-utils.js.map +0 -1
  161. package/src/utils/typescript/compile-typescript-files.js.map +0 -1
  162. package/src/utils/typescript/create-ts-config.js.map +0 -1
  163. package/src/utils/typescript/ensure-typescript.js.map +0 -1
  164. package/src/utils/typescript/get-source-nodes.js.map +0 -1
  165. package/src/utils/typescript/load-ts-transformers.js.map +0 -1
  166. package/src/utils/typescript/print-diagnostics.js.map +0 -1
  167. package/src/utils/typescript/run-type-check.js.map +0 -1
  168. package/src/utils/typescript/ts-config.js.map +0 -1
  169. package/src/utils/typescript/types.js.map +0 -1
  170. package/src/utils/versions.js.map +0 -1
  171. package/src/utils/watch-for-single-file-changes.js.map +0 -1
package/babel.js CHANGED
@@ -86,4 +86,3 @@ module.exports = function (api, options = {}) {
86
86
  ],
87
87
  };
88
88
  };
89
- //# sourceMappingURL=babel.js.map
package/executors.json CHANGED
@@ -3,6 +3,7 @@
3
3
  "executors": {
4
4
  "tsc": {
5
5
  "implementation": "./src/executors/tsc/tsc.impl",
6
+ "batchImplementation": "./src/executors/tsc/tsc.batch-impl",
6
7
  "schema": "./src/executors/tsc/schema.json",
7
8
  "description": "Build a project using TypeScript."
8
9
  },
package/generators.json CHANGED
@@ -29,6 +29,12 @@
29
29
  "schema": "./src/generators/setup-verdaccio/schema.json",
30
30
  "alias": ["verdaccio"],
31
31
  "description": "Setup Verdaccio for local package management."
32
+ },
33
+ "setup-build": {
34
+ "factory": "./src/generators/setup-build/generator#setupBuildSchematic",
35
+ "schema": "./src/generators/setup-build/schema.json",
36
+ "alias": ["build"],
37
+ "description": "setup-build generator"
32
38
  }
33
39
  },
34
40
  "generators": {
@@ -59,6 +65,12 @@
59
65
  "schema": "./src/generators/setup-verdaccio/schema.json",
60
66
  "alias": ["verdaccio"],
61
67
  "description": "Setup Verdaccio for local package management."
68
+ },
69
+ "setup-build": {
70
+ "factory": "./src/generators/setup-build/generator",
71
+ "schema": "./src/generators/setup-build/schema.json",
72
+ "alias": ["build"],
73
+ "description": "setup-build generator"
62
74
  }
63
75
  }
64
76
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/js",
3
- "version": "16.4.0-beta.0",
3
+ "version": "16.4.0-beta.10",
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,14 +39,15 @@
39
39
  "@babel/preset-env": "^7.15.0",
40
40
  "@babel/preset-typescript": "^7.15.0",
41
41
  "@babel/runtime": "^7.14.8",
42
- "@nrwl/js": "16.4.0-beta.0",
43
- "@nx/devkit": "16.4.0-beta.0",
44
- "@nx/workspace": "16.4.0-beta.0",
42
+ "@nrwl/js": "16.4.0-beta.10",
43
+ "@nx/devkit": "16.4.0-beta.10",
44
+ "@nx/workspace": "16.4.0-beta.10",
45
45
  "@phenomnomnominal/tsquery": "~5.0.1",
46
46
  "babel-plugin-const-enum": "^1.0.1",
47
47
  "babel-plugin-macros": "^2.8.0",
48
48
  "babel-plugin-transform-typescript-metadata": "^0.3.1",
49
49
  "chalk": "^4.1.0",
50
+ "detect-port": "^1.5.1",
50
51
  "fast-glob": "3.2.7",
51
52
  "fs-extra": "^11.1.0",
52
53
  "ignore": "^5.0.4",
@@ -68,5 +69,5 @@
68
69
  "access": "public"
69
70
  },
70
71
  "types": "./src/index.d.ts",
71
- "gitHead": "c2112a07278e9c78cd6f6c194eb4a75115a7d179"
72
+ "gitHead": "d2bde0605c692a023bc9c28686f3a3037bbd56d3"
72
73
  }
@@ -0,0 +1 @@
1
+ export * from '../../src/plugins/jest/start-local-registry';
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("../../src/plugins/jest/start-local-registry"), exports);
@@ -3,4 +3,3 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const devkit_1 = require("@nx/devkit");
4
4
  const node_impl_1 = require("./node.impl");
5
5
  exports.default = (0, devkit_1.convertNxExecutor)(node_impl_1.default);
6
- //# sourceMappingURL=compat.js.map
@@ -111,4 +111,3 @@ function buildProcessTree(parentPid, tree, pidsToProcess, spawnChildProcessesLis
111
111
  };
112
112
  ps.on('close', onClose);
113
113
  }
114
- //# sourceMappingURL=kill-tree.js.map
@@ -19,4 +19,3 @@ Module._load = function (request, parent) {
19
19
  }
20
20
  };
21
21
  dynamicImport(fileToRun);
22
- //# sourceMappingURL=node-with-require-overrides.js.map
@@ -8,9 +8,11 @@ const devkit_1 = require("@nx/devkit");
8
8
  const client_1 = require("nx/src/daemon/client/client");
9
9
  const crypto_1 = require("crypto");
10
10
  const path_1 = require("path");
11
+ const path = require("path");
11
12
  const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
12
13
  const buildable_libs_utils_1 = require("../../utils/buildable-libs-utils");
13
14
  const kill_tree_1 = require("./lib/kill-tree");
15
+ const fileutils_1 = require("nx/src/utils/fileutils");
14
16
  function debounce(fn, wait) {
15
17
  let timeoutId;
16
18
  return () => {
@@ -19,21 +21,35 @@ function debounce(fn, wait) {
19
21
  };
20
22
  }
21
23
  function nodeExecutor(options, context) {
22
- var _a, _b;
24
+ var _a, _b, _c, _d;
25
+ var _e;
23
26
  return tslib_1.__asyncGenerator(this, arguments, function* nodeExecutor_1() {
27
+ (_a = (_e = process.env).NODE_ENV) !== null && _a !== void 0 ? _a : (_e.NODE_ENV = (_b = context === null || context === void 0 ? void 0 : context.configurationName) !== null && _b !== void 0 ? _b : 'development');
24
28
  const project = context.projectGraph.nodes[context.projectName];
25
29
  const buildTarget = (0, devkit_1.parseTargetString)(options.buildTarget, context.projectGraph);
26
- const buildOptions = (_a = project.data.targets[buildTarget.target]) === null || _a === void 0 ? void 0 : _a.options;
27
- if (!buildOptions) {
30
+ let buildOptions;
31
+ if (project.data.targets[buildTarget.target]) {
32
+ buildOptions = Object.assign(Object.assign({}, (_c = project.data.targets[buildTarget.target]) === null || _c === void 0 ? void 0 : _c.options), options.buildTargetOptions);
33
+ }
34
+ else {
28
35
  throw new Error(`Cannot find build target ${chalk.bold(options.buildTarget)} for project ${chalk.bold(context.projectName)}`);
29
36
  }
37
+ if (options.waitUntilTargets && options.waitUntilTargets.length > 0) {
38
+ const results = yield tslib_1.__await(runWaitUntilTargets(options, context));
39
+ for (const [i, result] of results.entries()) {
40
+ if (!result.success) {
41
+ throw new Error(`Wait until target failed: ${options.waitUntilTargets[i]}.`);
42
+ }
43
+ }
44
+ }
30
45
  // Re-map buildable workspace projects to their output directory.
31
46
  const mappings = calculateResolveMappings(context, options);
32
- const fileToRun = (0, path_1.join)(context.root, buildOptions.outputPath, (_b = buildOptions.outputFileName) !== null && _b !== void 0 ? _b : 'main.js');
47
+ const outputFileName = (_d = buildOptions.outputFileName) !== null && _d !== void 0 ? _d : `${path.parse(buildOptions.main).name}.js`;
48
+ const fileToRun = (0, path_1.join)(context.root, buildOptions.outputPath, outputFileName);
33
49
  const tasks = [];
34
50
  let currentTask = null;
35
51
  yield tslib_1.__await(yield* tslib_1.__asyncDelegator(tslib_1.__asyncValues((0, async_iterable_1.createAsyncIterable)(({ done, next, error }) => tslib_1.__awaiter(this, void 0, void 0, function* () {
36
- var _c;
52
+ var _f;
37
53
  const processQueue = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
38
54
  if (tasks.length === 0)
39
55
  return;
@@ -43,7 +59,7 @@ function nodeExecutor(options, context) {
43
59
  yield (previousTask === null || previousTask === void 0 ? void 0 : previousTask.stop('SIGTERM'));
44
60
  yield task.start();
45
61
  });
46
- const debouncedProcessQueue = debounce(processQueue, (_c = options.debounce) !== null && _c !== void 0 ? _c : 1000);
62
+ const debouncedProcessQueue = debounce(processQueue, (_f = options.debounce) !== null && _f !== void 0 ? _f : 1000);
47
63
  const addToQueue = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
48
64
  const task = {
49
65
  id: (0, crypto_1.randomUUID)(),
@@ -88,15 +104,16 @@ function nodeExecutor(options, context) {
88
104
  // Run the program
89
105
  task.promise = new Promise((resolve, reject) => {
90
106
  var _a;
91
- task.childProcess = (0, child_process_1.fork)((0, devkit_1.joinPathFragments)(__dirname, 'node-with-require-overrides'), (_a = options.runtimeArgs) !== null && _a !== void 0 ? _a : [], {
107
+ task.childProcess = (0, child_process_1.fork)((0, devkit_1.joinPathFragments)(__dirname, 'node-with-require-overrides'), (_a = options.args) !== null && _a !== void 0 ? _a : [], {
92
108
  execArgv: getExecArgv(options),
93
109
  stdio: [0, 1, 'pipe', 'ipc'],
94
- env: Object.assign(Object.assign({}, process.env), { NX_FILE_TO_RUN: fileToRun, NX_MAPPINGS: JSON.stringify(mappings) }),
110
+ env: Object.assign(Object.assign({}, process.env), { NX_FILE_TO_RUN: fileToRunCorrectPath(fileToRun), NX_MAPPINGS: JSON.stringify(mappings) }),
95
111
  });
96
112
  task.childProcess.stderr.on('data', (data) => {
97
113
  // Don't log out error if task is killed and new one has started.
98
114
  // This could happen if a new build is triggered while new process is starting, since the operation is not atomic.
99
- if (options.watch && !task.killed) {
115
+ // Log the error in normal mode
116
+ if (!options.watch || !task.killed) {
100
117
  devkit_1.logger.error(data.toString());
101
118
  }
102
119
  });
@@ -128,13 +145,13 @@ function nodeExecutor(options, context) {
128
145
  watchProjects: [context.projectName],
129
146
  includeDependentProjects: true,
130
147
  }, (err, data) => tslib_1.__awaiter(this, void 0, void 0, function* () {
131
- var _d;
148
+ var _g;
132
149
  if (err === 'closed') {
133
150
  devkit_1.logger.error(`Watch error: Daemon closed the connection`);
134
151
  process.exit(1);
135
152
  }
136
153
  else if (err) {
137
- devkit_1.logger.error(`Watch error: ${(_d = err === null || err === void 0 ? void 0 : err.message) !== null && _d !== void 0 ? _d : 'Unknown'}`);
154
+ devkit_1.logger.error(`Watch error: ${(_g = err === null || err === void 0 ? void 0 : err.message) !== null && _g !== void 0 ? _g : 'Unknown'}`);
138
155
  }
139
156
  else {
140
157
  devkit_1.logger.info(`NX File change detected. Restarting...`);
@@ -169,7 +186,9 @@ function nodeExecutor(options, context) {
169
186
  }
170
187
  exports.nodeExecutor = nodeExecutor;
171
188
  function getExecArgv(options) {
172
- const args = ['-r', require.resolve('source-map-support/register')];
189
+ var _a;
190
+ const args = ((_a = options.runtimeArgs) !== null && _a !== void 0 ? _a : (options.runtimeArgs = []));
191
+ args.push('-r', require.resolve('source-map-support/register'));
173
192
  if (options.inspect === true) {
174
193
  options.inspect = "inspect" /* InspectType.Inspect */;
175
194
  }
@@ -188,5 +207,37 @@ function calculateResolveMappings(context, options) {
188
207
  return m;
189
208
  }, {});
190
209
  }
210
+ function runWaitUntilTargets(options, context) {
211
+ return Promise.all(options.waitUntilTargets.map((waitUntilTarget) => tslib_1.__awaiter(this, void 0, void 0, function* () {
212
+ const target = (0, devkit_1.parseTargetString)(waitUntilTarget, context.projectGraph);
213
+ const output = yield (0, devkit_1.runExecutor)(target, {}, context);
214
+ return new Promise((resolve) => tslib_1.__awaiter(this, void 0, void 0, function* () {
215
+ let event = yield output.next();
216
+ // Resolve after first event
217
+ resolve(event.value);
218
+ // Continue iterating
219
+ while (!event.done) {
220
+ event = yield output.next();
221
+ }
222
+ }));
223
+ })));
224
+ }
225
+ function fileToRunCorrectPath(fileToRun) {
226
+ if (!(0, fileutils_1.fileExists)(fileToRun)) {
227
+ const cjsFile = fileToRun.replace(/\.js$/, '.cjs');
228
+ if ((0, fileutils_1.fileExists)(cjsFile)) {
229
+ fileToRun = cjsFile;
230
+ }
231
+ else {
232
+ const mjsFile = fileToRun.replace(/\.js$/, '.mjs');
233
+ if ((0, fileutils_1.fileExists)(mjsFile)) {
234
+ fileToRun = mjsFile;
235
+ }
236
+ else {
237
+ throw new Error(`Could not find ${fileToRun}. Make sure your build succeeded.`);
238
+ }
239
+ }
240
+ }
241
+ return fileToRun;
242
+ }
191
243
  exports.default = nodeExecutor;
192
- //# sourceMappingURL=node.impl.js.map
@@ -3,4 +3,3 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const devkit_1 = require("@nx/devkit");
4
4
  const swc_impl_1 = require("./swc.impl");
5
5
  exports.default = (0, devkit_1.convertNxExecutor)(swc_impl_1.swcExecutor);
6
- //# sourceMappingURL=compat.js.map
@@ -110,4 +110,3 @@ function removeTmpSwcrc(swcrcPath) {
110
110
  }
111
111
  }
112
112
  exports.default = swcExecutor;
113
- //# sourceMappingURL=swc.impl.js.map
@@ -3,4 +3,3 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const devkit_1 = require("@nx/devkit");
4
4
  const tsc_impl_1 = require("./tsc.impl");
5
5
  exports.default = (0, devkit_1.convertNxExecutor)(tsc_impl_1.tscExecutor);
6
- //# sourceMappingURL=compat.js.map
@@ -0,0 +1,4 @@
1
+ import type { ExecutorContext } from '@nx/devkit';
2
+ import type { NormalizedExecutorOptions } from '../../../../utils/schema';
3
+ import type { TaskInfo } from './types';
4
+ export declare function buildTaskInfoPerTsConfigMap(tsConfigTaskInfoMap: Record<string, TaskInfo>, tasksOptions: Record<string, NormalizedExecutorOptions>, context: ExecutorContext, tasks: string[], shouldWatch: boolean): void;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildTaskInfoPerTsConfigMap = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const copy_assets_handler_1 = require("../../../../utils/assets/copy-assets-handler");
6
+ const buildable_libs_utils_1 = require("../../../../utils/buildable-libs-utils");
7
+ const generate_temp_tsconfig_1 = require("./generate-temp-tsconfig");
8
+ const get_task_options_1 = require("./get-task-options");
9
+ const taskTsConfigCache = new Set();
10
+ function buildTaskInfoPerTsConfigMap(tsConfigTaskInfoMap, tasksOptions, context, tasks, shouldWatch) {
11
+ for (const taskName of tasks) {
12
+ if (taskTsConfigCache.has(taskName)) {
13
+ continue;
14
+ }
15
+ let taskOptions = tasksOptions[taskName];
16
+ // task is in the batch (it's meant to be processed), create TaskInfo
17
+ if (taskOptions) {
18
+ const taskInfo = createTaskInfo(taskName, taskOptions, context);
19
+ const tsConfigPath = (0, generate_temp_tsconfig_1.generateTempTsConfig)(tasksOptions, taskName, taskOptions, context);
20
+ tsConfigTaskInfoMap[tsConfigPath] = taskInfo;
21
+ taskTsConfigCache.add(taskName);
22
+ }
23
+ else {
24
+ // if it's not included in the provided map, it could be a cached task and
25
+ // we need to pull the options from the relevant project graph node
26
+ taskOptions = (0, get_task_options_1.getTaskOptions)(taskName, context);
27
+ (0, generate_temp_tsconfig_1.generateTempTsConfig)(tasksOptions, taskName, taskOptions, context);
28
+ }
29
+ buildTaskInfoPerTsConfigMap(tsConfigTaskInfoMap, tasksOptions, context, context.taskGraph.dependencies[taskName], shouldWatch);
30
+ }
31
+ }
32
+ exports.buildTaskInfoPerTsConfigMap = buildTaskInfoPerTsConfigMap;
33
+ function createTaskInfo(taskName, taskOptions, context) {
34
+ const target = (0, devkit_1.parseTargetString)(taskName, context.projectGraph);
35
+ const taskContext = Object.assign(Object.assign({}, context), {
36
+ // batch executors don't get these in the context, we provide them
37
+ // here per task
38
+ projectName: target.project, targetName: target.target, configurationName: target.configuration });
39
+ const assetsHandler = new copy_assets_handler_1.CopyAssetsHandler({
40
+ projectDir: taskOptions.projectRoot,
41
+ rootDir: context.root,
42
+ outputDir: taskOptions.outputPath,
43
+ assets: taskOptions.assets,
44
+ });
45
+ const { target: projectGraphNode, dependencies: buildableProjectNodeDependencies, } = (0, buildable_libs_utils_1.calculateProjectDependencies)(context.projectGraph, context.root, context.taskGraph.tasks[taskName].target.project, context.taskGraph.tasks[taskName].target.target, context.taskGraph.tasks[taskName].target.configuration);
46
+ return {
47
+ task: taskName,
48
+ options: taskOptions,
49
+ context: taskContext,
50
+ assetsHandler,
51
+ buildableProjectNodeDependencies,
52
+ projectGraphNode,
53
+ };
54
+ }
@@ -0,0 +1,3 @@
1
+ import type { ExecutorContext } from '@nx/devkit';
2
+ import type { NormalizedExecutorOptions } from '../../../../utils/schema';
3
+ export declare function generateTempTsConfig(taskOptionsMap: Record<string, NormalizedExecutorOptions>, taskName: string, taskOptions: NormalizedExecutorOptions, context: ExecutorContext): string;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateTempTsConfig = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const path_1 = require("path");
6
+ const ts = require("typescript");
7
+ const get_task_options_1 = require("./get-task-options");
8
+ function generateTempTsConfig(taskOptionsMap, taskName, taskOptions, context) {
9
+ const tmpDir = (0, path_1.join)(context.root, 'tmp');
10
+ const originalTsConfigPath = taskOptions.tsConfig;
11
+ const tmpTsConfigPath = (0, path_1.join)(tmpDir, (0, path_1.relative)(context.root, originalTsConfigPath));
12
+ const projectReferences = [];
13
+ for (const depTask of context.taskGraph.dependencies[taskName]) {
14
+ // if included in the provided map, use it
15
+ if (taskOptionsMap[depTask]) {
16
+ projectReferences.push({
17
+ path: (0, path_1.join)(tmpDir, (0, path_1.relative)(context.root, taskOptionsMap[depTask].tsConfig)),
18
+ });
19
+ continue;
20
+ }
21
+ // if it's not included in the provided map, it could be a cached task and
22
+ // we need to pull the tsconfig from the relevant project graph node
23
+ const options = (0, get_task_options_1.getTaskOptions)(depTask, context);
24
+ if (options.tsConfig) {
25
+ projectReferences.push({
26
+ path: (0, path_1.join)(tmpDir, (0, path_1.relative)(context.root, options.tsConfig)),
27
+ });
28
+ }
29
+ }
30
+ (0, devkit_1.writeJsonFile)(tmpTsConfigPath, {
31
+ extends: (0, devkit_1.normalizePath)((0, path_1.relative)((0, path_1.dirname)(tmpTsConfigPath), taskOptions.tsConfig)),
32
+ compilerOptions: {
33
+ rootDir: taskOptions.rootDir,
34
+ outDir: taskOptions.outputPath,
35
+ composite: true,
36
+ declaration: true,
37
+ declarationMap: true,
38
+ tsBuildInfoFile: (0, devkit_1.joinPathFragments)(taskOptions.outputPath, 'tsconfig.tsbuildinfo'),
39
+ },
40
+ references: projectReferences,
41
+ });
42
+ /**
43
+ * Ensure the temp tsconfig has the same modified date as the original.
44
+ * Typescript compares this against the modified date of the tsbuildinfo
45
+ * file. If the tsbuildinfo file is older, the cache is invalidated.
46
+ * Since we always generate the temp tsconfig, any existing tsbuildinfo
47
+ * file will be older even if they are not older than the original tsconfig.
48
+ */
49
+ ts.sys.setModifiedTime(tmpTsConfigPath, ts.sys.getModifiedTime(originalTsConfigPath));
50
+ return tmpTsConfigPath;
51
+ }
52
+ exports.generateTempTsConfig = generateTempTsConfig;
@@ -0,0 +1,3 @@
1
+ import type { ExecutorContext } from '@nx/devkit';
2
+ import type { NormalizedExecutorOptions } from '../../../../utils/schema';
3
+ export declare function getTaskOptions(taskName: string, context: ExecutorContext): NormalizedExecutorOptions;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getTaskOptions = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const normalize_options_1 = require("../normalize-options");
6
+ const tasksOptionsCache = new Map();
7
+ function getTaskOptions(taskName, context) {
8
+ var _a, _b;
9
+ if (tasksOptionsCache.has(taskName)) {
10
+ return tasksOptionsCache.get(taskName);
11
+ }
12
+ const target = context.taskGraph.tasks[taskName].target;
13
+ const projectNode = context.projectGraph.nodes[target.project];
14
+ const targetConfig = (_a = projectNode.data.targets) === null || _a === void 0 ? void 0 : _a[target.target];
15
+ const taskOptions = Object.assign(Object.assign({}, targetConfig.options), (target.configuration
16
+ ? (_b = targetConfig.configurations) === null || _b === void 0 ? void 0 : _b[target.configuration]
17
+ : {}));
18
+ const { project } = (0, devkit_1.parseTargetString)(taskName, context.projectGraph);
19
+ const { sourceRoot, root } = context.projectsConfigurations.projects[project];
20
+ const normalizedTaskOptions = (0, normalize_options_1.normalizeOptions)(taskOptions, context.root, sourceRoot, root);
21
+ tasksOptionsCache.set(taskName, normalizedTaskOptions);
22
+ return normalizedTaskOptions;
23
+ }
24
+ exports.getTaskOptions = getTaskOptions;
@@ -0,0 +1,8 @@
1
+ export * from './build-task-info-per-tsconfig-map';
2
+ export * from './generate-temp-tsconfig';
3
+ export * from './get-task-options';
4
+ export * from './normalize-tasks-options';
5
+ export * from './types';
6
+ export * from './typescript-compilation';
7
+ export * from './typescript-diagnostic-reporters';
8
+ export * from './watch';
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./build-task-info-per-tsconfig-map"), exports);
5
+ tslib_1.__exportStar(require("./generate-temp-tsconfig"), exports);
6
+ tslib_1.__exportStar(require("./get-task-options"), exports);
7
+ tslib_1.__exportStar(require("./normalize-tasks-options"), exports);
8
+ tslib_1.__exportStar(require("./types"), exports);
9
+ tslib_1.__exportStar(require("./typescript-compilation"), exports);
10
+ tslib_1.__exportStar(require("./typescript-diagnostic-reporters"), exports);
11
+ tslib_1.__exportStar(require("./watch"), exports);
@@ -0,0 +1,3 @@
1
+ import type { ExecutorContext } from '@nx/devkit';
2
+ import type { ExecutorOptions, NormalizedExecutorOptions } from '../../../../utils/schema';
3
+ export declare function normalizeTasksOptions(inputs: Record<string, ExecutorOptions>, context: ExecutorContext): Record<string, NormalizedExecutorOptions>;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeTasksOptions = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const normalize_options_1 = require("../normalize-options");
6
+ function normalizeTasksOptions(inputs, context) {
7
+ return Object.entries(inputs).reduce((tasksOptions, [taskName, options]) => {
8
+ const { project } = (0, devkit_1.parseTargetString)(taskName, context.projectGraph);
9
+ const { sourceRoot, root } = context.projectsConfigurations.projects[project];
10
+ tasksOptions[taskName] = (0, normalize_options_1.normalizeOptions)(options, context.root, sourceRoot, root);
11
+ return tasksOptions;
12
+ }, {});
13
+ }
14
+ exports.normalizeTasksOptions = normalizeTasksOptions;
@@ -0,0 +1,12 @@
1
+ import type { ExecutorContext, ProjectGraphProjectNode } from '@nx/devkit';
2
+ import type { CopyAssetsHandler } from '../../../../utils/assets/copy-assets-handler';
3
+ import type { DependentBuildableProjectNode } from '../../../../utils/buildable-libs-utils';
4
+ import type { NormalizedExecutorOptions } from '../../../../utils/schema';
5
+ export interface TaskInfo {
6
+ task: string;
7
+ options: NormalizedExecutorOptions;
8
+ context: ExecutorContext;
9
+ assetsHandler: CopyAssetsHandler;
10
+ buildableProjectNodeDependencies: DependentBuildableProjectNode[];
11
+ projectGraphNode: ProjectGraphProjectNode;
12
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ import type { TaskGraph } from '@nx/devkit';
2
+ import type { BatchResults } from 'nx/src/tasks-runner/batch/batch-messages';
3
+ import type { TaskInfo } from './types';
4
+ export declare function compileBatchTypescript(tsConfigTaskInfoMap: Record<string, TaskInfo>, taskGraph: TaskGraph, watch: boolean, postProjectCompilationCallback: (taskInfo: TaskInfo) => void): {
5
+ iterator: AsyncIterable<BatchResults>;
6
+ close: () => void | Promise<void>;
7
+ };