@smoothbricks/nx-plugin 0.7.17 → 0.7.19

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 (199) hide show
  1. package/README.md +315 -114
  2. package/dist/.build-inputs.json +47 -38
  3. package/dist/built-output-packages.js +1 -1
  4. package/dist/bun-lock-scope.d.ts +128 -20
  5. package/dist/bun-lock-scope.d.ts.map +1 -1
  6. package/dist/bun-lock-scope.js +267 -44
  7. package/dist/cargo-closure-input.d.ts +8 -6
  8. package/dist/cargo-closure-input.d.ts.map +1 -1
  9. package/dist/cargo-closure-input.js +15 -12
  10. package/dist/cargo-source-hash.d.ts +26 -25
  11. package/dist/cargo-source-hash.d.ts.map +1 -1
  12. package/dist/cargo-source-hash.js +84 -105
  13. package/dist/cargo-toolchain-paths.d.ts +2 -2
  14. package/dist/cargo-toolchain-paths.js +2 -2
  15. package/dist/cargo-workspace.d.ts +20 -2
  16. package/dist/cargo-workspace.d.ts.map +1 -1
  17. package/dist/cargo-workspace.js +43 -22
  18. package/dist/ensure-built-receipt.d.ts +3 -2
  19. package/dist/ensure-built-receipt.d.ts.map +1 -1
  20. package/dist/ensure-built-receipt.js +3 -2
  21. package/dist/eslint-config-closure.d.ts +8 -3
  22. package/dist/eslint-config-closure.d.ts.map +1 -1
  23. package/dist/eslint-config-closure.js +24 -5
  24. package/dist/executors/bounded-exec/admission-queue.d.ts +3 -1
  25. package/dist/executors/bounded-exec/admission-queue.d.ts.map +1 -1
  26. package/dist/executors/bounded-exec/admission-queue.js +9 -10
  27. package/dist/executors/bounded-exec/awake-clock.d.ts +5 -0
  28. package/dist/executors/bounded-exec/awake-clock.d.ts.map +1 -0
  29. package/dist/executors/bounded-exec/awake-clock.js +22 -0
  30. package/dist/executors/bounded-exec/bounds.d.ts +19 -6
  31. package/dist/executors/bounded-exec/bounds.d.ts.map +1 -1
  32. package/dist/executors/bounded-exec/bounds.js +22 -15
  33. package/dist/executors/bounded-exec/case-gate.d.ts +114 -0
  34. package/dist/executors/bounded-exec/case-gate.d.ts.map +1 -0
  35. package/dist/executors/bounded-exec/case-gate.js +342 -0
  36. package/dist/executors/bounded-exec/cpu-pool-thread.d.ts +1 -0
  37. package/dist/executors/bounded-exec/cpu-pool-thread.d.ts.map +1 -1
  38. package/dist/executors/bounded-exec/cpu-pool-thread.js +2 -2
  39. package/dist/executors/bounded-exec/cpu-pool.d.ts +28 -1
  40. package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
  41. package/dist/executors/bounded-exec/cpu-pool.js +102 -16
  42. package/dist/executors/bounded-exec/cpu-rise.d.ts +73 -0
  43. package/dist/executors/bounded-exec/cpu-rise.d.ts.map +1 -0
  44. package/dist/executors/bounded-exec/cpu-rise.js +111 -0
  45. package/dist/executors/bounded-exec/endpoint-life.d.ts +146 -0
  46. package/dist/executors/bounded-exec/endpoint-life.d.ts.map +1 -0
  47. package/dist/executors/bounded-exec/endpoint-life.js +228 -0
  48. package/dist/executors/bounded-exec/executor.d.ts +1 -1
  49. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  50. package/dist/executors/bounded-exec/executor.js +256 -86
  51. package/dist/executors/bounded-exec/gateway-lease.d.ts +1 -1
  52. package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -1
  53. package/dist/executors/bounded-exec/gateway-lease.js +8 -1
  54. package/dist/executors/bounded-exec/go-run-summary.d.ts +51 -0
  55. package/dist/executors/bounded-exec/go-run-summary.d.ts.map +1 -0
  56. package/dist/executors/bounded-exec/go-run-summary.js +98 -0
  57. package/dist/executors/bounded-exec/hang-diagnostics.d.ts +11 -3
  58. package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
  59. package/dist/executors/bounded-exec/hang-diagnostics.js +125 -47
  60. package/dist/executors/bounded-exec/lease-wait.d.ts +1 -0
  61. package/dist/executors/bounded-exec/lease-wait.d.ts.map +1 -1
  62. package/dist/executors/bounded-exec/lease-wait.js +1 -0
  63. package/dist/executors/bounded-exec/mbx-pool.d.ts +42 -7
  64. package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -1
  65. package/dist/executors/bounded-exec/mbx-pool.js +45 -8
  66. package/dist/executors/bounded-exec/mbx-reservations.d.ts +12 -6
  67. package/dist/executors/bounded-exec/mbx-reservations.d.ts.map +1 -1
  68. package/dist/executors/bounded-exec/mbx-reservations.js +190 -284
  69. package/dist/executors/bounded-exec/parent-grant.d.ts +2 -0
  70. package/dist/executors/bounded-exec/parent-grant.d.ts.map +1 -1
  71. package/dist/executors/bounded-exec/parent-grant.js +1 -0
  72. package/dist/executors/bounded-exec/pool-admission.d.ts +29 -3
  73. package/dist/executors/bounded-exec/pool-admission.d.ts.map +1 -1
  74. package/dist/executors/bounded-exec/pool-admission.js +47 -1
  75. package/dist/executors/bounded-exec/progress-channel.d.ts +38 -0
  76. package/dist/executors/bounded-exec/progress-channel.d.ts.map +1 -0
  77. package/dist/executors/bounded-exec/progress-channel.js +113 -0
  78. package/dist/executors/bounded-exec/progress.d.ts +5 -1
  79. package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
  80. package/dist/executors/bounded-exec/progress.js +31 -1
  81. package/dist/executors/bounded-exec/ram-temp.d.ts +24 -1
  82. package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
  83. package/dist/executors/bounded-exec/ram-temp.js +123 -16
  84. package/dist/executors/bounded-exec/reservation-connection.d.ts +90 -0
  85. package/dist/executors/bounded-exec/reservation-connection.d.ts.map +1 -0
  86. package/dist/executors/bounded-exec/reservation-connection.js +248 -0
  87. package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -1
  88. package/dist/executors/bounded-exec/run-cpu-pool.js +3 -0
  89. package/dist/executors/bounded-exec/runner-sizing.d.ts +9 -5
  90. package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -1
  91. package/dist/executors/bounded-exec/runner-sizing.js +13 -9
  92. package/dist/executors/bounded-exec/schema.d.ts +7 -2
  93. package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
  94. package/dist/executors/bounded-exec/schema.js +17 -1
  95. package/dist/executors/bounded-exec/suite-minimum.d.ts +21 -0
  96. package/dist/executors/bounded-exec/suite-minimum.d.ts.map +1 -0
  97. package/dist/executors/bounded-exec/suite-minimum.js +85 -0
  98. package/dist/executors/bounded-exec/test-result-writer.d.ts +2 -0
  99. package/dist/executors/bounded-exec/test-result-writer.d.ts.map +1 -1
  100. package/dist/executors/bounded-exec/test-result-writer.js +1 -0
  101. package/dist/executors/bounded-exec/test-results.d.ts +5 -0
  102. package/dist/executors/bounded-exec/test-results.d.ts.map +1 -1
  103. package/dist/executors/bounded-exec/test-results.js +2 -2
  104. package/dist/executors/bounded-exec/verdict.d.ts +39 -10
  105. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
  106. package/dist/executors/bounded-exec/verdict.js +60 -14
  107. package/dist/executors/cargo-zigbuild/executor.d.ts +10 -8
  108. package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -1
  109. package/dist/executors/cargo-zigbuild/executor.js +32 -19
  110. package/dist/index.d.ts.map +1 -1
  111. package/dist/index.js +294 -152
  112. package/dist/managed-files/ci-workflow.d.ts +4 -1
  113. package/dist/managed-files/ci-workflow.d.ts.map +1 -1
  114. package/dist/managed-files/ci-workflow.js +9 -14
  115. package/dist/managed-files/files.d.ts +3 -3
  116. package/dist/managed-files/files.js +3 -3
  117. package/dist/managed-files/generator.d.ts +5 -1
  118. package/dist/managed-files/generator.d.ts.map +1 -1
  119. package/dist/managed-files/generator.js +22 -7
  120. package/dist/managed-files/render-memo.d.ts +13 -0
  121. package/dist/managed-files/render-memo.d.ts.map +1 -0
  122. package/dist/managed-files/render-memo.js +94 -0
  123. package/dist/task-results.js +2 -1
  124. package/dist/test-program.d.ts +11 -6
  125. package/dist/test-program.d.ts.map +1 -1
  126. package/dist/test-program.js +39 -35
  127. package/dist/tool-bins.d.ts +12 -0
  128. package/dist/tool-bins.d.ts.map +1 -1
  129. package/dist/tool-bins.js +31 -6
  130. package/dist/typecheck-test-policy.d.ts +10 -1
  131. package/dist/typecheck-test-policy.d.ts.map +1 -1
  132. package/dist/typecheck-test-policy.js +40 -24
  133. package/dist/workspace-config-policy.d.ts.map +1 -1
  134. package/dist/workspace-config-policy.js +135 -42
  135. package/dist/workspace-index.d.ts +14 -1
  136. package/dist/workspace-index.d.ts.map +1 -1
  137. package/dist/workspace-index.js +36 -4
  138. package/executors.json +2 -0
  139. package/managed/raw/envrc +24 -0
  140. package/managed/raw/patches/nx@24.0.3.patch +1851 -221
  141. package/managed/raw/patches/ttsc@0.37.1.patch +1055 -0
  142. package/managed/raw/tooling/direnv/developer-links.ts +122 -14
  143. package/managed/raw/tooling/direnv/devenv.smoo.nix +20 -19
  144. package/managed/templates/github/actions/save-nix-devenv/action.yml +19 -1
  145. package/managed/templates/github/actions/setup-devenv/action.yml +2 -0
  146. package/package.json +68 -11
  147. package/runtime/nx-publish/.build-inputs.json +2 -2
  148. package/runtime/nx-publish/cache_adapter.js +293 -3
  149. package/runtime/nx-publish/nx_publish.js +36 -14
  150. package/src/built-output-packages.ts +1 -1
  151. package/src/bun-lock-scope.ts +293 -40
  152. package/src/cargo-closure-input.ts +20 -12
  153. package/src/cargo-source-hash.ts +119 -145
  154. package/src/cargo-toolchain-paths.ts +2 -2
  155. package/src/cargo-workspace.ts +59 -21
  156. package/src/ensure-built-receipt.ts +3 -2
  157. package/src/eslint-config-closure.ts +27 -6
  158. package/src/executors/bounded-exec/admission-queue.ts +11 -10
  159. package/src/executors/bounded-exec/awake-clock.ts +20 -0
  160. package/src/executors/bounded-exec/bounds.ts +41 -19
  161. package/src/executors/bounded-exec/case-gate.ts +365 -0
  162. package/src/executors/bounded-exec/cpu-pool-thread.ts +3 -3
  163. package/src/executors/bounded-exec/cpu-pool.ts +139 -12
  164. package/src/executors/bounded-exec/cpu-rise.ts +156 -0
  165. package/src/executors/bounded-exec/endpoint-life.ts +279 -0
  166. package/src/executors/bounded-exec/executor.ts +341 -123
  167. package/src/executors/bounded-exec/gateway-lease.ts +6 -0
  168. package/src/executors/bounded-exec/go-run-summary.ts +137 -0
  169. package/src/executors/bounded-exec/hang-diagnostics.ts +150 -50
  170. package/src/executors/bounded-exec/lease-wait.ts +1 -0
  171. package/src/executors/bounded-exec/mbx-pool.ts +57 -9
  172. package/src/executors/bounded-exec/mbx-reservations.ts +216 -183
  173. package/src/executors/bounded-exec/parent-grant.ts +3 -0
  174. package/src/executors/bounded-exec/pool-admission.ts +59 -2
  175. package/src/executors/bounded-exec/progress-channel.ts +129 -0
  176. package/src/executors/bounded-exec/progress.ts +39 -3
  177. package/src/executors/bounded-exec/ram-temp.ts +137 -17
  178. package/src/executors/bounded-exec/reservation-connection.ts +221 -0
  179. package/src/executors/bounded-exec/run-cpu-pool.ts +2 -0
  180. package/src/executors/bounded-exec/runner-sizing.ts +13 -8
  181. package/src/executors/bounded-exec/schema.json +1 -1
  182. package/src/executors/bounded-exec/schema.ts +21 -2
  183. package/src/executors/bounded-exec/suite-minimum.ts +81 -0
  184. package/src/executors/bounded-exec/test-result-writer.ts +3 -0
  185. package/src/executors/bounded-exec/test-results.ts +5 -0
  186. package/src/executors/bounded-exec/verdict.ts +83 -22
  187. package/src/executors/cargo-zigbuild/executor.ts +30 -19
  188. package/src/index.ts +357 -166
  189. package/src/managed-files/ci-workflow.ts +13 -17
  190. package/src/managed-files/files.ts +3 -3
  191. package/src/managed-files/generator.ts +21 -6
  192. package/src/managed-files/render-memo.ts +135 -0
  193. package/src/test-program.ts +36 -41
  194. package/src/tool-bins.ts +35 -6
  195. package/src/typecheck-test-policy.ts +49 -24
  196. package/src/workspace-config-policy.ts +161 -43
  197. package/src/workspace-index.ts +40 -5
  198. package/test-timings.json +157 -141
  199. package/managed/raw/patches/ttsc@0.36.3.patch +0 -1660
