@nx/js 22.6.0-pr.34728.66566c0 → 22.6.0-pr.34764.07d8b15
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": "22.6.0-pr.
|
|
3
|
+
"version": "22.6.0-pr.34764.07d8b15",
|
|
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": "22.6.0-pr.
|
|
43
|
-
"@nx/workspace": "22.6.0-pr.
|
|
42
|
+
"@nx/devkit": "22.6.0-pr.34764.07d8b15",
|
|
43
|
+
"@nx/workspace": "22.6.0-pr.34764.07d8b15",
|
|
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,7 +60,7 @@
|
|
|
60
60
|
"tslib": "^2.3.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"nx": "22.6.0-pr.
|
|
63
|
+
"nx": "22.6.0-pr.34764.07d8b15"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"verdaccio": "^6.0.5"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/plugins/typescript/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,kBAAkB,EAEvB,KAAK,aAAa,EAInB,MAAM,YAAY,CAAC;AA+BpB,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAC1B,SAAS,CAAC,EACN,OAAO,GACP;QACE,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IACN,KAAK,CAAC,EACF,OAAO,GACP;QACE,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,cAAc,CAAC,EAAE,OAAO,CAAC;KAC1B,CAAC;IACN,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/plugins/typescript/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,kBAAkB,EAEvB,KAAK,aAAa,EAInB,MAAM,YAAY,CAAC;AA+BpB,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAC1B,SAAS,CAAC,EACN,OAAO,GACP;QACE,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IACN,KAAK,CAAC,EACF,OAAO,GACP;QACE,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,cAAc,CAAC,EAAE,OAAO,CAAC;KAC1B,CAAC;IACN,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AA2KD;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,kBAEhC,CAAC;AAEF,eAAO,MAAM,WAAW,sBAAsB,CAAC;AAI/C,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,gBAAgB,CA0FzD,CAAC;AAEF,eAAO,MAAM,WAAW,iCAAgB,CAAC"}
|
|
@@ -166,7 +166,8 @@ async function resolveValidConfigFilesAndHashes(configFilePaths, options, option
|
|
|
166
166
|
const absolutePath = (0, node_path_1.join)(context.workspaceRoot, configFilePath);
|
|
167
167
|
const configContext = getConfigContext(absolutePath, context.workspaceRoot, cache);
|
|
168
168
|
// Skip configs that can't produce any targets based on plugin options
|
|
169
|
-
const isTypecheckConfig = configContext.basename ===
|
|
169
|
+
const isTypecheckConfig = configContext.basename ===
|
|
170
|
+
(options.typecheck ? options.typecheck.configName : 'tsconfig.json');
|
|
170
171
|
const isBuildConfig = options.build && configContext.basename === options.build.configName;
|
|
171
172
|
if (!isTypecheckConfig && !isBuildConfig) {
|
|
172
173
|
continue;
|
|
@@ -248,8 +249,8 @@ function buildTscTargets(config, options, context, configFiles, cache) {
|
|
|
248
249
|
const namedInputs = (0, get_named_inputs_1.getNamedInputs)(config.project.root, context);
|
|
249
250
|
const tsConfig = retrieveTsConfigFromCache(config.absolutePath, context.workspaceRoot, cache);
|
|
250
251
|
let internalProjectReferences;
|
|
251
|
-
if (
|
|
252
|
-
options.typecheck &&
|
|
252
|
+
if (options.typecheck &&
|
|
253
|
+
config.basename === options.typecheck.configName &&
|
|
253
254
|
tsConfig.raw?.['nx']?.addTypecheckTarget !== false) {
|
|
254
255
|
internalProjectReferences = resolveInternalProjectReferences(tsConfig, context.workspaceRoot, config.project, cache);
|
|
255
256
|
const externalProjectReferences = resolveShallowExternalProjectReferences(tsConfig, context.workspaceRoot, config.project, cache);
|
|
@@ -455,10 +456,18 @@ function getInputs(namedInputs, config, tsConfig, internalProjectReferences, wor
|
|
|
455
456
|
if (excludePaths.size) {
|
|
456
457
|
inputs.push(...Array.from(excludePaths).map((p) => `!${pathToInputOrOutput((0, devkit_1.joinPathFragments)(config.project.root, p), workspaceRoot, config.project)}`));
|
|
457
458
|
}
|
|
458
|
-
|
|
459
|
-
|
|
459
|
+
const externalRefConfigFiles = getExternalProjectReferenceConfigFiles(tsConfig, internalProjectReferences, workspaceRoot, config.project, cache, configFiles);
|
|
460
|
+
if (externalRefConfigFiles.length > 0) {
|
|
461
|
+
// tsc --build reads .d.ts and .tsbuildinfo files from referenced projects
|
|
460
462
|
// https://www.typescriptlang.org/docs/handbook/project-references.html#what-is-a-project-reference
|
|
461
|
-
inputs.push({
|
|
463
|
+
inputs.push({
|
|
464
|
+
dependentTasksOutputFiles: '**/*.{d.ts,tsbuildinfo}',
|
|
465
|
+
transitive: true,
|
|
466
|
+
});
|
|
467
|
+
// tsc --build also reads the tsconfig files from external project
|
|
468
|
+
// references (and their extended configs) when processing project
|
|
469
|
+
// references, so we need to add them as inputs
|
|
470
|
+
inputs.push(...externalRefConfigFiles.map((p) => pathToInputOrOutput(p, workspaceRoot, config.project)));
|
|
462
471
|
}
|
|
463
472
|
else {
|
|
464
473
|
inputs.push('production' in namedInputs ? '^production' : '^default');
|
|
@@ -466,17 +475,23 @@ function getInputs(namedInputs, config, tsConfig, internalProjectReferences, wor
|
|
|
466
475
|
// inputs.push({ externalDependencies });
|
|
467
476
|
return inputs;
|
|
468
477
|
}
|
|
469
|
-
function getOutputs(config,
|
|
478
|
+
function getOutputs(config, rootTsConfig, internalProjectReferences, workspaceRoot, emitDeclarationOnly) {
|
|
470
479
|
const outputs = new Set();
|
|
471
480
|
// We could have more surgical outputs based on the tsconfig options, but the
|
|
472
481
|
// user could override them through the command line and that wouldn't be
|
|
473
482
|
// reflected in the outputs. So, we just include everything that could be
|
|
474
483
|
// produced by the tsc command.
|
|
475
|
-
[
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
484
|
+
[
|
|
485
|
+
{ configBaseNameNoExt: config.basenameNoExt, tsConfig: rootTsConfig },
|
|
486
|
+
...Object.entries(internalProjectReferences).map(([internalConfigPath, internalConfig]) => ({
|
|
487
|
+
configBaseNameNoExt: (0, node_path_1.basename)(internalConfigPath, '.json'),
|
|
488
|
+
tsConfig: internalConfig,
|
|
489
|
+
})),
|
|
490
|
+
].forEach(({ configBaseNameNoExt, tsConfig }) => {
|
|
491
|
+
if (tsConfig.options.outFile) {
|
|
492
|
+
const outFileName = (0, node_path_1.basename)(tsConfig.options.outFile, '.js');
|
|
493
|
+
const outFileDir = (0, node_path_1.dirname)(tsConfig.options.outFile);
|
|
494
|
+
outputs.add(pathToInputOrOutput(tsConfig.options.outFile, workspaceRoot, config.project));
|
|
480
495
|
// outFile is not be used with .cjs, .mjs, .jsx, so the list is simpler
|
|
481
496
|
const outDir = (0, node_path_1.relative)(workspaceRoot, outFileDir);
|
|
482
497
|
outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(outDir, `${outFileName}.js.map`), workspaceRoot, config.project));
|
|
@@ -487,38 +502,36 @@ function getOutputs(config, tsConfig, internalProjectReferences, workspaceRoot,
|
|
|
487
502
|
? pathToInputOrOutput(tsConfig.options.tsBuildInfoFile, workspaceRoot, config.project)
|
|
488
503
|
: pathToInputOrOutput((0, devkit_1.joinPathFragments)(outDir, `${outFileName}.tsbuildinfo`), workspaceRoot, config.project));
|
|
489
504
|
}
|
|
490
|
-
else if (
|
|
505
|
+
else if (tsConfig.options.outDir) {
|
|
491
506
|
if (emitDeclarationOnly) {
|
|
492
|
-
outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(
|
|
507
|
+
outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(tsConfig.options.outDir, '**/*.d.ts'), workspaceRoot, config.project));
|
|
493
508
|
if (tsConfig.options.declarationMap) {
|
|
494
|
-
outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(
|
|
509
|
+
outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(tsConfig.options.outDir, '**/*.d.ts.map'), workspaceRoot, config.project));
|
|
495
510
|
}
|
|
496
511
|
}
|
|
497
512
|
else {
|
|
498
|
-
outputs.add(pathToInputOrOutput(
|
|
513
|
+
outputs.add(pathToInputOrOutput(tsConfig.options.outDir, workspaceRoot, config.project));
|
|
499
514
|
}
|
|
500
|
-
if (
|
|
515
|
+
if (tsConfig.options.tsBuildInfoFile) {
|
|
501
516
|
if (emitDeclarationOnly ||
|
|
502
|
-
!(0, node_path_1.normalize)(
|
|
517
|
+
!(0, node_path_1.normalize)(tsConfig.options.tsBuildInfoFile).startsWith(`${(0, node_path_1.normalize)(tsConfig.options.outDir)}${node_path_1.sep}`)) {
|
|
503
518
|
// https://www.typescriptlang.org/tsconfig#tsBuildInfoFile
|
|
504
|
-
outputs.add(pathToInputOrOutput(
|
|
519
|
+
outputs.add(pathToInputOrOutput(tsConfig.options.tsBuildInfoFile, workspaceRoot, config.project));
|
|
505
520
|
}
|
|
506
521
|
}
|
|
507
|
-
else if (
|
|
508
|
-
tsconfig.options.rootDir !== '.') {
|
|
522
|
+
else if (tsConfig.options.rootDir && tsConfig.options.rootDir !== '.') {
|
|
509
523
|
// If rootDir is set, then the tsbuildinfo file will be outside the outDir so we need to add it.
|
|
510
|
-
const relativeRootDir = (0, node_path_1.relative)(
|
|
511
|
-
outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(
|
|
524
|
+
const relativeRootDir = (0, node_path_1.relative)(tsConfig.options.rootDir, (0, node_path_1.join)(workspaceRoot, config.project.root));
|
|
525
|
+
outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(tsConfig.options.outDir, relativeRootDir, `*.tsbuildinfo`), workspaceRoot, config.project));
|
|
512
526
|
}
|
|
513
527
|
else if (emitDeclarationOnly) {
|
|
514
528
|
// https://www.typescriptlang.org/tsconfig#tsBuildInfoFile
|
|
515
|
-
|
|
516
|
-
outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(tsconfig.options.outDir, `${name}.tsbuildinfo`), workspaceRoot, config.project));
|
|
529
|
+
outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(tsConfig.options.outDir, `${configBaseNameNoExt}.tsbuildinfo`), workspaceRoot, config.project));
|
|
517
530
|
}
|
|
518
531
|
}
|
|
519
|
-
else if (
|
|
520
|
-
|
|
521
|
-
(!
|
|
532
|
+
else if (tsConfig.raw?.include?.length ||
|
|
533
|
+
tsConfig.raw?.files?.length ||
|
|
534
|
+
(!tsConfig.raw?.include && !tsConfig.raw?.files)) {
|
|
522
535
|
// tsc produce files in place when no outDir or outFile is set
|
|
523
536
|
outputs.add((0, devkit_1.joinPathFragments)('{projectRoot}', '**/*.js'));
|
|
524
537
|
outputs.add((0, devkit_1.joinPathFragments)('{projectRoot}', '**/*.cjs'));
|
|
@@ -533,10 +546,9 @@ function getOutputs(config, tsConfig, internalProjectReferences, workspaceRoot,
|
|
|
533
546
|
outputs.add((0, devkit_1.joinPathFragments)('{projectRoot}', '**/*.d.cts.map'));
|
|
534
547
|
outputs.add((0, devkit_1.joinPathFragments)('{projectRoot}', '**/*.d.mts.map'));
|
|
535
548
|
// https://www.typescriptlang.org/tsconfig#tsBuildInfoFile
|
|
536
|
-
const name = config.basenameNoExt;
|
|
537
549
|
outputs.add(tsConfig.options.tsBuildInfoFile
|
|
538
550
|
? pathToInputOrOutput(tsConfig.options.tsBuildInfoFile, workspaceRoot, config.project)
|
|
539
|
-
: (0, devkit_1.joinPathFragments)('{projectRoot}', `${
|
|
551
|
+
: (0, devkit_1.joinPathFragments)('{projectRoot}', `${configBaseNameNoExt}.tsbuildinfo`));
|
|
540
552
|
}
|
|
541
553
|
});
|
|
542
554
|
return Array.from(outputs);
|
|
@@ -611,33 +623,35 @@ function resolveShallowExternalProjectReferences(tsConfig, workspaceRoot, projec
|
|
|
611
623
|
}
|
|
612
624
|
return projectReferences;
|
|
613
625
|
}
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
}
|
|
634
|
-
const
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
626
|
+
/**
|
|
627
|
+
* Collects config file paths from external project references, including their
|
|
628
|
+
* extended config files. It checks the root tsconfig and all internal project
|
|
629
|
+
* references for their direct external references.
|
|
630
|
+
*/
|
|
631
|
+
function getExternalProjectReferenceConfigFiles(tsConfig, internalProjectReferences, workspaceRoot, project, cache, existingConfigFiles) {
|
|
632
|
+
const externalRefs = {};
|
|
633
|
+
// Collect direct external references from the root tsconfig
|
|
634
|
+
resolveShallowExternalProjectReferences(tsConfig, workspaceRoot, project, cache, externalRefs);
|
|
635
|
+
// Collect external references from internal project references
|
|
636
|
+
for (const refTsConfig of Object.values(internalProjectReferences)) {
|
|
637
|
+
resolveShallowExternalProjectReferences(refTsConfig, workspaceRoot, project, cache, externalRefs);
|
|
638
|
+
}
|
|
639
|
+
const result = [];
|
|
640
|
+
const seen = new Set();
|
|
641
|
+
for (const [refConfigPath, refTsConfig] of Object.entries(externalRefs)) {
|
|
642
|
+
if (!existingConfigFiles.has(refConfigPath) && !seen.has(refConfigPath)) {
|
|
643
|
+
result.push(refConfigPath);
|
|
644
|
+
seen.add(refConfigPath);
|
|
645
|
+
}
|
|
646
|
+
const extendedFiles = getExtendedConfigFiles(refTsConfig, workspaceRoot, cache);
|
|
647
|
+
for (const extFile of extendedFiles.files) {
|
|
648
|
+
if (!existingConfigFiles.has(extFile) && !seen.has(extFile)) {
|
|
649
|
+
result.push(extFile);
|
|
650
|
+
seen.add(extFile);
|
|
651
|
+
}
|
|
638
652
|
}
|
|
639
653
|
}
|
|
640
|
-
return
|
|
654
|
+
return result;
|
|
641
655
|
}
|
|
642
656
|
function isExternalProjectReference(refConfig, project, workspaceRoot, cache) {
|
|
643
657
|
const owner = cache.configOwners.get(refConfig.relativePath);
|
|
@@ -765,7 +779,9 @@ function normalizePluginOptions(pluginOptions = {}) {
|
|
|
765
779
|
const defaultCompiler = 'tsc';
|
|
766
780
|
const compiler = pluginOptions.compiler ?? defaultCompiler;
|
|
767
781
|
const defaultTypecheckTargetName = 'typecheck';
|
|
782
|
+
const defaultTypecheckConfigName = 'tsconfig.json';
|
|
768
783
|
let typecheck = {
|
|
784
|
+
configName: defaultTypecheckConfigName,
|
|
769
785
|
targetName: defaultTypecheckTargetName,
|
|
770
786
|
};
|
|
771
787
|
if (pluginOptions.typecheck === false) {
|
|
@@ -774,6 +790,7 @@ function normalizePluginOptions(pluginOptions = {}) {
|
|
|
774
790
|
else if (pluginOptions.typecheck &&
|
|
775
791
|
typeof pluginOptions.typecheck !== 'boolean') {
|
|
776
792
|
typecheck = {
|
|
793
|
+
configName: pluginOptions.typecheck.configName ?? defaultTypecheckConfigName,
|
|
777
794
|
targetName: pluginOptions.typecheck.targetName ?? defaultTypecheckTargetName,
|
|
778
795
|
};
|
|
779
796
|
}
|