@nx/js 0.0.0-pr-29464-b66c9d0 → 0.0.0-pr-11-e92ae29

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": "0.0.0-pr-29464-b66c9d0",
3
+ "version": "0.0.0-pr-11-e92ae29",
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": "0.0.0-pr-29464-b66c9d0",
43
- "@nx/workspace": "0.0.0-pr-29464-b66c9d0",
42
+ "@nx/devkit": "0.0.0-pr-11-e92ae29",
43
+ "@nx/workspace": "0.0.0-pr-11-e92ae29",
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",
@@ -52,11 +52,10 @@
52
52
  "ignore": "^5.0.4",
53
53
  "js-tokens": "^4.0.0",
54
54
  "jsonc-parser": "3.2.0",
55
+ "minimatch": "9.0.3",
55
56
  "npm-package-arg": "11.0.1",
56
57
  "npm-run-path": "^4.0.1",
57
58
  "ora": "5.3.0",
58
- "picocolors": "^1.1.0",
59
- "picomatch": "4.0.2",
60
59
  "semver": "^7.5.3",
61
60
  "source-map-support": "0.5.19",
62
61
  "tinyglobby": "^0.2.10",
@@ -298,7 +298,7 @@ function getFileToRun(context, project, buildOptions, buildTargetExecutor) {
298
298
  const outputFilePath = (0, utils_1.interpolate)(outputPath, {
299
299
  projectName: project.name,
300
300
  projectRoot: project.data.root,
301
- workspaceRoot: context.root,
301
+ workspaceRoot: '',
302
302
  });
303
303
  return path.join(outputFilePath, 'main.js');
304
304
  }
@@ -161,7 +161,7 @@ async function libraryGeneratorInternal(tree, schema) {
161
161
  async function configureProject(tree, options) {
162
162
  if (options.hasPlugin) {
163
163
  const nxJson = (0, devkit_1.readNxJson)(tree);
164
- (0, plugin_1.ensureProjectIsIncludedInPluginRegistrations)(nxJson, options.projectRoot, options.bundler === 'none' ? null : 'build');
164
+ (0, plugin_1.ensureProjectIsIncludedInPluginRegistrations)(nxJson, options.projectRoot);
165
165
  (0, devkit_1.updateNxJson)(tree, nxJson);
166
166
  }
167
167
  const projectConfiguration = {
@@ -719,7 +719,9 @@ function createProjectTsConfigs(tree, options) {
719
719
  .map(([k, v]) => `${JSON.stringify(k)}: ${JSON.stringify(v)}`)
720
720
  .join(',\n '),
721
721
  tmpl: '',
722
- outDir: 'dist',
722
+ outDir: options.bundler === 'tsc'
723
+ ? 'dist'
724
+ : `out-tsc/${options.projectRoot.split('/').pop()}`,
723
725
  emitDeclarationOnly: options.bundler === 'tsc' ? false : true,
724
726
  });
725
727
  // tsconfig.json
@@ -732,12 +734,6 @@ function createProjectTsConfigs(tree, options) {
732
734
  json.references.push({
733
735
  path: './tsconfig.lib.json',
734
736
  });
735
- // If using `tsc` to build, then we do not want a typecheck target that duplicates the work, since both run `tsc`.
736
- // This applies to `@nx/js/typescript` plugin only.
737
- if (options.bundler === 'tsc') {
738
- json['nx'] ??= {};
739
- json['nx'].addTypecheckTarget = false;
740
- }
741
737
  return json;
742
738
  });
743
739
  }
@@ -749,12 +745,6 @@ function createProjectTsConfigs(tree, options) {
749
745
  include: [],
750
746
  references: [{ path: './tsconfig.lib.json' }],
751
747
  };