package/dist/index.js CHANGED
@@ -10,19 +10,21 @@ import { parse as parseToml } from 'smol-toml';
10
10
  import { BOUNDED_TEST_IDLE_TIMEOUT_MS, BOUNDED_TEST_KILL_AFTER_MS } from './bounded-test-policy.js';
11
11
  import { refuseOverlappingOutputs } from './build-state-output-policy.js';
12
12
  import { builtOutputLockfileDependencies, builtOutputLockfileNodes } from './built-output-packages.js';
13
- import { bunLockDependencies, bunLockInput, bunLockNode } from './bun-lock-scope.js';
14
- import { CARGO_CLOSURE_INPUT, CARGO_LOCK_NODE_PREFIX, cargoClosureInputs, cargoLockNode, cargoLockNodeName, indexedCargoManifests, isCargoLockInput, resolveCargoClosureSource, } from './cargo-closure-input.js';
13
+ import { BUN_LOCK_SCOPE_NAMED_INPUT, bunLoadInput, bunLoadScopes, bunLockDependencies, bunLockInput, bunLockNode, bunLockRuntimeNode, bunScopeInput, bunVersionAliasDependencies, manifestsAbove, refuseUndeclaredImports, specifierPackage, typescriptLoads, } from './bun-lock-scope.js';
14
+ import { CARGO_CLOSURE_INPUT, CARGO_LOCK_NODE_PREFIX, cargoClosureInputs, cargoLockNode, cargoLockNodeName, indexedCargoSources, isCargoLockInput, resolveCargoClosureSource, } from './cargo-closure-input.js';
15
15
  import { CARGO_PRODUCER_METADATA, postTasksExecution as postCargoRetention } from './cargo-retention-hook.js';
16
16
  import { CARGO_TOOLCHAIN_NAMED_INPUT, cargoRuntimeInput, cargoToolchainInputs } from './cargo-toolchain-policy.js';
17
- import { attributeCargoWorkspacePackages, CARGO_TEST_BUILD_TARGET, CARGO_TEST_EXCEPTIONS_SUFFIX, CARGO_TEST_TARGET, cargoPackageTestInputs, cargoTestGroupTargetName, cargoTestPackageTargetName, createCargoInputsCache, EXTERNAL_RUST_CRATES_INPUT, exceptionalTestFilter, listCargoCrossTestTargets, listCargoWorkspacePackages, NEXTEST_REPO_CONFIG_PATH, nextestToolConfigArg, PLUGIN_NEXTEST_CONFIG_PATH, requireExternalRustCratesInput, serialTestGroups, } from './cargo-workspace.js';
17
+ import { attributeCargoWorkspacePackages, CARGO_TEST_BUILD_TARGET, CARGO_TEST_EXCEPTIONS_SUFFIX, CARGO_TEST_TARGET, cargoPackageTestInputs, cargoProducerOutputInputs, cargoTestGroupTargetName, cargoTestPackageTargetName, createCargoInputsCache, EXTERNAL_RUST_CRATES_INPUT, exceptionalTestFilter, listCargoCrossTestTargets, listCargoWorkspacePackages, NEXTEST_REPO_CONFIG_PATH, nextestToolConfigArg, PLUGIN_NEXTEST_CONFIG_PATH, requireExternalRustCratesInput, serialTestGroups, } from './cargo-workspace.js';
18
18
  import { compileEnvironment } from './compile-environment.js';
