@nx/js 20.7.0 → 20.8.0-canary.20250402-2d210b8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/js",
3
- "version": "20.7.0",
3
+ "version": "20.8.0-canary.20250402-2d210b8",
4
4
  "private": false,
5
5
  "description": "The JS plugin for Nx contains executors and generators that provide the best experience for developing JavaScript and TypeScript projects. ",
6
6
  "repository": {
@@ -39,8 +39,8 @@
39
39
  "@babel/preset-env": "^7.23.2",
40
40
  "@babel/preset-typescript": "^7.22.5",
41
41
  "@babel/runtime": "^7.22.6",
42
- "@nx/devkit": "20.7.0",
43
- "@nx/workspace": "20.7.0",
42
+ "@nx/devkit": "20.8.0-canary.20250402-2d210b8",
43
+ "@nx/workspace": "20.8.0-canary.20250402-2d210b8",
44
44
  "@zkochan/js-yaml": "0.0.7",
45
45
  "babel-plugin-const-enum": "^1.0.1",
46
46
  "babel-plugin-macros": "^3.1.0",
@@ -147,7 +147,7 @@ async function getConfigFileHash(configFilePath, workspaceRoot, projectRoot, opt
147
147
  ...(packageJson ? [(0, file_hasher_1.hashObject)(packageJson)] : []),
148
148
  // change this to bust the cache when making changes that would yield
149
149
  // different results for the same hash
150
- (0, file_hasher_1.hashObject)({ bust: 1 }),
150
+ (0, file_hasher_1.hashObject)({ bust: 2 }),
151
151
  ]);
152
152
  }