752
- // If using `tsc` to build, then we do not want a typecheck target that duplicates the work, since both run `tsc`.
753
- // This applies to `@nx/js/typescript` plugin only.
754
- if (options.bundler === 'tsc') {
755
- tsconfig['nx'] ??= {};
756
- tsconfig['nx'].addTypecheckTarget = false;
757
- }
758
748
  (0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.json'), tsconfig);
759
749
  // update root project tsconfig.json references with the new lib tsconfig
760
750
  (0, devkit_1.updateJson)(tree, 'tsconfig.json', (json) => {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createNodes = exports.createNodesV2 = exports.PLUGIN_NAME = exports.createDependencies = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
6
- const picomatch = require("picomatch");
6
+ const minimatch_1 = require("minimatch");
7
7
  const node_fs_1 = require("node:fs");
8
8
  const node_path_1 = require("node:path");
9
9
  const posix = require("node:path/posix");
@@ -178,9 +178,7 @@ function buildTscTargets(configFilePath, projectRoot, options, context) {
178
178
  const tsConfig = retrieveTsConfigFromCache(configFilePath, context.workspaceRoot);
179
179
  let internalProjectReferences;
180
180
  // Typecheck target
181
- if ((0, node_path_1.basename)(configFilePath) === 'tsconfig.json' &&
182
- options.typecheck &&
183
- tsConfig.raw?.['nx']?.addTypecheckTarget !== false) {
181
+ if ((0, node_path_1.basename)(configFilePath) === 'tsconfig.json' && options.typecheck) {
184
182
  internalProjectReferences = resolveInternalProjectReferences(tsConfig, context.workspaceRoot, projectRoot);
185
183
  const externalProjectReferences = resolveShallowExternalProjectReferences(tsConfig, context.workspaceRoot, projectRoot);
186
184
  const targetName = options.typecheck.targetName;
@@ -278,8 +276,8 @@ function getInputs(namedInputs, configFilePath, tsConfig, internalProjectReferen
278
276
  });
279
277
  const normalize = (p) => (p.startsWith('./') ? p.slice(2) : p);
280
278
  config.raw.exclude.forEach((excludePath) => {
281
- if (!otherFilesInclude.some((includePath) => picomatch(normalize(excludePath))(normalize(includePath)) ||
282
- picomatch(normalize(includePath))(normalize(excludePath)))) {
279
+ if (!otherFilesInclude.some((includePath) => (0, minimatch_1.minimatch)(normalize(includePath), normalize(excludePath)) ||
280
+ (0, minimatch_1.minimatch)(normalize(excludePath), normalize(includePath)))) {
283
281
  excludePaths.add(excludePath);
284
282
  }
285
283
  });
@@ -556,7 +554,7 @@ function hasExternalProjectReferences(tsConfigPath, tsConfig, workspaceRoot, pro
556
554
  return false;
557
555
  }
558
556
  function isExternalProjectReference(refTsConfigPath, workspaceRoot, projectRoot) {
559
- const relativePath = posixRelative(workspaceRoot, refTsConfigPath);
557
+ const relativePath = posix.relative(workspaceRoot, refTsConfigPath);
560
558
  if (cache.isExternalProjectReference[relativePath] !== undefined) {
561
559
  return cache.isExternalProjectReference[relativePath];
562
560
  }
@@ -586,7 +584,7 @@ function getTsConfigDirName(tsConfigPath) {
586
584
  : (0, node_path_1.normalize)(tsConfigPath);
587
585
  }
588
586
  function retrieveTsConfigFromCache(tsConfigPath, workspaceRoot) {
589
- const relativePath = posixRelative(workspaceRoot, tsConfigPath);
587
+ const relativePath = posix.relative(workspaceRoot, tsConfigPath);
590
588
  // we don't need to check the hash if it's in the cache, because we've already
591
589
  // checked it when we initially populated the cache
592
590
  return tsConfigCache[relativePath]
@@ -602,7 +600,7 @@ function initializeTsConfigCache(configFilePaths, workspaceRoot) {
602
600
  }
603
601
  }
604
602
  function readTsConfigAndCache(tsConfigPath, workspaceRoot) {
605
- const relativePath = posixRelative(workspaceRoot, tsConfigPath);
603
+ const relativePath = posix.relative(workspaceRoot, tsConfigPath);
606
604
  const hash = getFileHash(tsConfigPath, workspaceRoot);
607
605
  let extendedFilesHash;
608
606
  if (tsConfigCache[relativePath] &&
@@ -718,7 +716,7 @@ function resolveExtendedTsConfigPath(tsConfigPath, directory) {
718
716
  }
719
717
  }
720
718
  function getFileHash(filePath, workspaceRoot) {
721
- const relativePath = posixRelative(workspaceRoot, filePath);
719
+ const relativePath = posix.relative(workspaceRoot, filePath);
722
720
  if (!cache.fileHashes[relativePath]) {
723
721
  const content = readFile(filePath, workspaceRoot);
724
722
  cache.fileHashes[relativePath] = (0, file_hasher_1.hashArray)([content]);
@@ -726,7 +724,7 @@ function getFileHash(filePath, workspaceRoot) {
726
724
  return cache.fileHashes[relativePath];
727
725
  }
728
726
  function readFile(filePath, workspaceRoot) {
729
- const relativePath = posixRelative(workspaceRoot, filePath);
727
+ const relativePath = posix.relative(workspaceRoot, filePath);
730
728
  if (!cache.rawFiles[relativePath]) {
731
729
  const content = (0, node_fs_1.readFileSync)(filePath, 'utf8');
732
730
  cache.rawFiles[relativePath] = content;
@@ -739,9 +737,6 @@ function toAbsolutePaths(cache, workspaceRoot) {
739
737
  updatedCache[key] = {
740
738
  data: {
741
739
  options: { noEmit: data.options.noEmit },
742
- raw: {
743
- nx: { addTypecheckTarget: data.raw?.['nx']?.addTypecheckTarget },
744
- },
745
740
  extendedConfigFile: data.extendedConfigFile,
746
741
  },
747
742
  extendedFilesHash,
@@ -774,38 +769,29 @@ function toRelativePaths(cache, workspaceRoot) {
774
769
  updatedCache[key] = {
775
770
  data: {
776
771
  options: { noEmit: data.options.noEmit },
777
- raw: {
778
- nx: { addTypecheckTarget: data.raw?.['nx']?.addTypecheckTarget },
779
- },
780
772
  extendedConfigFile: data.extendedConfigFile,
781
773
  },
782
774
  extendedFilesHash,
783
775
  hash,
784
776
  };
785
777
  if (data.options.rootDir) {
786
- updatedCache[key].data.options.rootDir = posixRelative(workspaceRoot, data.options.rootDir);
778
+ updatedCache[key].data.options.rootDir = posix.relative(workspaceRoot, data.options.rootDir);
787
779
  }
788
780
  if (data.options.outDir) {
789
- updatedCache[key].data.options.outDir = posixRelative(workspaceRoot, data.options.outDir);
781
+ updatedCache[key].data.options.outDir = posix.relative(workspaceRoot, data.options.outDir);
790
782
  }
791
783
  if (data.options.outFile) {
792
- updatedCache[key].data.options.outFile = posixRelative(workspaceRoot, data.options.outFile);
784
+ updatedCache[key].data.options.outFile = posix.relative(workspaceRoot, data.options.outFile);
793
785
  }
794
786
  if (data.options.tsBuildInfoFile) {
795
- updatedCache[key].data.options.tsBuildInfoFile = posixRelative(workspaceRoot, data.options.tsBuildInfoFile);
787
+ updatedCache[key].data.options.tsBuildInfoFile = posix.relative(workspaceRoot, data.options.tsBuildInfoFile);
796
788
  }
797
789
  if (data.extendedConfigFile?.filePath) {
798
- updatedCache[key].data.extendedConfigFile.filePath = posixRelative(workspaceRoot, data.extendedConfigFile.filePath);
790
+ updatedCache[key].data.extendedConfigFile.filePath = posix.relative(workspaceRoot, data.extendedConfigFile.filePath);
799
791
  }
800
792
  if (data.projectReferences) {
801
- updatedCache[key].data.projectReferences = data.projectReferences.map((ref) => ({
802
- ...ref,
803
- path: posixRelative(workspaceRoot, ref.path),
804
- }));
793
+ updatedCache[key].data.projectReferences = data.projectReferences.map((ref) => ({ ...ref, path: posix.relative(workspaceRoot, ref.path) }));
805
794
  }
806
795
  }
807
796
  return updatedCache;
808
797
  }
809
- function posixRelative(workspaceRoot, path) {
810
- return posix.normalize((0, node_path_1.relative)(workspaceRoot, path));
811
- }
@@ -27,6 +27,7 @@ function addBuildAndWatchDepsTargets(workspaceRoot, projectRoot, targets, option
27
27
  dependsOn: ['^build'],
28
28
  };
29
29
  targets[options.watchDepsTargetName ?? 'watch-deps'] = {
30
+ continuous: true,
30
31
  dependsOn: [buildDepsTargetName],
31
32
  command: `${pmc.exec} nx watch --projects ${projectName} --includeDependentProjects -- ${pmc.exec} nx ${buildDepsTargetName} ${projectName}`,
32
33
  };
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CopyAssetsHandler = exports.defaultFileEventHandler = void 0;
4
- const picomatch = require("picomatch");
4
+ const minimatch_1 = require("minimatch");
5
5
  const node_fs_1 = require("node:fs");
6
6
  const pathPosix = require("node:path/posix");
7
7
  const path = require("node:path");
@@ -9,7 +9,6 @@ const ignore_1 = require("ignore");
9
9
  const tinyglobby_1 = require("tinyglobby");
10
10
  const devkit_1 = require("@nx/devkit");
11
11
  const client_1 = require("nx/src/daemon/client/client");
12
- const picocolors_1 = require("picocolors");
13
12
  const defaultFileEventHandler = (events) => {
14
13
  const dirs = new Set(events.map((event) => path.dirname(event.dest)));
15
14
  dirs.forEach((d) => (0, node_fs_1.mkdirSync)(d, { recursive: true }));
@@ -25,9 +24,6 @@ const defaultFileEventHandler = (events) => {
25
24
  else {
26
25
  devkit_1.logger.error(`Unknown file event: ${event.type}`);
27
26
  }
28
- const eventDir = path.dirname(event.src);
29
- const relativeDest = path.relative(eventDir, event.dest);
30
- devkit_1.logger.log(`\n${(0, picocolors_1.dim)(relativeDest)}`);
31
27
  });
32
28
  };
33
29
  exports.defaultFileEventHandler = defaultFileEventHandler;
@@ -119,12 +115,10 @@ class CopyAssetsHandler {
119
115
  async processWatchEvents(events) {
120
116
  const fileEvents = [];
121
117
  for (const event of events) {
122
- const pathFromRoot = event.path.startsWith(this.rootDir)
123
- ? path.relative(this.rootDir, event.path)
124
- : event.path;
118
+ const pathFromRoot = path.relative(this.rootDir, event.path);
125
119
  for (const ag of this.assetGlobs) {
126
- if (picomatch(ag.pattern)(pathFromRoot) &&
127
- !ag.ignore?.some((ig) => picomatch(ig)(pathFromRoot)) &&
120
+ if ((0, minimatch_1.minimatch)(pathFromRoot, ag.pattern) &&
121
+ !ag.ignore?.some((ig) => (0, minimatch_1.minimatch)(pathFromRoot, ig)) &&
128
122
  !this.ignore.ignores(pathFromRoot)) {
129
123
  const relPath = path.relative(ag.input, pathFromRoot);
130
124
  const destPath = relPath.startsWith('..') ? pathFromRoot : relPath;
@@ -143,7 +137,7 @@ class CopyAssetsHandler {
143
137
  }
144
138
  filesToEvent(files, assetGlob) {
145
139
  return files.reduce((acc, src) => {
146
- if (!assetGlob.ignore?.some((ig) => picomatch(ig)(src)) &&
140
+ if (!assetGlob.ignore?.some((ig) => (0, minimatch_1.minimatch)(src, ig)) &&
147
141
  !this.ignore.ignores(src)) {
148
142
  const relPath = path.relative(assetGlob.input, src);
149
143
  const dest = relPath.startsWith('..') ? src : relPath;
@@ -16,8 +16,6 @@ const fileutils_1 = require("nx/src/utils/fileutils");
16
16
  const output_1 = require("nx/src/utils/output");
17
17
  const path_1 = require("path");
18
18
  const ts_config_1 = require("./typescript/ts-config");
19
- const crypto_1 = require("crypto");
20
- const project_graph_1 = require("nx/src/config/project-graph");
21
19
  function isBuildable(target, node) {
22
20
  return (node.data.targets &&
23
21
  node.data.targets[target] &&
@@ -50,7 +48,7 @@ function calculateProjectDependencies(projGraph, root, projectName, targetName,
50
48
  .map(({ name: dep, isTopLevel }) => {
51
49
  let project = null;
52
50
  const depNode = projGraph.nodes[dep] || projGraph.externalNodes[dep];
53
- if ((0, project_graph_1.isProjectGraphProjectNode)(depNode) && depNode.type === 'lib') {
51
+ if (depNode.type === 'lib') {
54
52
  if (isBuildable(targetName, depNode)) {
55
53
  const libPackageJsonPath = (0, path_1.join)(root, depNode.data.root, 'package.json');
56
54
  project = {
@@ -69,7 +67,7 @@ function calculateProjectDependencies(projGraph, root, projectName, targetName,
69
67
  nonBuildableDependencies.push(dep);
70
68
  }
71
69
  }
72
- else if ((0, project_graph_1.isProjectGraphExternalNode)(depNode)) {
70
+ else if (depNode.type === 'npm') {
73
71
  project = {
74
72
  name: depNode.data.packageName,
75
73
  outputs: [],
@@ -231,7 +229,7 @@ function computeCompilerOptionsPaths(tsConfig, dependencies) {
231
229
  return paths;
232
230
  }
233
231
  function createTmpTsConfig(tsconfigPath, workspaceRoot, projectRoot, dependencies, useWorkspaceAsBaseUrl = false) {
234
- const tmpTsConfigPath = (0, path_1.join)(workspaceRoot, 'tmp', projectRoot, process.env.NX_TASK_TARGET_TARGET ?? 'build', `tsconfig.generated.${(0, crypto_1.randomUUID)()}.json`);
232
+ const tmpTsConfigPath = (0, path_1.join)(workspaceRoot, 'tmp', projectRoot, process.env.NX_TASK_TARGET_TARGET ?? 'build', 'tsconfig.generated.json');
235
233
  if (tsconfigPath === tmpTsConfigPath) {
236
234
  return tsconfigPath;
237
235
  }
@@ -285,9 +283,10 @@ function findMissingBuildDependencies(root, projectName, targetName, projectDepe
285
283
  function updatePaths(dependencies, paths) {
286
284
  const pathsKeys = Object.keys(paths);
287
285
  // For each registered dependency
288
- dependencies
289
- .filter((dep) => (0, project_graph_1.isProjectGraphProjectNode)(dep.node))
290
- .forEach((dep) => {
286
+ dependencies.forEach((dep) => {
287
+ if (dep.node.type === 'npm') {
288
+ return;
289
+ }
291
290
  // If there are outputs
292
291
  if (dep.outputs && dep.outputs.length > 0) {
293
292
  // Directly map the dependency name to the output paths (dist/packages/..., etc.)
@@ -351,8 +350,7 @@ function updateBuildableProjectPackageJsonDependencies(root, projectName, target
351
350
  !hasDependency(packageJson, 'peerDependencies', packageName)) {
352
351
  try {
353
352
  let depVersion;
354
- if ((0, project_graph_1.isProjectGraphProjectNode)(entry.node) &&
355
- entry.node.type === 'lib') {
353
+ if (entry.node.type === 'lib') {
356
354
  const outputs = (0, devkit_1.getOutputsForTargetAndConfiguration)({
357
355
  project: projectName,
358
356
  target: targetName,
@@ -5,7 +5,7 @@ exports.isUsingPackageManagerWorkspaces = isUsingPackageManagerWorkspaces;
5
5
  exports.isWorkspacesEnabled = isWorkspacesEnabled;
6
6
  exports.getProjectPackageManagerWorkspaceStateWarningTask = getProjectPackageManagerWorkspaceStateWarningTask;
7
7
  const devkit_1 = require("@nx/devkit");
8
- const picomatch = require("picomatch");
8
+ const minimatch_1 = require("minimatch");
9
9
  const posix_1 = require("node:path/posix");
10
10
  const package_json_1 = require("nx/src/plugins/package-json");
11
11
  const semver_1 = require("semver");
@@ -13,18 +13,17 @@ function getProjectPackageManagerWorkspaceState(tree, projectRoot) {
13
13
  if (!isUsingPackageManagerWorkspaces(tree)) {
14
14
  return 'no-workspaces';
15
15
  }
16
- const patterns = (0, package_json_1.getGlobPatternsFromPackageManagerWorkspaces)(tree.root, (path) => (0, devkit_1.readJson)(tree, path, { expectComments: true }), (path) => {
17
- const content = tree.read(path, 'utf-8');
18
- const { load } = require('@zkochan/js-yaml');
19
- return load(content, { filename: path });
20
- }, (path) => tree.exists(path));
21
- const isIncluded = patterns.some((p) => picomatch(p)((0, posix_1.join)(projectRoot, 'package.json')));
16
+ const patterns = (0, package_json_1.getGlobPatternsFromPackageManagerWorkspaces)(tree.root, (path) => (0, devkit_1.readJson)(tree, path, { expectComments: true }));
17
+ const isIncluded = patterns.some((p) => (0, minimatch_1.minimatch)((0, posix_1.join)(projectRoot, 'package.json'), p));
22
18
  return isIncluded ? 'included' : 'excluded';
23
19
  }
24
20
  function isUsingPackageManagerWorkspaces(tree) {
25
21
  return isWorkspacesEnabled(tree);
26
22
  }
27
- function isWorkspacesEnabled(tree) {
23
+ function isWorkspacesEnabled(tree
24
+ // packageManager: PackageManager = detectPackageManager(),
25
+ // root: string = workspaceRoot
26
+ ) {
28
27
  const packageManager = (0, devkit_1.detectPackageManager)(tree.root);
29
28
  if (packageManager === 'pnpm') {
30
29
  return tree.exists('pnpm-workspace.yaml');
@@ -1,3 +1,3 @@
1
1
  import type { NxJsonConfiguration } from '@nx/devkit';
2
- export declare function ensureProjectIsIncludedInPluginRegistrations(nxJson: NxJsonConfiguration, projectRoot: string, buildTargetName: string | null): void;
2
+ export declare function ensureProjectIsIncludedInPluginRegistrations(nxJson: NxJsonConfiguration, projectRoot: string, buildTargetName?: string): void;
3
3
  export declare function ensureProjectIsExcludedFromPluginRegistrations(nxJson: NxJsonConfiguration, projectRoot: string): void;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ensureProjectIsIncludedInPluginRegistrations = ensureProjectIsIncludedInPluginRegistrations;
4
4
  exports.ensureProjectIsExcludedFromPluginRegistrations = ensureProjectIsExcludedFromPluginRegistrations;
5
5
  const devkit_internals_1 = require("nx/src/devkit-internals");
6
- function ensureProjectIsIncludedInPluginRegistrations(nxJson, projectRoot, buildTargetName) {
6
+ function ensureProjectIsIncludedInPluginRegistrations(nxJson, projectRoot, buildTargetName = 'build') {
7
7
  nxJson.plugins ??= [];
8
8
  let isIncluded = false;
9
9
  let index = 0;
@@ -13,17 +13,12 @@ function ensureProjectIsIncludedInPluginRegistrations(nxJson, projectRoot, build
13
13
  continue;
14
14
  }
15
15
  if (typeof registration === 'string') {
16
- if (buildTargetName) {
17
- // if it's a string all projects are included but the are no user-specified options
18
- // and the build task is not inferred by default, so we need to exclude it
19
- nxJson.plugins[index] = {
20
- plugin: '@nx/js/typescript',
21
- exclude: [`${projectRoot}/*`],
22
- };
23
- }
24
- else {
25
- isIncluded = true;
26
- }
16
+ // if it's a string all projects are included but the are no user-specified options
17
+ // and the build task is not inferred by default, so we need to exclude it
18
+ nxJson.plugins[index] = {
19
+ plugin: '@nx/js/typescript',
20
+ exclude: [`${projectRoot}/*`],
21
+ };
27
22
  }
28
23
  else {
29
24
  // check if the project would be included by the plugin registration
@@ -32,7 +27,7 @@ function ensureProjectIsIncludedInPluginRegistrations(nxJson, projectRoot, build
32
27
  // it's included by the plugin registration, check if the user-specified options would result
33
28
  // in the appropriate build task being inferred, if not, we need to exclude it
34
29
  if (registration.options?.typecheck !== false &&
35
- matchesBuildTargetDefinition(registration.options?.build, buildTargetName)) {
30
+ matchesBuildTarget(registration.options?.build, buildTargetName)) {
36
31
  // it has the desired options, do nothing, but continue processing
37
32
  // other registrations to exclude as needed
38
33
  isIncluded = true;
@@ -45,7 +40,7 @@ function ensureProjectIsIncludedInPluginRegistrations(nxJson, projectRoot, build
45
40
  }
46
41
  else if (!isIncluded &&
47
42
  registration.options?.typecheck !== false &&
48
- matchesBuildTargetDefinition(registration.options?.build, buildTargetName)) {
43
+ matchesBuildTarget(registration.options?.build, buildTargetName)) {
49
44
  if (!registration.exclude?.length) {
50
45
  // negative pattern are not supported by the `exclude` option so we
51
46
  // can't update it to not exclude the project, so we only update the
@@ -71,20 +66,17 @@ function ensureProjectIsIncludedInPluginRegistrations(nxJson, projectRoot, build
71
66
  if (!isIncluded) {
72
67
  // the project is not included by any plugin registration with an inferred build task
73
68
  // with the given name, so we create a new plugin registration for it
74
- const registration = {
69
+ nxJson.plugins.push({
75
70
  plugin: '@nx/js/typescript',
76
71
  include: [`${projectRoot}/*`],
77
72
  options: {
78
73
  typecheck: { targetName: 'typecheck' },
74
+ build: {
75
+ targetName: buildTargetName,
76
+ configName: 'tsconfig.lib.json',
77
+ },
79
78
  },
80
- };
81
- if (buildTargetName) {
82
- registration.options.build = {
83
- targetName: buildTargetName,
84
- configName: 'tsconfig.lib.json',
85
- };
86
- }
87
- nxJson.plugins.push(registration);
79
+ });
88
80
  }
89
81
  }
90
82
  function ensureProjectIsExcludedFromPluginRegistrations(nxJson, projectRoot) {
@@ -123,11 +115,8 @@ function isTypeScriptPluginRegistration(plugin) {
123
115
  return ((typeof plugin === 'string' && plugin === '@nx/js/typescript') ||
124
116
  (typeof plugin !== 'string' && plugin.plugin === '@nx/js/typescript'));
125
117
  }
126
- function matchesBuildTargetDefinition(buildOptions, buildTargetName) {
118
+ function matchesBuildTarget(buildOptions, buildTargetName) {
127
119
  if (buildOptions === undefined || buildOptions === false) {
128
- return !buildTargetName;
129
- }
130
- if (!buildTargetName) {
131
120
  return false;
132
121
  }
133
122
  if (buildOptions === true && buildTargetName === 'build') {
@@ -90,7 +90,9 @@ function updateTsconfigFiles(tree, projectRoot, runtimeTsconfigFileName, compile
90
90
  json.extends = (0, devkit_1.joinPathFragments)(offset, 'tsconfig.base.json');
91
91
  json.compilerOptions = {
92
92
  ...json.compilerOptions,
93
- outDir: 'dist',
93
+ // Make sure d.ts files from typecheck does not conflict with bundlers.
94
+ // Other tooling like jest write to "out-tsc/jest" to we just default to "out-tsc/<project-name>".
95
+ outDir: (0, devkit_1.joinPathFragments)('out-tsc', projectRoot.split('/').at(-1)),
94
96
  rootDir,
95
97
  ...compilerOptions,
96
98
  };
@@ -144,10 +146,6 @@ function updateTsconfigFiles(tree, projectRoot, runtimeTsconfigFileName, compile
144
146
  }
145
147
  }
146
148
  function addProjectToTsSolutionWorkspace(tree, projectDir) {
147
- const state = (0, package_manager_workspaces_1.getProjectPackageManagerWorkspaceState)(tree, projectDir);
148
- if (state === 'included') {
149
- return;
150
- }
151
149
  // If dir is "libs/foo" then use "libs/*" so we don't need so many entries in the workspace file.
152
150
  // If dir is nested like "libs/shared/foo" then we add "libs/shared/*".
153
151
  // If the dir is just "foo" then we have to add it as is.