19
19
  import { CARGO_CROSS_LINT_COMMAND, CARGO_CROSS_LINT_TARGET, CARGO_FETCH_COMMAND, CARGO_FETCH_TARGET, CARGO_LINT_CLIPPY_COMMAND, cargoCrossTestArchiveFile, cargoCrossTestArchiveTargetName, cargoCrossTestTargetName, cargoFrozen, runsFrozenCargo, } from './cross-check-policy.js';
20
20
  import { directDependencyManifests } from './dependency-manifests.js';
21
21
  import { eslintConfigClosure } from './eslint-config-closure.js';
22
22
  import { ESLINT_SOURCES_GLOB, eslintSources } from './eslint-sources.js';
23
23
  import { ALL_VERDICTS_EXECUTOR, ESLINT_SOURCES_TOKEN, } from './executors/all-verdicts/schema.js';
24
+ import { runsAsCargoLeaf } from './executors/bounded-exec/mbx-pool.js';
24
25
  import { closeRunReservations, serveRunReservations } from './executors/bounded-exec/mbx-reservations.js';
25
26
  import { closeRunCpuPool, serveRunCpuPool } from './executors/bounded-exec/run-cpu-pool.js';
27
+ import { boundedCommand } from './executors/bounded-exec/schema.js';
26
28
  import { ffiPathProblem } from './executors/scriptc-native/ffi-paths.js';
27
29
  import { hashVersionlessCrateManifests } from './manifest-hash.js';
28
30
  import { NEXTEST_TIMINGS_PATH, namedTestsFilter, readNextestTimings, timedShardMembers } from './nextest-timings.js';
@@ -32,7 +34,7 @@ import { inferredTaskKind, refuseBuildTestDependencies } from './task-graph-poli
32
34
  import { postTasksExecution as postTaskResults, preTasksExecution as preTaskResults } from './task-results.js';
33
35
  import { SHARD_TIMINGS_EXECUTOR, SHARD_TIMINGS_TARGET, timingsShardedSuite, timingsSuiteInputs, } from './test-timings.js';
34
36
  import { assertUpstreamBasePrecondition } from './test-walk-policy.js';
35
- import { nativeToolCommand, nativeToolDependsOn, resolveNativeTools } from './tool-bins.js';
37
+ import { nativeToolCommand, nativeToolDependsOn, pluginBuildDependsOn, resolveNativeTools, } from './tool-bins.js';
36
38
  import { typecheckRoute } from './typecheck-route.js';
37
39
  import { isBuildOutputTargetName, isTestNamespaceTargetName, isTestRunnerTargetName, RELEASE_CONFIGURATION, } from './workspace-config-policy.js';
38
40
  import { globIndexedFiles } from './workspace-index.js';
@@ -63,6 +65,13 @@ const WORKSPACE_TSCONFIG_BASE_INPUT = '{workspaceRoot}/tsconfig.base.json';
63
65
  */
64
66
  const TYPECHECK_COMPILER_ENV = 'SMOO_TYPECHECK_TSC';
65
67
  const TYPECHECK_COMPILER_INPUT = { env: TYPECHECK_COMPILER_ENV };
68
+ /**
69
+ * The named input a project defines as the compiler identity of its inferred `typecheck`: {@link TYPECHECK_COMPILER_INPUT}
70
+ * where that target runs the native compiler, undefined where it runs ttsc, whose compiler the workspace keys, or where
71
+ * a declared `typecheck` replaces the inferred command. A workspace `typecheck` default that replaces the inferred
72
+ * inputs names it to key exactly the compiler its command runs, and defines it empty in `nx.json` for the rest.
73
+ */
74
+ const TYPECHECK_COMPILER_NAMED_INPUT = 'typecheckCompiler';
66
75
  function typecheckCommand(args) {
67
76
  return `"\${${TYPECHECK_COMPILER_ENV}:?is unset, enter the devenv shell (devenv.smoo.nix builds the typecheck compiler)}" ${args}`;
68
77
  }
@@ -139,33 +148,55 @@ const NODE_MODULES_SEGMENT = /(?:^|\/)node_modules(?:\/|$)/;
139
148
  * the two kinds Nx has no fileset for; see {@link configChainInput}.
140
149
  */
141
150
  function typescriptConfigChainInputs(configPaths, workspaceRoot) {
142
- const inputs = new Set([WORKSPACE_TSCONFIG_BASE_INPUT]);
151
+ const chain = {
152
+ inputs: new Set([WORKSPACE_TSCONFIG_BASE_INPUT]),
153
+ extendsLoads: [],
154
+ transformLoads: [],
155
+ };
143
156
  const walked = new Set();
144
157
  for (const configPath of configPaths) {
145
- addTypescriptConfigAncestors(configPath, workspaceRoot, inputs, walked);
158
+ addTypescriptConfigAncestors(configPath, workspaceRoot, chain, walked);
159
+ }
160
+ return { inputs: [...chain.inputs], extendsLoads: chain.extendsLoads, transformLoads: chain.transformLoads };
161
+ }
162
+ /** The bare transform plugin specifiers one config names (`compilerOptions.plugins[].transform`). */
163
+ function typescriptTransforms(configPath) {
164
+ const config = readJsonFile(configPath, { expectComments: true });
165
+ if (!isRecord(config) || !isRecord(config.compilerOptions) || !Array.isArray(config.compilerOptions.plugins)) {
166
+ return [];
146
167
  }
147
- return [...inputs];
168
+ return config.compilerOptions.plugins.flatMap((plugin) => isRecord(plugin) && typeof plugin.transform === 'string' && /^[@\w]/u.test(plugin.transform)
169
+ ? [plugin.transform]
170
+ : []);
148
171
  }
149
172
  /**
150
173
  * One config's ancestors; `walked` both dedupes shared bases and breaks an
151
174
  * `extends` cycle.
152
175
  *
153
176
  * The walk stops at an ancestor Nx cannot hash, because everything reachable
154
- * from an installed config is installed too: the lockfile pins that whole
155
- * subtree, and parsing it could only invent failures for a dependency's own
156
- * chain.
177
+ * from an installed config is installed too: the package holding it is
178
+ * recorded as a load of the extending config's directory, and the lock scope
179
+ * that declares it there keys that whole subtree. Parsing it could only
180
+ * invent failures for a dependency's own chain.
157
181
  */