153
153
  function checkIfConfigFileShouldBeProject(configFilePath, projectRoot, context) {
@@ -196,13 +196,27 @@ function buildTscTargets(configFilePath, projectRoot, options, context) {
196
196
  // `tsc --build` does not work with `noEmit: true`
197
197
  command = `echo "The 'typecheck' target is disabled because one or more project references set 'noEmit: true' in their tsconfig. Remove this property to resolve this issue."`;
198
198
  }
199
+ const dependsOn = [`^${targetName}`];
200
+ if (options.build && targets[options.build.targetName]) {
201
+ // we already processed and have a build target
202
+ dependsOn.unshift(options.build.targetName);
203
+ }
204
+ else if (options.build) {
205
+ // check if the project will have a build target
206
+ const buildConfigPath = (0, devkit_1.joinPathFragments)(projectRoot, options.build.configName);
207
+ if (context.configFiles.some((f) => f === buildConfigPath) &&
208
+ (0, util_1.isValidPackageJsonBuildConfig)(retrieveTsConfigFromCache(buildConfigPath, context.workspaceRoot), context.workspaceRoot, projectRoot)) {
209
+ dependsOn.unshift(options.build.targetName);
210
+ }
211
+ }
199
212
  targets[targetName] = {
200
- dependsOn: [`^${targetName}`],
213
+ dependsOn,
201
214
  command,
202
215
  options: { cwd: projectRoot },
203
216
  cache: true,
204
217
  inputs: getInputs(namedInputs, configFilePath, tsConfig, internalProjectReferences, context.workspaceRoot, projectRoot),
205
- outputs: getOutputs(configFilePath, tsConfig, internalProjectReferences, context.workspaceRoot, projectRoot),
218
+ outputs: getOutputs(configFilePath, tsConfig, internalProjectReferences, context.workspaceRoot, projectRoot,
219
+ /* emitDeclarationOnly */ true),
206
220
  syncGenerators: ['@nx/js:typescript-sync'],
207
221
  metadata: {
208
222
  technologies: ['typescript'],
@@ -229,7 +243,9 @@ function buildTscTargets(configFilePath, projectRoot, options, context) {
229
243
  options: { cwd: projectRoot },
230
244
  cache: true,
231
245
  inputs: getInputs(namedInputs, configFilePath, tsConfig, internalProjectReferences, context.workspaceRoot, projectRoot),
232
- outputs: getOutputs(configFilePath, tsConfig, internalProjectReferences, context.workspaceRoot, projectRoot),
246
+ outputs: getOutputs(configFilePath, tsConfig, internalProjectReferences, context.workspaceRoot, projectRoot,
247
+ // should be false for build target, but providing it just in case is set to true
248
+ tsConfig.options.emitDeclarationOnly),
233
249
  syncGenerators: ['@nx/js:typescript-sync'],
234
250
  metadata: {
235
251
  technologies: ['typescript'],
@@ -362,7 +378,7 @@ function getInputs(namedInputs, configFilePath, tsConfig, internalProjectReferen
362
378
  inputs.push({ externalDependencies });
363
379
  return inputs;
364
380
  }
365
- function getOutputs(configFilePath, tsConfig, internalProjectReferences, workspaceRoot, projectRoot) {
381
+ function getOutputs(configFilePath, tsConfig, internalProjectReferences, workspaceRoot, projectRoot, emitDeclarationOnly) {
366
382
  const outputs = new Set();
367
383
  // We could have more surgical outputs based on the tsconfig options, but the
368
384
  // user could override them through the command line and that wouldn't be
@@ -384,9 +400,18 @@ function getOutputs(configFilePath, tsConfig, internalProjectReferences, workspa
384
400
  : pathToInputOrOutput((0, devkit_1.joinPathFragments)(outDir, `${outFileName}.tsbuildinfo`), workspaceRoot, projectRoot));
385
401
  }
386
402
  else if (config.options.outDir) {
387
- outputs.add(pathToInputOrOutput(config.options.outDir, workspaceRoot, projectRoot));
403
+ if (emitDeclarationOnly) {
404
+ outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(config.options.outDir, '**/*.d.ts'), workspaceRoot, projectRoot));
405
+ if (tsConfig.options.declarationMap) {
406
+ outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(config.options.outDir, '**/*.d.ts.map'), workspaceRoot, projectRoot));
407
+ }
408
+ }
409
+ else {
410
+ outputs.add(pathToInputOrOutput(config.options.outDir, workspaceRoot, projectRoot));
411
+ }
388
412
  if (config.options.tsBuildInfoFile) {
389
- if (!(0, node_path_1.normalize)(config.options.tsBuildInfoFile).startsWith(`${(0, node_path_1.normalize)(config.options.outDir)}${node_path_1.sep}`)) {
413
+ if (emitDeclarationOnly ||
414
+ !(0, node_path_1.normalize)(config.options.tsBuildInfoFile).startsWith(`${(0, node_path_1.normalize)(config.options.outDir)}${node_path_1.sep}`)) {
390
415
  // https://www.typescriptlang.org/tsconfig#tsBuildInfoFile
391
416
  outputs.add(pathToInputOrOutput(config.options.tsBuildInfoFile, workspaceRoot, projectRoot));
392
417
  }
@@ -396,6 +421,11 @@ function getOutputs(configFilePath, tsConfig, internalProjectReferences, workspa
396
421
  const relativeRootDir = (0, node_path_1.relative)(config.options.rootDir, (0, node_path_1.join)(workspaceRoot, projectRoot));
397
422
  outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(config.options.outDir, relativeRootDir, `*.tsbuildinfo`), workspaceRoot, projectRoot));
398
423
  }
424
+ else if (emitDeclarationOnly) {
425
+ // https://www.typescriptlang.org/tsconfig#tsBuildInfoFile
426
+ const name = (0, node_path_1.basename)(configFilePath, '.json');
427
+ outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(config.options.outDir, `${name}.tsbuildinfo`), workspaceRoot, projectRoot));
428
+ }
399
429
  }
400
430
  else if (config.raw?.include?.length ||
401
431
  config.raw?.files?.length ||