@nx/js 0.0.0-pr-29464-73fdcbb → 0.0.0-pr-30565-cfe2164

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/migrations.json CHANGED
@@ -146,15 +146,6 @@
146
146
  "alwaysAddToPackageJson": false
147
147
  }
148
148
  }
149
- },
150
- "20.7.1-beta.0": {
151
- "version": "20.7.1-beta.0",
152
- "packages": {
153
- "@swc/cli": {
154
- "version": "~0.6.0",
155
- "alwaysAddToPackageJson": false
156
- }
157
- }
158
149
  }
159
150
  }
160
151
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/js",
3
- "version": "0.0.0-pr-29464-73fdcbb",
3
+ "version": "0.0.0-pr-30565-cfe2164",
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-73fdcbb",
43
- "@nx/workspace": "0.0.0-pr-29464-73fdcbb",
42
+ "@nx/devkit": "0.0.0-pr-30565-cfe2164",
43
+ "@nx/workspace": "0.0.0-pr-30565-cfe2164",
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",
@@ -60,6 +60,8 @@
60
60
  "semver": "^7.5.3",
61
61
  "source-map-support": "0.5.19",
62
62
  "tinyglobby": "^0.2.12",
63
+ "ts-node": "10.9.1",
64
+ "tsconfig-paths": "^4.1.2",
63
65
  "tslib": "^2.3.0"
64
66
  },
65
67
  "peerDependencies": {
@@ -17,7 +17,6 @@
17
17
  "noUnusedLocals": true,
18
18
  "skipLibCheck": true,
19
19
  "strict": true,
20
- "target": "es2022",
21
- "customConditions": ["development"]
20
+ "target": "es2022"
22
21
  }
23
22
  }
@@ -425,8 +425,6 @@ function createFiles(tree, options) {
425
425
  };
426
426
  if (options.isUsingTsSolutionConfig &&
427
427
  !['none', 'rollup', 'vite'].includes(options.bundler)) {
428
- // the file must exist in the TS solution setup
429
- const tsconfigBase = (0, devkit_1.readJson)(tree, 'tsconfig.base.json');
430
428
  return (0, update_package_json_1.getUpdatedPackageJsonContent)(updatedPackageJson, {
431
429
  main: (0, path_1.join)(options.projectRoot, 'src/index.ts'),
432
430
  outputPath: (0, devkit_1.joinPathFragments)(options.projectRoot, 'dist'),
@@ -435,7 +433,6 @@ function createFiles(tree, options) {
435
433
  generateExportsField: true,
436
434
  packageJsonPath,
437
435
  format: ['esm'],
438
- skipDevelopmentExports: !tsconfigBase.compilerOptions?.customConditions?.includes('development'),
439
436
  });
440
437
  }
441
438
  return updatedPackageJson;
@@ -458,7 +455,6 @@ function createFiles(tree, options) {
458
455
  }
459
456
  if (options.isUsingTsSolutionConfig &&
460
457
  !['none', 'rollup', 'vite'].includes(options.bundler)) {
461
- const tsconfigBase = (0, devkit_1.readJson)(tree, 'tsconfig.base.json');
462
458
  packageJson = (0, update_package_json_1.getUpdatedPackageJsonContent)(packageJson, {
463
459
  main: (0, path_1.join)(options.projectRoot, 'src/index.ts'),
464
460
  outputPath: (0, devkit_1.joinPathFragments)(options.projectRoot, 'dist'),
@@ -467,7 +463,6 @@ function createFiles(tree, options) {
467
463
  generateExportsField: true,
468
464
  packageJsonPath,
469
465
  format: ['esm'],
470
- skipDevelopmentExports: !tsconfigBase.compilerOptions?.customConditions?.includes('development'),
471
466
  });
472
467
  }
473
468
  if (!options.useProjectJson && options.name !== options.importPath) {
@@ -737,6 +732,12 @@ function createProjectTsConfigs(tree, options) {
737
732
  json.references.push({
738
733
  path: './tsconfig.lib.json',
739
734
  });
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
+ }
740
741
  return json;
741
742
  });
742
743
  }