158
- function addTypescriptConfigAncestors(configPath, workspaceRoot, inputs, walked) {
182
+ function addTypescriptConfigAncestors(configPath, workspaceRoot, chain, walked) {
159
183
  if (walked.has(configPath))
160
184
  return;
161
185
  walked.add(configPath);
186
+ const directory = relative(workspaceRoot, dirname(configPath)).replaceAll('\\', '/') || '.';
187
+ for (const transform of typescriptTransforms(configPath)) {
188
+ chain.transformLoads.push({ directory, name: specifierPackage(transform) });
189
+ }
162
190
  for (const specifier of typescriptConfigExtends(configPath)) {
163
191
  const ancestor = resolveTypescriptConfigExtends(specifier, configPath);
164
192
  const input = configChainInput(ancestor, configPath, workspaceRoot);
165
- if (input === null)
193
+ if (input === null) {
194
+ if (ancestor.installed)
195
+ chain.extendsLoads.push({ directory, name: specifierPackage(specifier) });
166
196
  continue;
167
- inputs.add(input);
168
- addTypescriptConfigAncestors(ancestor.path, workspaceRoot, inputs, walked);
197
+ }
198
+ chain.inputs.add(input);
199
+ addTypescriptConfigAncestors(ancestor.path, workspaceRoot, chain, walked);
169
200
  }
170
201
  }
171
202
  /** What one config extends: a single specifier, or the ordered list TypeScript 5.0 added. */
@@ -319,16 +350,19 @@ const ESLINT_CONFIG_FILES = [
319
350
  * The configs key every lint target with exactly the workspace files they
320
351
  * load (eslint-config-closure.ts): a glob over the directory holding a
321
352
  * config's rule modules keyed every file beside them, and one test fixture
322
- * there re-keyed 44 lint targets in one land.
353
+ * there re-keyed 44 lint targets in one land. The packages they load by name
354
+ * key it by the lock scope declaring each where it loads (bun-lock-scope.ts).
323
355
  */
324
356
  async function eslintWorkspace(workspaceRoot) {
325
357
  const configs = ESLINT_CONFIG_FILES.filter((name) => existsSync(join(workspaceRoot, name)));
326
358
  if (configs.length === 0)
327
359
  return null;
328
360
  const indexed = new Set(await globIndexedFiles(workspaceRoot, [ESLINT_SOURCES_GLOB, '**/*.json']));
361
+ const closure = eslintConfigClosure(workspaceRoot, configs, indexed);
329
362
  return {
330
363
  sources: new Set([...indexed].filter((path) => !path.endsWith('.json'))),
331
- configImports: eslintConfigClosure(workspaceRoot, configs, indexed),
364
+ configImports: closure.files,
365
+ configScopes: bunLoadScopes(workspaceRoot, closure.packageLoads),
332
366
  };
333
367
  }
334
368
  function projectLintCommands(projectRoot, workspaceRoot, eslint) {
@@ -661,14 +695,16 @@ function createCargoWasmTarget(projectRoot, config, repoRooted, cargoTargetDirec
661
695
  * create its parent, so the build consumes what the `mkdir` produced. Outside
662
696
  * Nx there is no task hash, and a build no task names is refused here rather
663
697
  * than by every runner.
698
+ *
699
+ * `inputs` is the workspace's Cargo union; the build also runs the nextest helper (`record`).
664
700
  */
665
- function createCargoTestBuildTarget(projectRoot, toolConfig, nativeTools) {
666
- const helper = nativeToolCommand(nativeTools, projectRoot, 'nextest-extract', 'smoo-nx-nextest-binaries');
701
+ function createCargoTestBuildTarget(projectRoot, toolConfig, nativeTools, inputs) {
702
+ const helper = nativeToolCommand(nativeTools, projectRoot, 'nextest-extract', NEXTEST_HELPER_BIN);
667
703
  return {
668
704
  executor: 'nx:run-commands',
669
705
  metadata: CARGO_PRODUCER_METADATA,
670
706
  cache: true,
671
- inputs: CARGO_INPUTS,
707
+ inputs: [...inputs, ...nextestHelperInputs(nativeTools)],
672
708
  outputs: [
673
709
  `{projectRoot}/${NEXTEST_BINARIES_METADATA}`,
674
710
  `{projectRoot}/${NEXTEST_CARGO_METADATA}`,
@@ -696,6 +732,27 @@ function createCargoTestBuildTarget(projectRoot, toolConfig, nativeTools) {
696
732
  function nextestBinariesBuild(toolConfig) {
697
733
  return cargoFrozen(`${NEXTEST_BINARIES_BUILD_ARGS.join(' ')} ${toolConfig}`);
698
734
  }
735
+ /** The nextest helper the test build and every runner run (`record`, `ensure`, `target-dir`). */
736
+ const NEXTEST_HELPER_BIN = 'smoo-nx-nextest-binaries';
737
+ /**
738
+ * The helper's bytes, for a target that runs it, where this workspace builds it: the producer edge orders the build and
739
+ * this input keys what the target runs. An installed helper is its package's, keyed as the package.
740
+ */
741
+ function nextestHelperInputs(nativeTools) {
742
+ return nativeTools !== null && nativeToolDependsOn(nativeTools, 'nextest-extract').length > 0
743
+ ? [{ dependentTasksOutputFiles: `**/dist/bin/${nativeTools.platform}/${NEXTEST_HELPER_BIN}`, transitive: false }]
744
+ : [];
745
+ }
746
+ /**
747
+ * The record writer's bytes, for a target that runs it after its build, where this workspace builds it: the writer
748
+ * decides the `.build-inputs.json` the target's outputs hold, so a change to what a record states re-keys the target
749
+ * and no cache hit restores a record in the old form. An installed writer is its package's, keyed as the package.
750
+ */
751
+ function buildInputsToolInputs(nativeTools) {
752
+ return nativeTools !== null && nativeToolDependsOn(nativeTools, 'build-inputs').length > 0
753
+ ? [{ dependentTasksOutputFiles: `**/dist/bin/${nativeTools.platform}/smoo-nx-build-inputs`, transitive: false }]
754
+ : [];
755
+ }
699
756
  /**
700
757
  * One foreign triple's test archive, and the target that EXECUTES it.
701
758
  *
@@ -1033,11 +1090,13 @@ export const postTasksExecution = async (options, context) => {
1033
1090
  export const createDependencies = (options, context) => [
1034
1091
  ...bunLockDependencies(context),
1035
1092
  ...builtOutputLockfileDependencies(options, context),
1093
+ ...bunVersionAliasDependencies(context.externalNodes ?? {}),
1036
1094
  ];
1037
1095
  /** Nx invokes this only after merging inferred/declarative targets and every plugin's project dependencies. */
1038
1096
  export const createMetadata = (graph, _options, context) => {
1039
1097
  refuseOverlappingOutputs(graph, context.workspaceRoot);
1040
1098
  refuseBuildTestDependencies(graph, context.workspaceRoot);
1099
+ refuseUndeclaredImports(graph);
1041
1100
  return {};
1042
1101
  };
1043
1102
  export default { createNodesV2, createDependencies, createMetadata, postTasksExecution, preTasksExecution };
@@ -1337,19 +1396,33 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
1337
1396
  // whole `extends` chain of the configs its commands name and not just those
1338
1397
  // two files. Resolved once per project: every target below shares it.
1339
1398
  const typescriptConfigChain = typescriptConfigChainInputs([...(hasLibTsconfig ? [libTsconfigPath] : []), ...(hasTestTsconfig ? [testTsconfigPath] : [])], workspaceRoot);
1399
+ // The packages a TypeScript task loads by name beyond its sources' imports, each keyed by the lock scope that
1400
+ // declares it where it loads (bun-lock-scope.ts): the project's own node keys its own declarations, and a root
1401
+ // declaration is named by itself, so no task is keyed on root tooling it never loads. A check reads the @types and
1402
+ // tslib TypeScript finds by ancestry and the installed configs its chain extends. The emit also runs ttsc from the
1403
+ // root's node_modules/.bin, and ttsc loads the TypeScript API from the project and each transform plugin its
1404
+ // configs name.
1405
+ const manifests = manifestsAbove(workspaceRoot, projectRoot);
1406
+ const rootManifests = manifests.filter((manifest) => manifest.root === '.');
1407
+ const checkScopes = [
1408
+ ...bunLoadInput(manifests, typescriptLoads(manifests)).externalDependencies,
1409
+ ...bunLoadScopes(workspaceRoot, typescriptConfigChain.extendsLoads),
1410
+ ];
1411
+ const checkScopeInput = bunScopeInput(projectRoot, checkScopes);
1412
+ const emitScopeInput = bunScopeInput(projectRoot, checkScopes, bunLoadInput(manifests, ['typescript']).externalDependencies, bunLoadInput(rootManifests, ['ttsc', '@typescript/native']).externalDependencies, bunLoadScopes(workspaceRoot, typescriptConfigChain.transformLoads));
1340
1413
  const toolchainInputs = [
1341
1414
  ...RELEASE_REWRITTEN_WORKSPACE_INPUTS,
1342
- bunLockInput(projectRoot),
1415
+ emitScopeInput,
1343
1416
  ...TYPESCRIPT_PATCH_INPUTS,
1344
- ...typescriptConfigChain,
1417
+ ...typescriptConfigChain.inputs,
1345
1418
  ];
1346
1419
  const checkInputs = versionless === null
1347
1420
  ? toolchainInputs
1348
1421
  : [
1349
1422
  ...TYPESCRIPT_PATCH_INPUTS,
1350
- ...typescriptConfigChain,
1423
+ ...typescriptConfigChain.inputs,
1351
1424
  ...VERSIONLESS_TOOLCHAIN_MANIFEST_INPUTS,
1352
- bunLockInput(projectRoot),
1425
+ checkScopeInput,
1353
1426
  ];
1354
1427
  const selfProduction = versionless === null ? 'production' : VERSIONLESS_PRODUCTION_INPUT;
1355
1428
  const selfDefault = versionless === null ? 'default' : VERSIONLESS_DEFAULT_INPUT;
@@ -1513,24 +1586,28 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
1513
1586
  memberDir: plan.package.dir,
1514
1587
  cache: cargoWorkspace.inputsCache,
1515
1588
  cargo: cargoWorkspace.closureSource.cargo,
1589
+ sources: cargoWorkspace.closureSource.sources,
1516
1590
  })))).flat()),
1517
1591
  ];
1518
- // Generated crate sources (wire codecs, vocabularies, fixtures) are
1519
- // gitignored and invisible to nx's file hasher; they reach these targets
1520
- // as the outputs of the targets a repository adds to `dependsOn`. Hashing
1521
- // those outputs here means a repository never has to restate `inputs` to
1522
- // add them - and a restated `inputs` REPLACES this union with the root
1523
- // project's `default`, which owns no crate file, so the test build then
1524
- // cache-hits against edited crates while every per-crate test reruns on
1525
- // the stale binary. That verdict is wrong, not merely slow.
1592
+ // Generated crate sources (wire codecs, vocabularies, fixtures) and
1593
+ // compiled-in files are often gitignored and invisible to nx's file
1594
+ // hasher; they reach these targets as the outputs of the targets a
1595
+ // repository adds to `dependsOn`. Hashing those outputs here means a
1596
+ // repository never has to restate `inputs` to add them - and a restated
1597
+ // `inputs` REPLACES this union with the root project's `default`, which
1598
+ // owns no crate file, so the test build then cache-hits against edited
1599
+ // crates while every per-crate test reruns on the stale binary. Only the
1600
+ // outputs under the union's own file sets are hashed
1601
+ // (`cargoProducerOutputInputs`): a compile reads nothing else, and a
1602
+ // producer's TypeScript output outside every crate keys no Rust build.
1603
+ const closureInputs = workspaceInputs.length > 0 ? workspaceInputs : CARGO_INPUTS;
1526
1604
  const workspaceCargoInputs = [
1527
- ...(workspaceInputs.length > 0 ? workspaceInputs : CARGO_INPUTS),
1528
- { dependentTasksOutputFiles: '**/*', transitive: false },
1605
+ ...closureInputs,
1606
+ ...cargoProducerOutputInputs(closureInputs, cargoWorkspaceRoot),
1529
1607
  ];
1530
- targets[CARGO_TEST_BUILD_TARGET] = createCargoTestBuildTarget(cargoWorkspaceRoot, nextestToolConfigArg(cargoWorkspaceRoot), nativeTools);
1531
1608
  // The build's `cargo nextest list` loads the repository's nextest config and
1532
1609
  // refuses an invalid one, so that file keys the build as well as every run.
1533
- targets[CARGO_TEST_BUILD_TARGET].inputs = [...workspaceCargoInputs, `{projectRoot}/${NEXTEST_REPO_CONFIG_PATH}`];
1610
+ targets[CARGO_TEST_BUILD_TARGET] = createCargoTestBuildTarget(cargoWorkspaceRoot, nextestToolConfigArg(cargoWorkspaceRoot), nativeTools, [...workspaceCargoInputs, `{projectRoot}/${NEXTEST_REPO_CONFIG_PATH}`]);
1534
1611
  // One archive per declared foreign triple, from the same inputs and the
1535
1612
  // same repository nextest config, whose `archive.include` decides what an
1536
1613
  // archive CONTAINS: it is the workspace's test binaries for another
@@ -1797,36 +1874,6 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
1797
1874
  [UNRESOLVED_CARGO_LOCK_INPUT]),
1798
1875
  ];
