@nx/js 20.7.0 → 20.7.2
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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/js",
|
|
3
|
-
"version": "20.7.
|
|
3
|
+
"version": "20.7.2",
|
|
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.
|
|
43
|
-
"@nx/workspace": "20.7.
|
|
42
|
+
"@nx/devkit": "20.7.2",
|
|
43
|
+
"@nx/workspace": "20.7.2",
|
|
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:
|
|
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
|
|
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
|
-
|
|
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 (
|
|
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 ||
|
|
@@ -431,17 +461,15 @@ function pathToInputOrOutput(path, workspaceRoot, projectRoot) {
|
|
|
431
461
|
}
|
|
432
462
|
return (0, devkit_1.joinPathFragments)('{projectRoot}', pathRelativeToProjectRoot);
|
|
433
463
|
}
|
|
434
|
-
function getExtendedConfigFiles(tsConfig, workspaceRoot) {
|
|
435
|
-
const
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
if (
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
}
|
|
443
|
-
extendedConfigFiles.add(currentExtendedConfigFile.filePath);
|
|
444
|
-
currentExtendedConfigFile = retrieveTsConfigFromCache(currentExtendedConfigFile.filePath, workspaceRoot).extendedConfigFile;
|
|
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
|
+
}
|
|
445
473
|
}
|
|
446
474
|
return {
|
|
447
475
|
files: Array.from(extendedConfigFiles),
|
|
@@ -577,40 +605,51 @@ function readTsConfigAndCache(tsConfigPath, workspaceRoot) {
|
|
|
577
605
|
let extendedFilesHash;
|
|
578
606
|
if (tsConfigCache[relativePath] &&
|
|
579
607
|
tsConfigCache[relativePath].hash === hash) {
|
|
580
|
-
extendedFilesHash = getExtendedFilesHash(tsConfigCache[relativePath].data.
|
|
608
|
+
extendedFilesHash = getExtendedFilesHash(tsConfigCache[relativePath].data.extendedConfigFiles, workspaceRoot);
|
|
581
609
|
if (tsConfigCache[relativePath].extendedFilesHash === extendedFilesHash) {
|
|
582
610
|
return tsConfigCache[relativePath].data;
|
|
583
611
|
}
|
|
584
612
|
}
|
|
585
613
|
const tsConfig = readTsConfig(tsConfigPath, workspaceRoot);
|
|
586
|
-
const
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
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);
|
|
590
627
|
tsConfigCache[relativePath] = {
|
|
591
628
|
data: {
|
|
592
629
|
options: tsConfig.options,
|
|
593
630
|
projectReferences: tsConfig.projectReferences,
|
|
594
631
|
raw: tsConfig.raw,
|
|
595
|
-
|
|
632
|
+
extendedConfigFiles,
|
|
596
633
|
},
|
|
597
634
|
hash,
|
|
598
635
|
extendedFilesHash,
|
|
599
636
|
};
|
|
600
637
|
return tsConfigCache[relativePath].data;
|
|
601
638
|
}
|
|
602
|
-
function getExtendedFilesHash(
|
|
639
|
+
function getExtendedFilesHash(extendedConfigFiles, workspaceRoot) {
|
|
603
640
|
const hashes = [];
|
|
604
|
-
if (!
|
|
641
|
+
if (!extendedConfigFiles.length) {
|
|
605
642
|
return '';
|
|
606
643
|
}
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
.extendedConfigFile, workspaceRoot)
|
|
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
|
+
}
|
|
614
653
|
}
|
|
615
654
|
return hashes.join('|');
|
|
616
655
|
}
|
|
@@ -673,7 +712,8 @@ function resolveExtendedTsConfigPath(tsConfigPath, directory) {
|
|
|
673
712
|
const resolvedPath = require.resolve(tsConfigPath, {
|
|
674
713
|
paths: directory ? [directory] : undefined,
|
|
675
714
|
});
|
|
676
|
-
if (tsConfigPath.startsWith('.')
|
|
715
|
+
if (tsConfigPath.startsWith('.') ||
|
|
716
|
+
!resolvedPath.includes('/node_modules/')) {
|
|
677
717
|
return { filePath: resolvedPath };
|
|
678
718
|
}
|
|
679
719
|
// parse the package from the tsconfig path
|
|
@@ -711,7 +751,7 @@ function toAbsolutePaths(cache, workspaceRoot) {
|
|
|
711
751
|
raw: {
|
|
712
752
|
nx: { addTypecheckTarget: data.raw?.['nx']?.addTypecheckTarget },
|
|
713
753
|
},
|
|
714
|
-
|
|
754
|
+
extendedConfigFiles: data.extendedConfigFiles,
|
|
715
755
|
},
|
|
716
756
|
extendedFilesHash,
|
|
717
757
|
hash,
|
|
@@ -728,8 +768,10 @@ function toAbsolutePaths(cache, workspaceRoot) {
|
|
|
728
768
|
if (data.options.tsBuildInfoFile) {
|
|
729
769
|
updatedCache[key].data.options.tsBuildInfoFile = (0, node_path_1.join)(workspaceRoot, data.options.tsBuildInfoFile);
|
|
730
770
|
}
|
|
731
|
-
if (data.
|
|
732
|
-
updatedCache[key].data.
|
|
771
|
+
if (data.extendedConfigFiles.length) {
|
|
772
|
+
updatedCache[key].data.extendedConfigFiles.forEach((file) => {
|
|
773
|
+
file.filePath = (0, node_path_1.join)(workspaceRoot, file.filePath);
|
|
774
|
+
});
|
|
733
775
|
}
|
|
734
776
|
if (data.projectReferences) {
|
|
735
777
|
updatedCache[key].data.projectReferences = data.projectReferences.map((ref) => ({ ...ref, path: (0, node_path_1.join)(workspaceRoot, ref.path) }));
|
|
@@ -746,7 +788,7 @@ function toRelativePaths(cache, workspaceRoot) {
|
|
|
746
788
|
raw: {
|
|
747
789
|
nx: { addTypecheckTarget: data.raw?.['nx']?.addTypecheckTarget },
|
|
748
790
|
},
|
|
749
|
-
|
|
791
|
+
extendedConfigFiles: data.extendedConfigFiles,
|
|
750
792
|
},
|
|
751
793
|
extendedFilesHash,
|
|
752
794
|
hash,
|
|
@@ -763,8 +805,10 @@ function toRelativePaths(cache, workspaceRoot) {
|
|
|
763
805
|
if (data.options.tsBuildInfoFile) {
|
|
764
806
|
updatedCache[key].data.options.tsBuildInfoFile = posixRelative(workspaceRoot, data.options.tsBuildInfoFile);
|
|
765
807
|
}
|
|
766
|
-
if (data.
|
|
767
|
-
updatedCache[key].data.
|
|
808
|
+
if (data.extendedConfigFiles.length) {
|
|
809
|
+
updatedCache[key].data.extendedConfigFiles.forEach((file) => {
|
|
810
|
+
file.filePath = posixRelative(workspaceRoot, file.filePath);
|
|
811
|
+
});
|
|
768
812
|
}
|
|
769
813
|
if (data.projectReferences) {
|
|
770
814
|
updatedCache[key].data.projectReferences = data.projectReferences.map((ref) => ({
|
|
@@ -1,11 +1,12 @@
|
|
|
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
|
+
};
|
|
4
8
|
export type ParsedTsconfigData = Pick<ParsedCommandLine, 'options' | 'projectReferences' | 'raw'> & {
|
|
5
|
-
|
|
6
|
-
filePath: string;
|
|
7
|
-
externalPackage?: string;
|
|
8
|
-
} | null;
|
|
9
|
+
extendedConfigFiles: ExtendedConfigFile[];
|
|
9
10
|
};
|
|
10
11
|
/**
|
|
11
12
|
* Allow uses that use incremental builds to run `nx watch-deps` to continuously build all dependencies.
|
|
@@ -114,7 +114,7 @@ function readTsConfigWithRemappedPaths(originalTsconfigPath, generatedTsconfigPa
|
|
|
114
114
|
const normalizedTsConfig = (0, path_1.resolve)(workspaceRoot, originalTsconfigPath);
|
|
115
115
|
const normalizedGeneratedTsConfigDir = (0, path_1.resolve)(workspaceRoot, (0, path_1.dirname)(generatedTsconfigPath));
|
|
116
116
|
generatedTsConfig.extends = (0, path_1.relative)(normalizedGeneratedTsConfigDir, normalizedTsConfig);
|
|
117
|
-
generatedTsConfig.compilerOptions.paths = computeCompilerOptionsPaths(
|
|
117
|
+
generatedTsConfig.compilerOptions.paths = computeCompilerOptionsPaths(normalizedTsConfig, dependencies);
|
|
118
118
|
if (process.env.NX_VERBOSE_LOGGING_PATH_MAPPINGS === 'true') {
|
|
119
119
|
output_1.output.log({
|
|
120
120
|
title: 'TypeScript path mappings have been rewritten.',
|
package/src/utils/versions.d.ts
CHANGED
|
@@ -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.
|
|
4
|
+
export declare const swcCliVersion = "~0.6.0";
|
|
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";
|
package/src/utils/versions.js
CHANGED
|
@@ -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.
|
|
7
|
+
exports.swcCliVersion = '~0.6.0';
|
|
8
8
|
exports.swcCoreVersion = '~1.5.7';
|
|
9
9
|
exports.swcHelpersVersion = '~0.5.11';
|
|
10
10
|
exports.swcNodeVersion = '~1.9.1';
|