@@ -748,6 +749,12 @@ function createProjectTsConfigs(tree, options) {
748
749
  include: [],
749
750
  references: [{ path: './tsconfig.lib.json' }],
750
751
  };
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
+ }
751
758
  (0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.json'), tsconfig);
752
759
  // update root project tsconfig.json references with the new lib tsconfig
753
760
  (0, devkit_1.updateJson)(tree, 'tsconfig.json', (json) => {
@@ -232,9 +232,6 @@ function updatePackageJson(tree, projectName, projectRoot, main, outputPath, roo
232
232
  version: '0.0.1',
233
233
  };
234
234
  }
235
- // the file must exist in the TS solution setup, which is the only case this
236
- // function is called
237
- const tsconfigBase = (0, devkit_1.readJson)(tree, 'tsconfig.base.json');
238
235
  packageJson = (0, update_package_json_1.getUpdatedPackageJsonContent)(packageJson, {
239
236
  main,
240
237
  outputPath,
@@ -243,7 +240,6 @@ function updatePackageJson(tree, projectName, projectRoot, main, outputPath, roo
243
240
  packageJsonPath,
244
241
  rootDir,
245
242
  format,
246
- skipDevelopmentExports: !tsconfigBase.compilerOptions?.customConditions?.includes('development'),
247
243
  });
248
244
  (0, devkit_1.writeJson)(tree, packageJsonPath, packageJson);
249
245
  }
@@ -29,21 +29,17 @@ function startLocalRegistry({ localRegistryTarget, storage, verbose, clearStorag
29
29
  const port = parseInt(data.toString().match(new RegExp(`${listenAddress}:(?<port>\\d+)`))
30
30
  ?.groups?.port);
31
31
  const registry = `http://${listenAddress}:${port}`;
32
- const authToken = 'secretVerdaccioToken';
33
32
  console.log(`Local registry started on ${registry}`);
34
33
  process.env.npm_config_registry = registry;
35
- (0, child_process_1.execSync)(`npm config set //${listenAddress}:${port}/:_authToken "${authToken}" --ws=false`, {
34
+ (0, child_process_1.execSync)(`npm config set //${listenAddress}:${port}/:_authToken "secretVerdaccioToken" --ws=false`, {
36
35
  windowsHide: false,
37
36
  });
38
- // bun
39
- process.env.BUN_CONFIG_REGISTRY = registry;
40
- process.env.BUN_CONFIG_TOKEN = authToken;
41
37
  // yarnv1
42
38
  process.env.YARN_REGISTRY = registry;
43
39
  // yarnv2
44
40
  process.env.YARN_NPM_REGISTRY_SERVER = registry;
45
41
  process.env.YARN_UNSAFE_HTTP_WHITELIST = listenAddress;
46
- console.log('Set npm, bun, and yarn config registry to ' + registry);
42
+ console.log('Set npm and yarn config registry to ' + registry);
47
43
  resolve(() => {
48
44
  childProcess.kill();
49
45
  (0, child_process_1.execSync)(`npm config delete //${listenAddress}:${port}/:_authToken --ws=false`, {
@@ -3,16 +3,15 @@ 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
7
  const node_fs_1 = require("node:fs");
7
8
  const node_path_1 = require("node:path");
8
9
  const posix = require("node:path/posix");
9
10
  const file_hasher_1 = require("nx/src/hasher/file-hasher");
10
- const picomatch = require("picomatch");
11
11
  // eslint-disable-next-line @typescript-eslint/no-restricted-imports
12
12
  const lock_file_1 = require("nx/src/plugins/js/lock-file/lock-file");
13
13
  const cache_directory_1 = require("nx/src/utils/cache-directory");
14
14
  const util_1 = require("./util");
15
- let ts;
16
15
  const pmc = (0, devkit_1.getPackageManagerCommand)();
17
16
  let tsConfigCache;
18
17
  const tsConfigCachePath = (0, node_path_1.join)(cache_directory_1.workspaceDataDirectory, 'tsconfig-files.hash');
@@ -145,9 +144,6 @@ async function getConfigFileHash(configFilePath, workspaceRoot, projectRoot, opt
145
144
  lockFileHash,
146
145
  optionsHash,
147
146
  ...(packageJson ? [(0, file_hasher_1.hashObject)(packageJson)] : []),
148
- // change this to bust the cache when making changes that would yield
149
- // different results for the same hash
150
- (0, file_hasher_1.hashObject)({ bust: 2 }),
151
147
  ]);
152
148
  }
153
149
  function checkIfConfigFileShouldBeProject(configFilePath, projectRoot, context) {
@@ -196,27 +192,13 @@ function buildTscTargets(configFilePath, projectRoot, options, context) {
196
192
  // `tsc --build` does not work with `noEmit: true`
197
193
  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
194
  }
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
- }
212
195
  targets[targetName] = {
213
- dependsOn,
196
+ dependsOn: [`^${targetName}`],
214
197
  command,
215
198
  options: { cwd: projectRoot },
216
199
  cache: true,
217
200
  inputs: getInputs(namedInputs, configFilePath, tsConfig, internalProjectReferences, context.workspaceRoot, projectRoot),
218
- outputs: getOutputs(configFilePath, tsConfig, internalProjectReferences, context.workspaceRoot, projectRoot,
219
- /* emitDeclarationOnly */ true),
201
+ outputs: getOutputs(configFilePath, tsConfig, internalProjectReferences, context.workspaceRoot, projectRoot),
220
202
  syncGenerators: ['@nx/js:typescript-sync'],
221
203
  metadata: {
222
204
  technologies: ['typescript'],
@@ -243,9 +225,7 @@ function buildTscTargets(configFilePath, projectRoot, options, context) {
243
225
  options: { cwd: projectRoot },
244
226
  cache: true,
245
227
  inputs: getInputs(namedInputs, 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),
228
+ outputs: getOutputs(configFilePath, tsConfig, internalProjectReferences, context.workspaceRoot, projectRoot),
249
229
  syncGenerators: ['@nx/js:typescript-sync'],
250
230
  metadata: {
251
231
  technologies: ['typescript'],
@@ -280,57 +260,10 @@ function getInputs(namedInputs, configFilePath, tsConfig, internalProjectReferen
280
260
  ...Object.entries(internalProjectReferences),
281
261
  ];
282
262
  const absoluteProjectRoot = (0, node_path_1.join)(workspaceRoot, projectRoot);
283
- if (!ts) {
284
- ts = require('typescript');
285
- }
286
- // https://github.com/microsoft/TypeScript/blob/19b777260b26aac5707b1efd34202054164d4a9d/src/compiler/utilities.ts#L9869
287
- const supportedTSExtensions = [
288
- ts.Extension.Ts,
289
- ts.Extension.Tsx,
290
- ts.Extension.Dts,
291
- ts.Extension.Cts,
292
- ts.Extension.Dcts,
293
- ts.Extension.Mts,
294
- ts.Extension.Dmts,
295
- ];
296
- // https://github.com/microsoft/TypeScript/blob/19b777260b26aac5707b1efd34202054164d4a9d/src/compiler/utilities.ts#L9878
297
- const allSupportedExtensions = [
298
- ts.Extension.Ts,
299
- ts.Extension.Tsx,
300
- ts.Extension.Dts,
301
- ts.Extension.Js,
302
- ts.Extension.Jsx,
303
- ts.Extension.Cts,
304
- ts.Extension.Dcts,
305
- ts.Extension.Cjs,
306
- ts.Extension.Mts,
307
- ts.Extension.Dmts,
308
- ts.Extension.Mjs,
309
- ];
310
- const normalizeInput = (input, config) => {
311
- const extensions = config.options.allowJs
312
- ? [...allSupportedExtensions]
313
- : [...supportedTSExtensions];
314
- if (config.options.resolveJsonModule) {
315
- extensions.push(ts.Extension.Json);
316
- }
317
- const segments = input.split('/');
318
- // An "includes" path "foo" is implicitly a glob "foo/**/*" if its last
319
- // segment has no extension, and does not contain any glob characters
320
- // itself.
321
- // https://github.com/microsoft/TypeScript/blob/19b777260b26aac5707b1efd34202054164d4a9d/src/compiler/utilities.ts#L9577-L9585
322
- if (!/[.*?]/.test(segments.at(-1))) {
323
- return extensions.map((ext) => `${segments.join('/')}/**/*${ext}`);
324
- }
325
- return [input];
326
- };
327
263
  projectTsConfigFiles.forEach(([configPath, config]) => {
328
264
  configFiles.add(configPath);
329
265
  const offset = (0, node_path_1.relative)(absoluteProjectRoot, (0, node_path_1.dirname)(configPath));
330
- (config.raw?.include ?? []).forEach((p) => {
331
- const normalized = normalizeInput((0, node_path_1.join)(offset, p), config);
332
- normalized.forEach((input) => includePaths.add(input));
333
- });
266
+ (config.raw?.include ?? []).forEach((p) => includePaths.add((0, node_path_1.join)(offset, p)));
334
267
  if (config.raw?.exclude) {
335
268
  /**
336
269
  * We need to filter out the exclude paths that are already included in
@@ -378,7 +311,7 @@ function getInputs(namedInputs, configFilePath, tsConfig, internalProjectReferen
378
311
  inputs.push({ externalDependencies });
379
312
  return inputs;
380
313
  }
381
- function getOutputs(configFilePath, tsConfig, internalProjectReferences, workspaceRoot, projectRoot, emitDeclarationOnly) {
314
+ function getOutputs(configFilePath, tsConfig, internalProjectReferences, workspaceRoot, projectRoot) {
382
315
  const outputs = new Set();
383
316
  // We could have more surgical outputs based on the tsconfig options, but the
384
317
  // user could override them through the command line and that wouldn't be
@@ -400,18 +333,9 @@ function getOutputs(configFilePath, tsConfig, internalProjectReferences, workspa
400
333
  : pathToInputOrOutput((0, devkit_1.joinPathFragments)(outDir, `${outFileName}.tsbuildinfo`), workspaceRoot, projectRoot));
401
334
  }
402
335
  else if (config.options.outDir) {
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
- }
336
+ outputs.add(pathToInputOrOutput(config.options.outDir, workspaceRoot, projectRoot));
412
337
  if (config.options.tsBuildInfoFile) {
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}`)) {
338
+ if (!(0, node_path_1.normalize)(config.options.tsBuildInfoFile).startsWith(`${(0, node_path_1.normalize)(config.options.outDir)}${node_path_1.sep}`)) {
415
339
  // https://www.typescriptlang.org/tsconfig#tsBuildInfoFile
416
340
  outputs.add(pathToInputOrOutput(config.options.tsBuildInfoFile, workspaceRoot, projectRoot));
417
341
  }
@@ -421,11 +345,6 @@ function getOutputs(configFilePath, tsConfig, internalProjectReferences, workspa
421
345
  const relativeRootDir = (0, node_path_1.relative)(config.options.rootDir, (0, node_path_1.join)(workspaceRoot, projectRoot));
422
346
  outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(config.options.outDir, relativeRootDir, `*.tsbuildinfo`), workspaceRoot, projectRoot));
423
347
  }
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
- }
429
348
  }
430
349
  else if (config.raw?.include?.length ||
431
350
  config.raw?.files?.length ||
@@ -461,15 +380,17 @@ function pathToInputOrOutput(path, workspaceRoot, projectRoot) {
461
380
  }
462
381
  return (0, devkit_1.joinPathFragments)('{projectRoot}', pathRelativeToProjectRoot);
463
382
  }
464
- function getExtendedConfigFiles(tsConfig, workspaceRoot, extendedConfigFiles = new Set(), extendedExternalPackages = new Set()) {
465
- for (const extendedConfigFile of tsConfig.extendedConfigFiles) {
466
- if (extendedConfigFile.externalPackage) {
467
- extendedExternalPackages.add(extendedConfigFile.externalPackage);
468
- }
469
- else if (extendedConfigFile.filePath) {
470
- extendedConfigFiles.add(extendedConfigFile.filePath);
471
- getExtendedConfigFiles(retrieveTsConfigFromCache(extendedConfigFile.filePath, workspaceRoot), workspaceRoot, extendedConfigFiles, extendedExternalPackages);
472
- }
383
+ function getExtendedConfigFiles(tsConfig, workspaceRoot) {
384
+ const extendedConfigFiles = new Set();
385
+ const extendedExternalPackages = new Set();
386
+ let currentExtendedConfigFile = tsConfig.extendedConfigFile;
387
+ while (currentExtendedConfigFile) {
388
+ if (currentExtendedConfigFile.externalPackage) {
389
+ extendedExternalPackages.add(currentExtendedConfigFile.externalPackage);
390
+ break;
391
+ }
392
+ extendedConfigFiles.add(currentExtendedConfigFile.filePath);
393
+ currentExtendedConfigFile = retrieveTsConfigFromCache(currentExtendedConfigFile.filePath, workspaceRoot).extendedConfigFile;
473
394
  }
474
395
  return {
475
396
  files: Array.from(extendedConfigFiles),
@@ -605,54 +526,44 @@ function readTsConfigAndCache(tsConfigPath, workspaceRoot) {
605
526
  let extendedFilesHash;
606
527
  if (tsConfigCache[relativePath] &&
607
528
  tsConfigCache[relativePath].hash === hash) {
608
- extendedFilesHash = getExtendedFilesHash(tsConfigCache[relativePath].data.extendedConfigFiles, workspaceRoot);
529
+ extendedFilesHash = getExtendedFilesHash(tsConfigCache[relativePath].data.extendedConfigFile, workspaceRoot);
609
530
  if (tsConfigCache[relativePath].extendedFilesHash === extendedFilesHash) {
610
531
  return tsConfigCache[relativePath].data;
611
532
  }
612
533
  }
613
534
  const tsConfig = readTsConfig(tsConfigPath, workspaceRoot);
614
- const extendedConfigFiles = [];
615
- if (tsConfig.raw?.extends) {
616
- const extendsArray = typeof tsConfig.raw.extends === 'string'
617
- ? [tsConfig.raw.extends]
618
- : tsConfig.raw.extends;
619
- for (const extendsPath of extendsArray) {
620
- const extendedConfigFile = resolveExtendedTsConfigPath(extendsPath, (0, node_path_1.dirname)(tsConfigPath));
621
- if (extendedConfigFile) {
622
- extendedConfigFiles.push(extendedConfigFile);
623
- }
624
- }
625
- }
626
- extendedFilesHash ??= getExtendedFilesHash(extendedConfigFiles, workspaceRoot);
535
+ const extendedConfigFile = tsConfig.raw?.extends
536
+ ? resolveExtendedTsConfigPath(tsConfig.raw.extends, (0, node_path_1.dirname)(tsConfigPath))
537
+ : null;
538
+ extendedFilesHash ??= getExtendedFilesHash(extendedConfigFile, workspaceRoot);
627
539
  tsConfigCache[relativePath] = {
628
540
  data: {
629
541
  options: tsConfig.options,
630
542
  projectReferences: tsConfig.projectReferences,
631
543
  raw: tsConfig.raw,
632
- extendedConfigFiles,
544
+ extendedConfigFile: extendedConfigFile ?? null,
633
545
  },
634
546
  hash,
635
547
  extendedFilesHash,
636
548
  };
637
549
  return tsConfigCache[relativePath].data;
638
550
  }
639
- function getExtendedFilesHash(extendedConfigFiles, workspaceRoot) {
551
+ function getExtendedFilesHash(extendedConfigFile, workspaceRoot) {
640
552
  const hashes = [];
641
- if (!extendedConfigFiles.length) {
553
+ if (!extendedConfigFile) {
642
554
  return '';
643
555
  }
644
- for (const extendedConfigFile of extendedConfigFiles) {
645
- if (extendedConfigFile.externalPackage) {
646
- hashes.push(extendedConfigFile.externalPackage);
647
- }
648
- else if (extendedConfigFile.filePath) {
649
- hashes.push(getFileHash(extendedConfigFile.filePath, workspaceRoot));
650
- hashes.push(getExtendedFilesHash(readTsConfigAndCache(extendedConfigFile.filePath, workspaceRoot)
651
- .extendedConfigFiles, workspaceRoot));
652
- }
556
+ if (extendedConfigFile.externalPackage) {
557
+ hashes.push(extendedConfigFile.externalPackage);
558
+ }
559
+ else if (extendedConfigFile.filePath) {
560
+ hashes.push(getFileHash(extendedConfigFile.filePath, workspaceRoot));
561
+ hashes.push(getExtendedFilesHash(readTsConfigAndCache(extendedConfigFile.filePath, workspaceRoot)
562
+ .extendedConfigFile, workspaceRoot));
653
563
  }
654
564
  return hashes.join('|');
655
565
  }
566
+ let ts;
656
567
  function readTsConfig(tsConfigPath, workspaceRoot) {
657
568
  if (!ts) {
658
569
  ts = require('typescript');
@@ -712,8 +623,7 @@ function resolveExtendedTsConfigPath(tsConfigPath, directory) {
712
623
  const resolvedPath = require.resolve(tsConfigPath, {
713
624
  paths: directory ? [directory] : undefined,
714
625
  });
715
- if (tsConfigPath.startsWith('.') ||
716
- !resolvedPath.includes('/node_modules/')) {
626
+ if (tsConfigPath.startsWith('.')) {
717
627
  return { filePath: resolvedPath };
718
628
  }
719
629
  // parse the package from the tsconfig path
@@ -751,7 +661,7 @@ function toAbsolutePaths(cache, workspaceRoot) {
751
661
  raw: {
752
662
  nx: { addTypecheckTarget: data.raw?.['nx']?.addTypecheckTarget },
753
663
  },
754
- extendedConfigFiles: data.extendedConfigFiles,
664
+ extendedConfigFile: data.extendedConfigFile,
755
665
  },
756
666
  extendedFilesHash,
757
667
  hash,
@@ -768,10 +678,8 @@ function toAbsolutePaths(cache, workspaceRoot) {
768
678
  if (data.options.tsBuildInfoFile) {
769
679
  updatedCache[key].data.options.tsBuildInfoFile = (0, node_path_1.join)(workspaceRoot, data.options.tsBuildInfoFile);
770
680
  }
771
- if (data.extendedConfigFiles.length) {
772
- updatedCache[key].data.extendedConfigFiles.forEach((file) => {
773
- file.filePath = (0, node_path_1.join)(workspaceRoot, file.filePath);
774
- });
681
+ if (data.extendedConfigFile?.filePath) {
682
+ updatedCache[key].data.extendedConfigFile.filePath = (0, node_path_1.join)(workspaceRoot, data.extendedConfigFile.filePath);
775
683
  }
776
684
  if (data.projectReferences) {
777
685
  updatedCache[key].data.projectReferences = data.projectReferences.map((ref) => ({ ...ref, path: (0, node_path_1.join)(workspaceRoot, ref.path) }));
@@ -788,7 +696,7 @@ function toRelativePaths(cache, workspaceRoot) {
788
696
  raw: {
789
697
  nx: { addTypecheckTarget: data.raw?.['nx']?.addTypecheckTarget },
790
698
  },
791
- extendedConfigFiles: data.extendedConfigFiles,
699
+ extendedConfigFile: data.extendedConfigFile,
792
700
  },
793
701
  extendedFilesHash,
794
702
  hash,
@@ -805,10 +713,8 @@ function toRelativePaths(cache, workspaceRoot) {
805
713
  if (data.options.tsBuildInfoFile) {
806
714
  updatedCache[key].data.options.tsBuildInfoFile = posixRelative(workspaceRoot, data.options.tsBuildInfoFile);
807
715
  }
808
- if (data.extendedConfigFiles.length) {
809
- updatedCache[key].data.extendedConfigFiles.forEach((file) => {
810
- file.filePath = posixRelative(workspaceRoot, file.filePath);
811
- });
716
+ if (data.extendedConfigFile?.filePath) {
717
+ updatedCache[key].data.extendedConfigFile.filePath = posixRelative(workspaceRoot, data.extendedConfigFile.filePath);
812
718
  }
813
719
  if (data.projectReferences) {
814
720
  updatedCache[key].data.projectReferences = data.projectReferences.map((ref) => ({
@@ -1,12 +1,11 @@
1
1
  import { type TargetConfiguration } from '@nx/devkit';
2
2
  import { type PackageManagerCommands } from 'nx/src/utils/package-manager';
3
3
  import { type ParsedCommandLine } from 'typescript';
4
- export type ExtendedConfigFile = {
5
- filePath: string;
6
- externalPackage?: string;
7
- };
8
4
  export type ParsedTsconfigData = Pick<ParsedCommandLine, 'options' | 'projectReferences' | 'raw'> & {
9
- extendedConfigFiles: ExtendedConfigFile[];
5
+ extendedConfigFile: {
6
+ filePath: string;
7
+ externalPackage?: string;
8
+ } | null;
10
9
  };
11
10
  /**
12
11
  * Allow uses that use incremental builds to run `nx watch-deps` to continuously build all dependencies.
@@ -29,6 +29,7 @@ function addBuildAndWatchDepsTargets(workspaceRoot, projectRoot, targets, option
29
29
  dependsOn: ['^build'],
30
30
  };
31
31
  targets[options.watchDepsTargetName ?? 'watch-deps'] = {
32
+ continuous: true,
32
33
  dependsOn: [buildDepsTargetName],
33
34
  command: `${pmc.exec} nx watch --projects ${projectName} --includeDependentProjects -- ${pmc.exec} nx ${buildDepsTargetName} ${projectName}`,
34
35
  };
@@ -67,8 +68,8 @@ function isValidPackageJsonBuildConfig(tsConfig, workspaceRoot, projectRoot) {
67
68
  }
68
69
  else if (typeof value === 'object') {
69
70
  return Object.entries(value).some(([currentKey, subValue]) => {
70
- // Skip types and development conditions
71
- if (currentKey === 'types' || currentKey === 'development') {
71
+ // Skip types field
72
+ if (currentKey === 'types') {
72
73
  return false;
73
74
  }
74
75
  if (typeof subValue === 'string') {
@@ -33,6 +33,8 @@ export declare function calculateDependenciesFromTaskGraph(taskGraph: TaskGraph,
33
33
  */
34
34
  export declare function computeCompilerOptionsPaths(tsConfig: string | ts.ParsedCommandLine, dependencies: DependentBuildableProjectNode[]): ts.MapLike<string[]>;
35
35
  export declare function createTmpTsConfig(tsconfigPath: string, workspaceRoot: string, projectRoot: string, dependencies: DependentBuildableProjectNode[], useWorkspaceAsBaseUrl?: boolean): string;
36
+ export declare function checkDependentProjectsHaveBeenBuilt(root: string, projectName: string, targetName: string, projectDependencies: DependentBuildableProjectNode[]): boolean;
37
+ export declare function findMissingBuildDependencies(root: string, projectName: string, targetName: string, projectDependencies: DependentBuildableProjectNode[]): DependentBuildableProjectNode[];
36
38
  export declare function updatePaths(dependencies: DependentBuildableProjectNode[], paths: Record<string, string[]>): void;
37
39
  /**
38
40
  * Updates the peerDependencies section in the `dist/lib/xyz/package.json` with
@@ -5,6 +5,8 @@ exports.calculateProjectDependencies = calculateProjectDependencies;
5
5
  exports.calculateDependenciesFromTaskGraph = calculateDependenciesFromTaskGraph;
6
6
  exports.computeCompilerOptionsPaths = computeCompilerOptionsPaths;
7
7
  exports.createTmpTsConfig = createTmpTsConfig;
8
+ exports.checkDependentProjectsHaveBeenBuilt = checkDependentProjectsHaveBeenBuilt;
9
+ exports.findMissingBuildDependencies = findMissingBuildDependencies;
8
10
  exports.updatePaths = updatePaths;
9
11
  exports.updateBuildableProjectPackageJsonDependencies = updateBuildableProjectPackageJsonDependencies;
10
12
  const devkit_1 = require("@nx/devkit");
@@ -250,6 +252,36 @@ function cleanupTmpTsConfigFile(tmpTsConfigPath) {
250
252
  }
251
253
  catch (e) { }
252
254
  }
255
+ function checkDependentProjectsHaveBeenBuilt(root, projectName, targetName, projectDependencies) {
256
+ const missing = findMissingBuildDependencies(root, projectName, targetName, projectDependencies);
257
+ if (missing.length > 0) {
258
+ console.error((0, devkit_1.stripIndents) `
259
+ It looks like all of ${projectName}'s dependencies have not been built yet:
260
+ ${missing.map((x) => ` - ${x.node.name}`).join('\n')}
261
+
262
+ You might be missing a "targetDefaults" configuration in your root nx.json (https://nx.dev/reference/project-configuration#target-defaults),
263
+ or "dependsOn" configured in ${projectName}'s project.json (https://nx.dev/reference/project-configuration#dependson)
264
+ `);
265
+ return false;
266
+ }
267
+ else {
268
+ return true;
269
+ }
270
+ }
271
+ function findMissingBuildDependencies(root, projectName, targetName, projectDependencies) {
272
+ const depLibsToBuildFirst = [];
273
+ // verify whether all dependent libraries have been built
274
+ projectDependencies.forEach((dep) => {
275
+ if (dep.node.type !== 'lib') {
276
+ return;
277
+ }
278
+ const paths = dep.outputs.map((p) => (0, path_1.join)(root, p));
279
+ if (!paths.some(fileutils_1.directoryExists)) {
280
+ depLibsToBuildFirst.push(dep);
281
+ }
282
+ });
283
+ return depLibsToBuildFirst;
284
+ }
253
285
  function updatePaths(dependencies, paths) {
254
286
  const pathsKeys = Object.keys(paths);
255
287
  // For each registered dependency
@@ -259,7 +291,7 @@ function updatePaths(dependencies, paths) {
259
291
  // If there are outputs
260
292
  if (dep.outputs && dep.outputs.length > 0) {
261
293
  // Directly map the dependency name to the output paths (dist/packages/..., etc.)
262
- paths[dep.name] = dep.outputs.map((output) => output.replace(/(\*|\/[^\/]*\*).*$/, ''));
294
+ paths[dep.name] = dep.outputs;
263
295
  // check for secondary entrypoints
264
296
  // For each registered path
265
297
  for (const path of pathsKeys) {
@@ -19,7 +19,6 @@ export interface UpdatePackageJsonOption {
19
19
  buildableProjectDepsInPackageJsonType?: 'dependencies' | 'peerDependencies';
20
20
  generateLockfile?: boolean;
21
21
  packageJsonPath?: string;
22
- skipDevelopmentExports?: boolean;
23
22
  }
24
23
  export declare function updatePackageJson(options: UpdatePackageJsonOption, context: ExecutorContext, target: ProjectGraphProjectNode, dependencies: DependentBuildableProjectNode[], fileMap?: ProjectFileMap): void;
25
24
  interface Exports {
@@ -50,10 +50,7 @@ function updatePackageJson(options, context, target, dependencies, fileMap = nul
50
50
  options.format = ['cjs'];
51
51
  }
52
52
  // update package specific settings
53
- packageJson = getUpdatedPackageJsonContent(packageJson, {
54
- skipDevelopmentExports: true,
55
- ...options,
56
- });
53
+ packageJson = getUpdatedPackageJsonContent(packageJson, options);
57
54
  // save files
58
55
  (0, devkit_1.writeJsonFile)(`${options.outputPath}/package.json`, packageJson);
59
56
  if (options.generateLockfile) {
@@ -149,19 +146,6 @@ function getUpdatedPackageJsonContent(packageJson, options) {
149
146
  packageJson.exports ??=
150
147
  typeof packageJson.exports === 'string' ? {} : { ...packageJson.exports };
151
148
  packageJson.exports['./package.json'] ??= './package.json';
152
- if (!options.skipDevelopmentExports && (hasCjsFormat || hasEsmFormat)) {
153
- packageJson.exports['.'] ??= {};
154
- const developmentExports = getDevelopmentExports(options);
155
- for (const [exportEntry, filePath] of Object.entries(developmentExports)) {
156
- if (!packageJson.exports[exportEntry]) {
157
- packageJson.exports[exportEntry] ??= {};
158
- packageJson.exports[exportEntry]['development'] ??= filePath;
159
- }
160
- else if (typeof packageJson.exports[exportEntry] === 'object') {
161
- packageJson.exports[exportEntry].development ??= filePath;
162
- }
163
- }
164
- }
165
149
  }
166
150
  if (!options.skipTypings) {
167
151
  const mainFile = (0, path_1.basename)(options.main).replace(/\.[tj]s$/, '');
@@ -231,31 +215,6 @@ function getUpdatedPackageJsonContent(packageJson, options) {
231
215
  }
232
216
  return packageJson;
233
217
  }
234
- function getDevelopmentExports(options) {
235
- const mainRelativeDir = (0, get_main_file_dir_1.getRelativeDirectoryToProjectRoot)(options.main, options.projectRoot);
236
- const exports = {
237
- '.': mainRelativeDir + (0, path_1.basename)(options.main),
238
- };
239
- if (options.additionalEntryPoints?.length) {
240
- const jsRegex = /\.[jt]sx?$/;
241
- for (const file of options.additionalEntryPoints) {
242
- const { ext: fileExt, name: fileName, base: baseName } = (0, path_1.parse)(file);
243
- if (!jsRegex.test(fileExt)) {
244
- continue;
245
- }
246
- const relativeDir = (0, get_main_file_dir_1.getRelativeDirectoryToProjectRoot)(file, options.projectRoot);
247
- const sourceFilePath = relativeDir + baseName;
248
- const entryRelativeDir = relativeDir.replace(/^\.\/src\//, './');
249
- const entryFilePath = entryRelativeDir + fileName;
250
- if (fileName === 'index') {
251
- const barrelEntry = entryRelativeDir.replace(/\/$/, '');
252
- exports[barrelEntry] = sourceFilePath;
253
- }
254
- exports[entryFilePath] = sourceFilePath;
255
- }
256
- }
257
- return exports;
258
- }
259
218
  function getOutputDir(options) {
260
219
  const packageJsonDir = options.packageJsonPath
261
220
  ? (0, path_1.dirname)(options.packageJsonPath)
@@ -0,0 +1 @@
1
+ export declare function tsNodeRegister(file: string, tsConfig?: string): void;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tsNodeRegister = tsNodeRegister;
4
+ function tsNodeRegister(file, tsConfig) {
5
+ if (!file?.endsWith('.ts'))
6
+ return;
7
+ // Register TS compiler lazily
8
+ require('ts-node').register({
9
+ project: tsConfig,
10
+ compilerOptions: {
11
+ module: 'CommonJS',
12
+ types: ['node'],
13
+ },
14
+ });
15
+ if (!tsConfig)
16
+ return;
17
+ // Register paths in tsConfig
18
+ const tsconfigPaths = require('tsconfig-paths');
19
+ const { absoluteBaseUrl: baseUrl, paths } = tsconfigPaths.loadConfig(tsConfig);
20
+ if (baseUrl && paths) {
21
+ tsconfigPaths.register({ baseUrl, paths });
22
+ }
23
+ }
@@ -1,7 +1,7 @@
1
1
  export declare const nxVersion: any;
2
2
  export declare const esbuildVersion = "^0.19.2";
3
3
  export declare const prettierVersion = "^2.6.2";
4
- export declare const swcCliVersion = "~0.6.0";
4
+ export declare const swcCliVersion = "~0.3.12";
5
5
  export declare const swcCoreVersion = "~1.5.7";
6
6
  export declare const swcHelpersVersion = "~0.5.11";
7
7
  export declare const swcNodeVersion = "~1.9.1";
@@ -4,7 +4,7 @@ exports.supportedTypescriptVersions = exports.typescriptVersion = exports.verdac
4
4
  exports.nxVersion = require('../../package.json').version;
5
5
  exports.esbuildVersion = '^0.19.2';
6
6
  exports.prettierVersion = '^2.6.2';
7
- exports.swcCliVersion = '~0.6.0';
7
+ exports.swcCliVersion = '~0.3.12';
8
8
  exports.swcCoreVersion = '~1.5.7';
9
9
  exports.swcHelpersVersion = '~0.5.11';
10
10
  exports.swcNodeVersion = '~1.9.1';