1799
1876
  }
1800
- const napiDebug = targets['napi-debug'];
1801
- if (napiDebug && cargoWorkspace) {
1802
- // A crate whose project also builds the debug cdylib runs its tests after
1803
- // that build: the tests dlopen what `napi-debug` writes into `target/debug`,
1804
- // and a test binary run in place loads it from this tree.
1805
- const runners = [
1806
- ...cargoPackagePlans.flatMap((plan) => plan.pieces.map((piece) => piece.targetName)),
1807
- // The root owns the serial groups' runners, so they take its build as its pieces do.
1808
- ...(ownsCargoWorkspaceTargets
1809
- ? cargoWorkspace.serialGroups.map((group) => cargoTestGroupTargetName(group.group))
1810
- : []),
1811
- ];
1812
- for (const name of runners) {
1813
- const target = targets[name];
1814
- if (target && !hasCargoTargetDependency(target.dependsOn ?? [], 'napi-debug')) {
1815
- target.dependsOn = [...(target.dependsOn ?? []), 'napi-debug'];
1816
- }
1817
- }
1818
- }
1819
- else if (napiDebug) {
1820
- const cargoTest = targets[CARGO_TEST_TARGET];
1821
- if (cargoTest?.options &&
1822
- typeof cargoTest.options.command === 'string' &&
1823
- cargoTest.options.command.startsWith('cargo ')) {
1824
- const dependsOn = cargoTest.dependsOn ?? [];
1825
- if (!dependsOn.includes('napi-debug')) {
1826
- cargoTest.dependsOn = [...dependsOn, 'napi-debug'];
1827
- }
1828
- }
1829
- }
1830
1877
  // The inferring host's own platform binaries join the aggregate `build`;
1831
1878
  // publish still owns foreign platforms.
1832
1879
  const hostPlatformBinaries = hostPlatformTargetNames([...Object.keys(declaredTargets), ...Object.keys(targets)], hostPlatform);
@@ -1980,6 +2027,15 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
1980
2027
  validationTargets.push(SHARD_TIMINGS_TARGET);
1981
2028
  }
1982
2029
  const { commands: lintCommands, inputs: lintProgramInputs, eslintFileSet, } = projectLintCommands(projectRoot, workspaceRoot, eslint);
2030
+ // The lint tools run from the root's node_modules/.bin, and ESLint loads the packages its configs name.
2031
+ const runsEslint = eslintFileSet !== null;
2032
+ const lintScopes = [
2033
+ ...bunLoadInput(rootManifests, [
2034
+ ...(runsEslint ? ['eslint'] : []),
2035
+ ...(lintCommands.some((command) => command.startsWith('biome ')) ? ['@biomejs/biome'] : []),
2036
+ ]).externalDependencies,
2037
+ ...(runsEslint ? (eslint?.configScopes ?? []) : []),
2038
+ ];
1983
2039
  // Every lint tool reaches its own verdict in one run: run-commands would end the
1984
2040
  // other tools once one fails, and their findings would surface a run later.
1985
2041
  if (validationTargets.length > 0 || lintCommands.length > 0) {
@@ -1999,6 +2055,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
1999
2055
  `{projectRoot}/${name}`,
2000
2056
  ]),
2001
2057
  ...(eslint?.configImports ?? []).map((path) => `{workspaceRoot}/${path}`),
2058
+ ...(lintScopes.length > 0 ? [bunScopeInput(projectRoot, lintScopes)] : []),
2002
2059
  ],
2003
2060
  ...(lintCommands.length > 0
2004
2061
  ? {
@@ -2025,28 +2082,82 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
2025
2082
  ];
2026
2083
  }
2027
2084
  }
2028
- // Runtime observers need the local addon, not the package aggregate (which can deliberately build only JS).
2029
- // Declarations retain these prerequisites and output inputs with Nx's ordinary "..." merge token.
2030
- // The canonical release-check instead judges prebuilt shipping artifacts and must remain dependency-free.
2031
- const observerProducers = [...nativeToolDependsOn(nativeTools, 'cowshed'), ...lineageProducer];
2032
- if (observerProducers.length > 0) {
2085
+ // The Darwin Node idle clock and the Cargo admission observer both load the local cowshed addon. They can fail
2086
+ // a run but do not change a passing command, so none keys its bytes (README, "Bounded exec key"). Declarations
2087
+ // retain these prerequisites with Nx's ordinary "..." merge token. The wall-only release-check judges already
2088
+ // built shipping artifacts and remains dependency-free.
2089
+ const addonProducers = [...nativeToolDependsOn(nativeTools, 'cowshed'), ...lineageProducer];
2090
+ if (addonProducers.length > 0) {
2033
2091
  for (const name of new Set([...Object.keys(targets), ...Object.keys(declaredTargets)])) {
2034
2092
  const declared = declaredTargets[name];
2035
2093
  const executor = isRecord(declared) && declared.executor !== undefined ? declared.executor : targets[name]?.executor;
2036
2094
  if (executor !== '@smoothbricks/nx-plugin:bounded-exec' || name === 'release-check')
2037
2095
  continue;
2038
- // Nx discards an incompatible executor's inferred configuration; only the observer prerequisites belong below it.
2096
+ const runs = [...targetOptionSets(declared), ...targetOptionSets(targets[name])];
2097
+ const needsAddon = runs.some((options) => runsAsCargoLeaf(boundedCommandLine(options) ?? '') ||
2098
+ (hostPlatform?.targetFamily === 'macos' && typeof options.idleTimeoutMs === 'number'));
2099
+ if (!needsAddon)
2100
+ continue;
2101
+ // Nx discards an incompatible executor's inferred configuration; only the runtime prerequisites belong below it.
2102
+ if (targets[name]?.executor !== undefined && targets[name]?.executor !== executor)
2103
+ targets[name] = {};
2104
+ targets[name] ??= {};
2105
+ const target = targets[name];
2106
+ target.dependsOn = [...(target.dependsOn ?? []), ...addonProducers];
2107
+ }
2108
+ }
2109
+ // The package's addon loader reads napi-debug's dev-profile addon when NAPI_DEBUG_ADDON=1 (createNapiTestTarget), so
2110
+ // a target whose run sets it, in its declaration or its inference, runs after that build and keys the addon it writes.
2111
+ if (targets['napi-debug'] !== undefined) {
2112
+ for (const name of new Set([...Object.keys(targets), ...Object.keys(declaredTargets)])) {
2113
+ const declared = declaredTargets[name];
2114
+ const runs = [...targetOptionSets(declared), ...targetOptionSets(targets[name])];
2115
+ if (!runs.some((options) => isRecord(options.env) && options.env.NAPI_DEBUG_ADDON === '1'))
2116
+ continue;
2117
+ const executor = isRecord(declared) && declared.executor !== undefined ? declared.executor : targets[name]?.executor;
2118
+ // Nx discards an incompatible executor's inferred configuration; only the addon prerequisite belongs below it.
2039
2119
  if (targets[name]?.executor !== undefined && targets[name]?.executor !== executor) {
2040
2120
  targets[name] = {};
2041
2121
  }
2042
2122
  targets[name] ??= {};
2043
2123
  const target = targets[name];
2044
- target.dependsOn = [...(target.dependsOn ?? []), ...observerProducers];
2124
+ const named = [
2125
+ ...(target.dependsOn ?? []),
2126
+ ...(isRecord(declared) && Array.isArray(declared.dependsOn) ? declared.dependsOn : []),
2127
+ ];
2128
+ if (!named.includes('napi-debug')) {
2129
+ target.dependsOn = [...(target.dependsOn ?? []), 'napi-debug'];
2130
+ }
2045
2131
  const inputs = target.inputs ?? (isRecord(declared) && Array.isArray(declared.inputs) ? [] : ['default', '^production']);
2046
- target.inputs = [
2047
- ...inputs,
2048
- { dependentTasksOutputFiles: '**/*.node', transitive: true },
2049
- { dependentTasksOutputFiles: '**/dist/lineage/**/*.js', transitive: true },
2132
+ target.inputs = [...inputs, { dependentTasksOutputFiles: '**/*.node', transitive: false }];
2133
+ }
2134
+ }
2135
+ // A plugin executor is a file the workspace plugin's own build writes, so a target that starts before that build
2136
+ // ends loads the dist a previous build left: one without the executors the plugin gained since (a Linux CLI
2137
+ // target failed "Could not resolve ./dist/executors/cargo-zigbuild/executor.js" in a checkout restored from a
2138
+ // cache that predated it). Every such target of every project but the plugin takes the one edge, so no executor
2139
+ // needs its own: the executors that build the plugin (the bootstrap ones) take none, the plugin's own targets
2140
+ // are ordered by its own graph, and release-check stays dependency-free (specs/cowshed/06_cli.md,
2141
+ // `release-check`). Declarations that replace `dependsOn` keep it with Nx's "..." token.
2142
+ if (packageJson.name !== '@smoothbricks/nx-plugin') {
2143
+ for (const name of new Set([...Object.keys(targets), ...Object.keys(declaredTargets)])) {
2144
+ if (name === 'release-check')
2145
+ continue;
2146
+ const declared = declaredTargets[name];
2147
+ const executor = isRecord(declared) && declared.executor !== undefined ? declared.executor : targets[name]?.executor;
2148
+ const edge = pluginBuildDependsOn(nativeTools, executor);
2149
+ if (edge.length === 0)
2150
+ continue;
2151
+ // Nx discards an incompatible executor's inferred configuration; only the edge belongs below it.
2152
+ if (targets[name]?.executor !== undefined && targets[name]?.executor !== executor) {
2153
+ targets[name] = {};
2154
+ }
2155
+ targets[name] ??= {};
2156
+ const target = targets[name];
2157
+ const present = new Set((target.dependsOn ?? []).map((dependency) => JSON.stringify(dependency)));
2158
+ target.dependsOn = [
2159
+ ...(target.dependsOn ?? []),
2160
+ ...edge.filter((dependency) => !present.has(JSON.stringify(dependency))),
2050
2161
  ];
2051
2162
  }
2052
2163
  }
@@ -2059,6 +2170,20 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
2059
2170
  target.metadata = { ...target.metadata, smooTaskKind: kind };
2060
2171
  }
2061
2172
  }
2173
+ // The inferred typecheck's compiler, named only where its command is the one inferred here: a declared typecheck
2174
+ // that runs another command runs something this inference does not know. Nx keeps the inferred command under a
2175
+ // declaration that names the same executor and no command, and replaces it under any other executor, under a
2176
+ // top-level `command` (its run-commands shorthand) or under `options.command`/`options.commands`.
2177
+ const declaredTypecheck = declaredTargets.typecheck;
2178
+ const declaredTypecheckOptions = isRecord(declaredTypecheck) ? declaredTypecheck.options : undefined;
2179
+ const typecheckCompilerInputs = targets.typecheck === undefined ||
2180
+ (isRecord(declaredTypecheck) &&
2181
+ ((declaredTypecheck.executor !== undefined && declaredTypecheck.executor !== targets.typecheck.executor) ||
2182
+ declaredTypecheck.command !== undefined)) ||
2183
+ (isRecord(declaredTypecheckOptions) &&
2184
+ (declaredTypecheckOptions.command !== undefined || declaredTypecheckOptions.commands !== undefined))
2185
+ ? []
2186
+ : typecheck.inputs;
2062
2187
  // A declared target REPLACES the inferred input list, pin included, so a
2063
2188
  // repository that hand-writes `inputs` for a cargo target silently loses its
2064
2189
  // toolchain identity. Name the identity once here so such a declaration can
@@ -2069,6 +2194,8 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
2069
2194
  // its configuration hash, so defining it everywhere would invalidate every
2070
2195
  // task in the repository to serve projects that can never reference it.
2071
2196
  const namedInputs = {
2197
+ [BUN_LOCK_SCOPE_NAMED_INPUT]: [bunLockInput(projectRoot)],
2198
+ ...(typecheckCompilerInputs.length === 0 ? {} : { [TYPECHECK_COMPILER_NAMED_INPUT]: [...typecheckCompilerInputs] }),
2072
2199
  ...(versionless === null
2073
2200
  ? {}
2074
2201
  : {
@@ -2143,7 +2270,8 @@ async function lockScopeNodes(projectRoot, inputLists, cargoWorkspaces) {
2143
2270
  }
2144
2271
  }
2145
2272
  const own = bunLockNode(projectRoot);
2146
- const nodes = { [own.name]: own };
2273
+ const runtime = bunLockRuntimeNode(projectRoot);
2274
+ const nodes = { [own.name]: own, [runtime.name]: runtime };
2147
2275
  for (const node of await Promise.all([...directories].map((directory) => cargoLockNode(directory, cargoSourcesUnder(directory, cargoWorkspaces))))) {
2148
2276
  nodes[node.name] = node;
2149
2277
  }
@@ -2333,58 +2461,9 @@ function createNapiTargets(projectRoot, config, hostPlatform, nativeTools, repoR
2333
2461
  };
2334
2462
  // The task that builds the executable recordInputs runs, when this workspace builds it.
2335
2463
  const buildInputsTool = nativeToolDependsOn(nativeTools, 'build-inputs');
2336
- const hasHostPlatformTarget = config.targets.some((triple) => {
2337
- const convention = NAPI_TARGET_CONVENTIONS[triple];
2338
- return convention !== undefined && sameNapiPlatform(convention, hostPlatform);
2339
- });
2464
+ const recordedInputs = [...(cargoInputs ?? []), ...buildInputsToolInputs(nativeTools)];
2340
2465
  const targets = {};
2341
- // The addon the test suite loads. A plain dev build shares target/debug with
2342
- // cargo-test's dependency graph, so after the tests compile this is nearly
2343
- // free, where a `--target <triple>` platform build compiles the graph again
2344
- // under target/<triple>/. The output lives OUTSIDE dist/ because packages
2345
- // publish `files: ["dist"]` wholesale: an addon the test run wrote under
2346
- // dist/ would ship in place of the release build. native.ts resolves this
2347
- // directory only when the napi-test target sets NAPI_DEBUG_ADDON=1, so
2348
- // production loads never see it.
2349
- targets['napi-debug'] = {
2350
- executor: 'nx:run-commands',
2351
- metadata: CARGO_PRODUCER_METADATA,
2352
- cache: true,
2353
- dependsOn: ['^build'],
2354
- inputs: cargoInputs,
2355
- outputs: ['{projectRoot}/.cache/native-debug/'],
2356
- options: {
2357
- cwd: cargoCwd,
2358
- command: `${napiCommand} build --platform --no-js --dts ${config.binaryName}.napi.d.ts ${commonCommand} --output-dir ${outputDir('.cache/native-debug')}`,
2359
- },
2360
- };
2361
- if (!hasHostPlatformTarget) {
2362
- // The platform target for this host triple is the same compilation, so a
2363
- // second cargo-napi invocation only buys a duplicate dependency graph
2364
- // (a plain build and a `--target` build write different target/
2365
- // subdirectories); native.ts already resolves the identical
2366
- // platform-suffixed filename from <tree>/<platform-dir> after <tree>/host,
2367
- // in the one tree its package's source authority selects (.cache/native-dev
2368
- // in a checkout, dist/native installed).
2369
- const hostBuild = (profile) => `${napiCommand} build${CARGO_PROFILE_FLAG[profile]} --platform --no-js --dts ${config.binaryName}.napi.d.ts ${commonCommand} --output-dir ${runOutputDirectory}${recordInputs(null, profile, runOutputDirectory)}`;
2370
- const hostOutputs = nativeOutputPaths('host');
2371
- targets['cargo-napi'] = {
2372
- executor: 'nx:run-commands',
2373
- metadata: CARGO_PRODUCER_METADATA,
2374
- cache: true,
2375
- dependsOn: ['^build', ...buildInputsTool],
2376
- inputs: cargoInputs,
2377
- outputs: [`{projectRoot}/${OUTPUT_DIR_OPTION}/`],
2378
- options: {
2379
- cwd: cargoCwd,
2380
- command: hostBuild('dev'),
2381
- outputDir: hostOutputs.dev,
2382
- },
2383
- configurations: {
2384
- [RELEASE_CONFIGURATION]: { command: hostBuild('release'), outputDir: hostOutputs.release },
2385
- },
2386
- };
2387
- }
2466
+ const debugDirectory = '.cache/native-debug';
2388
2467
  for (const triple of config.targets) {
2389
2468
  const convention = NAPI_TARGET_CONVENTIONS[triple];
2390
2469
  if (!convention) {
@@ -2392,12 +2471,33 @@ function createNapiTargets(projectRoot, config, hostPlatform, nativeTools, repoR
2392
2471
  }
2393
2472
  const targetName = `napi-${convention.architecture}-${convention.targetFamily}`;
2394
2473
  const outputs = nativeOutputPaths(convention.outputName);
2474
+ const fileName = `${config.binaryName}.${convention.outputName}.node`;
2475
+ if (sameNapiPlatform(convention, hostPlatform)) {
2476
+ const source = `${outputs.dev}/${fileName}`;
2477
+ const destination = `${debugDirectory}/${fileName}`;
2478
+ const staging = `${destination}.partial`;
2479
+ targets['napi-debug'] = {
2480
+ executor: 'nx:run-commands',
2481
+ cache: true,
2482
+ // An empty configuration selects the producer's default instead of inheriting `production` from the run.
2483
+ dependsOn: [{ target: targetName, configuration: '' }],
2484
+ inputs: [
2485
+ { externalDependencies: [] },
2486
+ { dependentTasksOutputFiles: posix.join(projectRoot, source), transitive: false },
2487
+ ],
2488
+ outputs: [`{projectRoot}/${destination}`],
2489
+ options: {
2490
+ cwd: projectRoot,
2491
+ command: `mkdir -p ${debugDirectory} && cp ${source} ${staging} && mv -f ${staging} ${destination}`,
2492
+ },
2493
+ };
2494
+ }
2395
2495
  if (convention.targetFamily === 'linux') {
2396
2496
  // Every host builds a Linux addon the same way: devenv's zig through
2397
2497
  // cargo-zigbuild, glibc pinned by the triple suffix. The napi CLI cannot
2398
2498
  // carry that suffix (it looks for the artifact under
2399
2499
  // target/<triple>.2.17/), so the executor names the `.node` itself.
2400
- const nodeFile = (directory) => `{projectRoot}/${directory}/${config.binaryName}.${convention.outputName}.node`;
2500
+ const nodeFile = (directory) => `{projectRoot}/${directory}/${fileName}`;
2401
2501
  targets[targetName] = {
2402
2502
  executor: '@smoothbricks/nx-plugin:cargo-zigbuild',
2403
2503
  metadata: CARGO_PRODUCER_METADATA,
@@ -2425,7 +2525,7 @@ function createNapiTargets(projectRoot, config, hostPlatform, nativeTools, repoR
2425
2525
  metadata: CARGO_PRODUCER_METADATA,
2426
2526
  cache: true,
2427
2527
  ...(buildInputsTool.length > 0 ? { dependsOn: buildInputsTool } : {}),
2428
- inputs: cargoInputs,
2528
+ inputs: recordedInputs,
2429
2529
  outputs: [`{projectRoot}/${OUTPUT_DIR_OPTION}/`],
2430
2530
  options: {
2431
2531
  cwd: cargoCwd,
@@ -2437,18 +2537,69 @@ function createNapiTargets(projectRoot, config, hostPlatform, nativeTools, repoR
2437
2537
  },
2438
2538
  };
2439
2539
  }
2540
+ if (!targets['napi-debug']) {
2541
+ // No declared platform target serves this host: retain the direct builds for both checkout consumers.
2542
+ targets['napi-debug'] = {
2543
+ executor: 'nx:run-commands',
2544
+ metadata: CARGO_PRODUCER_METADATA,
2545
+ cache: true,
2546
+ dependsOn: ['^build'],
2547
+ inputs: cargoInputs,
2548
+ outputs: [`{projectRoot}/${debugDirectory}/`],
2549
+ options: {
2550
+ cwd: cargoCwd,
2551
+ command: `${napiCommand} build --platform --no-js --dts ${config.binaryName}.napi.d.ts ${commonCommand} --output-dir ${outputDir(debugDirectory)}`,
2552
+ },
2553
+ };
2554
+ const hostBuild = (profile) => `${napiCommand} build${CARGO_PROFILE_FLAG[profile]} --platform --no-js --dts ${config.binaryName}.napi.d.ts ${commonCommand} --output-dir ${runOutputDirectory}${recordInputs(null, profile, runOutputDirectory)}`;
2555
+ const hostOutputs = nativeOutputPaths('host');
2556
+ targets['cargo-napi'] = {
2557
+ executor: 'nx:run-commands',
2558
+ metadata: CARGO_PRODUCER_METADATA,
2559
+ cache: true,
2560
+ dependsOn: ['^build', ...buildInputsTool],
2561
+ inputs: recordedInputs,
2562
+ outputs: [`{projectRoot}/${OUTPUT_DIR_OPTION}/`],
2563
+ options: {
2564
+ cwd: cargoCwd,
2565
+ command: hostBuild('dev'),
2566
+ outputDir: hostOutputs.dev,
2567
+ },
2568
+ configurations: {
2569
+ [RELEASE_CONFIGURATION]: { command: hostBuild('release'), outputDir: hostOutputs.release },
2570
+ },
2571
+ };
2572
+ }
2440
2573
  return targets;
2441
2574
  }
2575
+ /** A target's own options and each of its configurations' options, as one declaration or inference states them. */
2576
+ function targetOptionSets(target) {
2577
+ if (!isRecord(target))
2578
+ return [];
2579
+ const configurations = isRecord(target.configurations) ? Object.values(target.configurations) : [];
2580
+ return [target.options, ...configurations].filter(isRecord);
2581
+ }
2582
+ /** The command line a bounded-exec run with `options` starts (`boundedCommand`), or null when they name no command. */
2583
+ function boundedCommandLine(options) {
2584
+ const { command, args } = options;
2585
+ if (typeof command !== 'string')
2586
+ return null;
2587
+ return boundedCommand({
2588
+ command,
2589
+ args: typeof args === 'string'
2590
+ ? args
2591
+ : Array.isArray(args)
2592
+ ? args.filter((arg) => typeof arg === 'string')
2593
+ : undefined,
2594
+ });
2595
+ }
2442
2596
  function createNapiTestTarget(projectRoot, hasDedicatedBunfig) {
2443
2597
  const configFlag = hasDedicatedBunfig ? ' --config=../bunfig.napi-test.toml' : ' --config=../bunfig.toml';
2444
2598
  return {
2445
2599
  executor: '@smoothbricks/nx-plugin:bounded-exec',
2446
2600
  cache: true,
2447
- // Deliberately NOT `build`: the aggregate drags the host-platform binaries
2448
- // onto the test critical path, and a `--target <triple>` platform build
2449
- // compiles the whole graph again. tsc-js supplies dist/ts for the suite's
2450
- // own imports; napi-debug supplies the addon from the graph cargo-test
2451
- // already built.
2601
+ // Name only what the suite reads, not `build` with its unrelated host binaries.
2602
+ // tsc-js supplies dist/ts; napi-debug supplies the development addon.
2452
2603
  dependsOn: ['cargo-test', 'napi-debug', 'tsc-js', '^build'],
2453
2604
  options: {
2454
2605
  // cwd is src/, not the package root: `bun test <arg>` treats the arg as a
@@ -2643,10 +2794,10 @@ async function resolveCargoWorkspaces(packageJsonPaths, workspaceRoot, hostPlatf
2643
2794
  return [];
2644
2795
  // Started only once every workspace listed cleanly, so a listing that throws
2645
2796
  // leaves no Cargo process behind.
2646
- const indexedManifests = indexedCargoManifests(workspaceRoot);
2797
+ const indexedSources = indexedCargoSources(workspaceRoot);
2647
2798
  return Promise.all(found.map(async (workspace) => ({
2648
2799
  ...workspace,
2649
- closureSource: await resolveCargoClosureSource(posix.join(workspace.projectRoot, 'Cargo.toml'), workspaceRoot, indexedManifests, workspace.inputsCache.compiledInFiles),
2800
+ closureSource: await resolveCargoClosureSource(posix.join(workspace.projectRoot, 'Cargo.toml'), workspaceRoot, indexedSources, workspace.inputsCache.compiledInFiles),
2650
2801
  })));
2651
2802
  }
2652
2803
  /**
@@ -2775,6 +2926,7 @@ async function cargoTestRunnerInputs(workspaceRoot, workspace, memberDirs) {
2775
2926
  memberDir,
2776
2927
  cache: workspace.inputsCache,
2777
2928
  cargo: workspace.closureSource.cargo,
2929
+ sources: workspace.closureSource.sources,
2778
2930
  })));
2779
2931
  // The test build unifies every built package's manifest into every test binary, and a runner's key does not follow
2780
2932
  // the build's outputs, so each runner names them all: the ones Nx holds as files, the rest through the repository's
@@ -2822,7 +2974,7 @@ const NEXTEST_BINARIES_FIXTURE_TIMEOUT_MS = 3_600_000;
2822
2974
  * from the run's, and names the crates loudly when mbx had to compile (smoo-nx-nextest-binaries).
2823
2975
  */
2824
2976
  function nextestRunnerFixture(workspace, nativeTools) {
2825
- const helper = nativeToolCommand(nativeTools, workspace.projectRoot, 'nextest-extract', 'smoo-nx-nextest-binaries');
2977
+ const helper = nativeToolCommand(nativeTools, workspace.projectRoot, 'nextest-extract', NEXTEST_HELPER_BIN);
2826
2978
  return `${helper} ensure ${NEXTEST_BINARIES_METADATA} ${NEXTEST_BUILD_KEY} -- ${nextestBinariesBuild(nextestToolConfigArg(workspace.projectRoot))}`;
2827
2979
  }
2828
2980
  /**
@@ -2833,7 +2985,7 @@ function nextestRunnerFixture(workspace, nativeTools) {
2833
2985
  function nextestRunnerCommand(verb, workspace, nativeTools, selector, flags) {
2834
2986
  const toolConfig = nextestToolConfigArg(workspace.projectRoot);
2835
2987
  // Relative to the runner's cwd, so the hashed command is the same in every checkout.
2836
- const helper = nativeToolCommand(nativeTools, workspace.projectRoot, 'nextest-extract', 'smoo-nx-nextest-binaries');
2988
+ const helper = nativeToolCommand(nativeTools, workspace.projectRoot, 'nextest-extract', NEXTEST_HELPER_BIN);
2837
2989
  const reuseBuild = `--binaries-metadata ${NEXTEST_BINARIES_METADATA} --cargo-metadata ${NEXTEST_CARGO_METADATA} ` +
2838
2990
  `--target-dir-remap "$(${helper} target-dir)"`;
2839
2991
  return cargoFrozen(`nextest ${verb} ${reuseBuild} --workspace-remap . -E ${shellWord(selector)}${flags} --user-config-file none ${toolConfig}`);
@@ -2843,7 +2995,8 @@ function cargoTestRunnerTarget(workspace, nativeTools, build, inputs, piece) {
2843
2995
  return {
2844
2996
  executor: '@smoothbricks/nx-plugin:bounded-exec',
2845
2997
  cache: true,
2846
- inputs,
2998
+ // The command (`target-dir`) and the fixture (`ensure`) run the nextest helper.
2999
+ inputs: [...inputs, ...nextestHelperInputs(nativeTools)],
2847
3000
  dependsOn: [build, ...nativeToolDependsOn(nativeTools, 'nextest-extract')],
2848
3001
  options: {
2849
3002
  command: nextestRunnerCommand('run', workspace, nativeTools, piece.selector, `${piece.extra} --no-fail-fast --no-tests=pass`),
@@ -2869,7 +3022,7 @@ function cargoTestGroupTarget(workspace, nativeTools, inputs, group) {
2869
3022
  return {
2870
3023
  executor: '@smoothbricks/nx-plugin:bounded-exec',
2871
3024
  cache: true,
2872
- inputs: [...inputs, fileHashInput(PLUGIN_NEXTEST_CODE_BOUND)],
3025
+ inputs: [...inputs, fileHashInput(PLUGIN_NEXTEST_CODE_BOUND), ...nextestHelperInputs(nativeTools)],
2873
3026
  dependsOn: [CARGO_TEST_BUILD_TARGET, ...nativeToolDependsOn(nativeTools, 'nextest-extract')],
2874
3027
  options: {
2875
3028
  command: nextestRunnerCommand('run', workspace, nativeTools, group.filter, ' --no-fail-fast --no-tests=fail'),
@@ -2882,14 +3035,3 @@ function cargoTestGroupTarget(workspace, nativeTools, inputs, group) {
2882
3035
  },
2883
3036
  };
2884
3037
  }
2885
- function hasCargoTargetDependency(dependencies, expected) {
2886
- if (typeof expected === 'string') {
2887
- return dependencies.includes(expected);
2888
- }
2889
- return dependencies.some((dependency) => typeof dependency !== 'string' &&
2890
- dependency.target === expected.target &&
2891
- Array.isArray(dependency.projects) &&
2892
- Array.isArray(expected.projects) &&
2893
- dependency.projects.length === expected.projects.length &&
2894
- dependency.projects.every((project, index) => project === expected.projects?.[index]));
2895
- }