@nx/js 0.0.0-pr-3-c6ccd0d → 0.0.0-pr-30250-73071c2
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 +5 -4
- package/src/executors/node/node.impl.js +1 -1
- package/src/generators/library/library.js +14 -4
- package/src/plugins/typescript/plugin.js +29 -15
- package/src/plugins/typescript/util.js +0 -1
- package/src/utils/assets/copy-assets-handler.js +11 -5
- package/src/utils/buildable-libs-utils.js +2 -1
- package/src/utils/package-manager-workspaces.js +8 -7
- package/src/utils/typescript/plugin.d.ts +1 -1
- package/src/utils/typescript/plugin.js +27 -16
- package/src/utils/typescript/ts-solution-setup.js +5 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/js",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-30250-73071c2",
|
|
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-
|
|
43
|
-
"@nx/workspace": "0.0.0-pr-
|
|
42
|
+
"@nx/devkit": "0.0.0-pr-30250-73071c2",
|
|
43
|
+
"@nx/workspace": "0.0.0-pr-30250-73071c2",
|
|
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,10 +52,11 @@
|
|
|
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",
|
|
56
55
|
"npm-package-arg": "11.0.1",
|
|
57
56
|
"npm-run-path": "^4.0.1",
|
|
58
57
|
"ora": "5.3.0",
|
|
58
|
+
"picocolors": "^1.1.0",
|
|
59
|
+
"picomatch": "4.0.2",
|
|
59
60
|
"semver": "^7.5.3",
|
|
60
61
|
"source-map-support": "0.5.19",
|
|
61
62
|
"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:
|
|
301
|
+
workspaceRoot: context.root,
|
|
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);
|
|
164
|
+
(0, plugin_1.ensureProjectIsIncludedInPluginRegistrations)(nxJson, options.projectRoot, options.bundler === 'none' ? null : 'build');
|
|
165
165
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
166
166
|
}
|
|
167
167
|
const projectConfiguration = {
|
|
@@ -719,9 +719,7 @@ function createProjectTsConfigs(tree, options) {
|
|
|
719
719
|
.map(([k, v]) => `${JSON.stringify(k)}: ${JSON.stringify(v)}`)
|
|
720
720
|
.join(',\n '),
|
|
721
721
|
tmpl: '',
|
|
722
|
-
outDir:
|
|
723
|
-
? 'dist'
|
|
724
|
-
: `out-tsc/${options.projectRoot.split('/').pop()}`,
|
|
722
|
+
outDir: 'dist',
|
|
725
723
|
emitDeclarationOnly: options.bundler === 'tsc' ? false : true,
|
|
726
724
|
});
|
|
727
725
|
// tsconfig.json
|
|
@@ -734,6 +732,12 @@ function createProjectTsConfigs(tree, options) {
|
|
|
734
732
|
json.references.push({
|
|
735
733
|
path: './tsconfig.lib.json',
|
|
736
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
|
+
}
|
|
737
741
|
return json;
|
|
738
742
|
});
|
|
739
743
|
}
|
|
@@ -745,6 +749,12 @@ function createProjectTsConfigs(tree, options) {
|
|
|
745
749
|
include: [],
|
|
746
750
|
references: [{ path: './tsconfig.lib.json' }],
|
|
747
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
|
+
}
|
|
748
758
|
(0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.json'), tsconfig);
|
|
749
759
|
// update root project tsconfig.json references with the new lib tsconfig
|
|
750
760
|
(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
|
|
6
|
+
const picomatch = require("picomatch");
|
|
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,7 +178,9 @@ 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' &&
|
|
181
|
+
if ((0, node_path_1.basename)(configFilePath) === 'tsconfig.json' &&
|
|
182
|
+
options.typecheck &&
|
|
183
|
+
tsConfig.raw?.['nx']?.addTypecheckTarget !== false) {
|
|
182
184
|
internalProjectReferences = resolveInternalProjectReferences(tsConfig, context.workspaceRoot, projectRoot);
|
|
183
185
|
const externalProjectReferences = resolveShallowExternalProjectReferences(tsConfig, context.workspaceRoot, projectRoot);
|
|
184
186
|
const targetName = options.typecheck.targetName;
|
|
@@ -276,8 +278,8 @@ function getInputs(namedInputs, configFilePath, tsConfig, internalProjectReferen
|
|
|
276
278
|
});
|
|
277
279
|
const normalize = (p) => (p.startsWith('./') ? p.slice(2) : p);
|
|
278
280
|
config.raw.exclude.forEach((excludePath) => {
|
|
279
|
-
if (!otherFilesInclude.some((includePath) => (
|
|
280
|
-
(
|
|
281
|
+
if (!otherFilesInclude.some((includePath) => picomatch(normalize(excludePath))(normalize(includePath)) ||
|
|
282
|
+
picomatch(normalize(includePath))(normalize(excludePath)))) {
|
|
281
283
|
excludePaths.add(excludePath);
|
|
282
284
|
}
|
|
283
285
|
});
|
|
@@ -554,7 +556,7 @@ function hasExternalProjectReferences(tsConfigPath, tsConfig, workspaceRoot, pro
|
|
|
554
556
|
return false;
|
|
555
557
|
}
|
|
556
558
|
function isExternalProjectReference(refTsConfigPath, workspaceRoot, projectRoot) {
|
|
557
|
-
const relativePath =
|
|
559
|
+
const relativePath = posixRelative(workspaceRoot, refTsConfigPath);
|
|
558
560
|
if (cache.isExternalProjectReference[relativePath] !== undefined) {
|
|
559
561
|
return cache.isExternalProjectReference[relativePath];
|
|
560
562
|
}
|
|
@@ -584,7 +586,7 @@ function getTsConfigDirName(tsConfigPath) {
|
|
|
584
586
|
: (0, node_path_1.normalize)(tsConfigPath);
|
|
585
587
|
}
|
|
586
588
|
function retrieveTsConfigFromCache(tsConfigPath, workspaceRoot) {
|
|
587
|
-
const relativePath =
|
|
589
|
+
const relativePath = posixRelative(workspaceRoot, tsConfigPath);
|
|
588
590
|
// we don't need to check the hash if it's in the cache, because we've already
|
|
589
591
|
// checked it when we initially populated the cache
|
|
590
592
|
return tsConfigCache[relativePath]
|
|
@@ -600,7 +602,7 @@ function initializeTsConfigCache(configFilePaths, workspaceRoot) {
|
|
|
600
602
|
}
|
|
601
603
|
}
|
|
602
604
|
function readTsConfigAndCache(tsConfigPath, workspaceRoot) {
|
|
603
|
-
const relativePath =
|
|
605
|
+
const relativePath = posixRelative(workspaceRoot, tsConfigPath);
|
|
604
606
|
const hash = getFileHash(tsConfigPath, workspaceRoot);
|
|
605
607
|
let extendedFilesHash;
|
|
606
608
|
if (tsConfigCache[relativePath] &&
|
|
@@ -716,7 +718,7 @@ function resolveExtendedTsConfigPath(tsConfigPath, directory) {
|
|
|
716
718
|
}
|
|
717
719
|
}
|
|
718
720
|
function getFileHash(filePath, workspaceRoot) {
|
|
719
|
-
const relativePath =
|
|
721
|
+
const relativePath = posixRelative(workspaceRoot, filePath);
|
|
720
722
|
if (!cache.fileHashes[relativePath]) {
|
|
721
723
|
const content = readFile(filePath, workspaceRoot);
|
|
722
724
|
cache.fileHashes[relativePath] = (0, file_hasher_1.hashArray)([content]);
|
|
@@ -724,7 +726,7 @@ function getFileHash(filePath, workspaceRoot) {
|
|
|
724
726
|
return cache.fileHashes[relativePath];
|
|
725
727
|
}
|
|
726
728
|
function readFile(filePath, workspaceRoot) {
|
|
727
|
-
const relativePath =
|
|
729
|
+
const relativePath = posixRelative(workspaceRoot, filePath);
|
|
728
730
|
if (!cache.rawFiles[relativePath]) {
|
|
729
731
|
const content = (0, node_fs_1.readFileSync)(filePath, 'utf8');
|
|
730
732
|
cache.rawFiles[relativePath] = content;
|
|
@@ -737,6 +739,9 @@ function toAbsolutePaths(cache, workspaceRoot) {
|
|
|
737
739
|
updatedCache[key] = {
|
|
738
740
|
data: {
|
|
739
741
|
options: { noEmit: data.options.noEmit },
|
|
742
|
+
raw: {
|
|
743
|
+
nx: { addTypecheckTarget: data.raw?.['nx']?.addTypecheckTarget },
|
|
744
|
+
},
|
|
740
745
|
extendedConfigFile: data.extendedConfigFile,
|
|
741
746
|
},
|
|
742
747
|
extendedFilesHash,
|
|
@@ -769,29 +774,38 @@ function toRelativePaths(cache, workspaceRoot) {
|
|
|
769
774
|
updatedCache[key] = {
|
|
770
775
|
data: {
|
|
771
776
|
options: { noEmit: data.options.noEmit },
|
|
777
|
+
raw: {
|
|
778
|
+
nx: { addTypecheckTarget: data.raw?.['nx']?.addTypecheckTarget },
|
|
779
|
+
},
|
|
772
780
|
extendedConfigFile: data.extendedConfigFile,
|
|
773
781
|
},
|
|
774
782
|
extendedFilesHash,
|
|
775
783
|
hash,
|
|
776
784
|
};
|
|
777
785
|
if (data.options.rootDir) {
|
|
778
|
-
updatedCache[key].data.options.rootDir =
|
|
786
|
+
updatedCache[key].data.options.rootDir = posixRelative(workspaceRoot, data.options.rootDir);
|
|
779
787
|
}
|
|
780
788
|
if (data.options.outDir) {
|
|
781
|
-
updatedCache[key].data.options.outDir =
|
|
789
|
+
updatedCache[key].data.options.outDir = posixRelative(workspaceRoot, data.options.outDir);
|
|
782
790
|
}
|
|
783
791
|
if (data.options.outFile) {
|
|
784
|
-
updatedCache[key].data.options.outFile =
|
|
792
|
+
updatedCache[key].data.options.outFile = posixRelative(workspaceRoot, data.options.outFile);
|
|
785
793
|
}
|
|
786
794
|
if (data.options.tsBuildInfoFile) {
|
|
787
|
-
updatedCache[key].data.options.tsBuildInfoFile =
|
|
795
|
+
updatedCache[key].data.options.tsBuildInfoFile = posixRelative(workspaceRoot, data.options.tsBuildInfoFile);
|
|
788
796
|
}
|
|
789
797
|
if (data.extendedConfigFile?.filePath) {
|
|
790
|
-
updatedCache[key].data.extendedConfigFile.filePath =
|
|
798
|
+
updatedCache[key].data.extendedConfigFile.filePath = posixRelative(workspaceRoot, data.extendedConfigFile.filePath);
|
|
791
799
|
}
|
|
792
800
|
if (data.projectReferences) {
|
|
793
|
-
updatedCache[key].data.projectReferences = data.projectReferences.map((ref) => ({
|
|
801
|
+
updatedCache[key].data.projectReferences = data.projectReferences.map((ref) => ({
|
|
802
|
+
...ref,
|
|
803
|
+
path: posixRelative(workspaceRoot, ref.path),
|
|
804
|
+
}));
|
|
794
805
|
}
|
|
795
806
|
}
|
|
796
807
|
return updatedCache;
|
|
797
808
|
}
|
|
809
|
+
function posixRelative(workspaceRoot, path) {
|
|
810
|
+
return posix.normalize((0, node_path_1.relative)(workspaceRoot, path));
|
|
811
|
+
}
|
|
@@ -27,7 +27,6 @@ function addBuildAndWatchDepsTargets(workspaceRoot, projectRoot, targets, option
|
|
|
27
27
|
dependsOn: ['^build'],
|
|
28
28
|
};
|
|
29
29
|
targets[options.watchDepsTargetName ?? 'watch-deps'] = {
|
|
30
|
-
continuous: true,
|
|
31
30
|
dependsOn: [buildDepsTargetName],
|
|
32
31
|
command: `${pmc.exec} nx watch --projects ${projectName} --includeDependentProjects -- ${pmc.exec} nx ${buildDepsTargetName} ${projectName}`,
|
|
33
32
|
};
|
|
@@ -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
|
|
4
|
+
const picomatch = require("picomatch");
|
|
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,6 +9,7 @@ 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");
|
|
12
13
|
const defaultFileEventHandler = (events) => {
|
|
13
14
|
const dirs = new Set(events.map((event) => path.dirname(event.dest)));
|
|
14
15
|
dirs.forEach((d) => (0, node_fs_1.mkdirSync)(d, { recursive: true }));
|
|
@@ -24,6 +25,9 @@ const defaultFileEventHandler = (events) => {
|
|
|
24
25
|
else {
|
|
25
26
|
devkit_1.logger.error(`Unknown file event: ${event.type}`);
|
|
26
27
|
}
|
|
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)}`);
|
|
27
31
|
});
|
|
28
32
|
};
|
|
29
33
|
exports.defaultFileEventHandler = defaultFileEventHandler;
|
|
@@ -115,10 +119,12 @@ class CopyAssetsHandler {
|
|
|
115
119
|
async processWatchEvents(events) {
|
|
116
120
|
const fileEvents = [];
|
|
117
121
|
for (const event of events) {
|
|
118
|
-
const pathFromRoot = path.
|
|
122
|
+
const pathFromRoot = event.path.startsWith(this.rootDir)
|
|
123
|
+
? path.relative(this.rootDir, event.path)
|
|
124
|
+
: event.path;
|
|
119
125
|
for (const ag of this.assetGlobs) {
|
|
120
|
-
if ((
|
|
121
|
-
!ag.ignore?.some((ig) => (
|
|
126
|
+
if (picomatch(ag.pattern)(pathFromRoot) &&
|
|
127
|
+
!ag.ignore?.some((ig) => picomatch(ig)(pathFromRoot)) &&
|
|
122
128
|
!this.ignore.ignores(pathFromRoot)) {
|
|
123
129
|
const relPath = path.relative(ag.input, pathFromRoot);
|
|
124
130
|
const destPath = relPath.startsWith('..') ? pathFromRoot : relPath;
|
|
@@ -137,7 +143,7 @@ class CopyAssetsHandler {
|
|
|
137
143
|
}
|
|
138
144
|
filesToEvent(files, assetGlob) {
|
|
139
145
|
return files.reduce((acc, src) => {
|
|
140
|
-
if (!assetGlob.ignore?.some((ig) => (
|
|
146
|
+
if (!assetGlob.ignore?.some((ig) => picomatch(ig)(src)) &&
|
|
141
147
|
!this.ignore.ignores(src)) {
|
|
142
148
|
const relPath = path.relative(assetGlob.input, src);
|
|
143
149
|
const dest = relPath.startsWith('..') ? src : relPath;
|
|
@@ -16,6 +16,7 @@ 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");
|
|
19
20
|
function isBuildable(target, node) {
|
|
20
21
|
return (node.data.targets &&
|
|
21
22
|
node.data.targets[target] &&
|
|
@@ -229,7 +230,7 @@ function computeCompilerOptionsPaths(tsConfig, dependencies) {
|
|
|
229
230
|
return paths;
|
|
230
231
|
}
|
|
231
232
|
function createTmpTsConfig(tsconfigPath, workspaceRoot, projectRoot, dependencies, useWorkspaceAsBaseUrl = false) {
|
|
232
|
-
const tmpTsConfigPath = (0, path_1.join)(workspaceRoot, 'tmp', projectRoot, process.env.NX_TASK_TARGET_TARGET ?? 'build',
|
|
233
|
+
const tmpTsConfigPath = (0, path_1.join)(workspaceRoot, 'tmp', projectRoot, process.env.NX_TASK_TARGET_TARGET ?? 'build', `tsconfig.generated.${(0, crypto_1.randomUUID)()}.json`);
|
|
233
234
|
if (tsconfigPath === tmpTsConfigPath) {
|
|
234
235
|
return tsconfigPath;
|
|
235
236
|
}
|
|
@@ -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
|
|
8
|
+
const picomatch = require("picomatch");
|
|
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,17 +13,18 @@ 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 }))
|
|
17
|
-
|
|
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')));
|
|
18
22
|
return isIncluded ? 'included' : 'excluded';
|
|
19
23
|
}
|
|
20
24
|
function isUsingPackageManagerWorkspaces(tree) {
|
|
21
25
|
return isWorkspacesEnabled(tree);
|
|
22
26
|
}
|
|
23
|
-
function isWorkspacesEnabled(tree
|
|
24
|
-
// packageManager: PackageManager = detectPackageManager(),
|
|
25
|
-
// root: string = workspaceRoot
|
|
26
|
-
) {
|
|
27
|
+
function isWorkspacesEnabled(tree) {
|
|
27
28
|
const packageManager = (0, devkit_1.detectPackageManager)(tree.root);
|
|
28
29
|
if (packageManager === 'pnpm') {
|
|
29
30
|
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
|
|
2
|
+
export declare function ensureProjectIsIncludedInPluginRegistrations(nxJson: NxJsonConfiguration, projectRoot: string, buildTargetName: string | null): 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) {
|
|
7
7
|
nxJson.plugins ??= [];
|
|
8
8
|
let isIncluded = false;
|
|
9
9
|
let index = 0;
|
|
@@ -13,12 +13,17 @@ function ensureProjectIsIncludedInPluginRegistrations(nxJson, projectRoot, build
|
|
|
13
13
|
continue;
|
|
14
14
|
}
|
|
15
15
|
if (typeof registration === 'string') {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
+
}
|
|
22
27
|
}
|
|
23
28
|
else {
|
|
24
29
|
// check if the project would be included by the plugin registration
|
|
@@ -27,7 +32,7 @@ function ensureProjectIsIncludedInPluginRegistrations(nxJson, projectRoot, build
|
|
|
27
32
|
// it's included by the plugin registration, check if the user-specified options would result
|
|
28
33
|
// in the appropriate build task being inferred, if not, we need to exclude it
|
|
29
34
|
if (registration.options?.typecheck !== false &&
|
|
30
|
-
|
|
35
|
+
matchesBuildTargetDefinition(registration.options?.build, buildTargetName)) {
|
|
31
36
|
// it has the desired options, do nothing, but continue processing
|
|
32
37
|
// other registrations to exclude as needed
|
|
33
38
|
isIncluded = true;
|
|
@@ -40,7 +45,7 @@ function ensureProjectIsIncludedInPluginRegistrations(nxJson, projectRoot, build
|
|
|
40
45
|
}
|
|
41
46
|
else if (!isIncluded &&
|
|
42
47
|
registration.options?.typecheck !== false &&
|
|
43
|
-
|
|
48
|
+
matchesBuildTargetDefinition(registration.options?.build, buildTargetName)) {
|
|
44
49
|
if (!registration.exclude?.length) {
|
|
45
50
|
// negative pattern are not supported by the `exclude` option so we
|
|
46
51
|
// can't update it to not exclude the project, so we only update the
|
|
@@ -66,17 +71,20 @@ function ensureProjectIsIncludedInPluginRegistrations(nxJson, projectRoot, build
|
|
|
66
71
|
if (!isIncluded) {
|
|
67
72
|
// the project is not included by any plugin registration with an inferred build task
|
|
68
73
|
// with the given name, so we create a new plugin registration for it
|
|
69
|
-
|
|
74
|
+
const registration = {
|
|
70
75
|
plugin: '@nx/js/typescript',
|
|
71
76
|
include: [`${projectRoot}/*`],
|
|
72
77
|
options: {
|
|
73
78
|
typecheck: { targetName: 'typecheck' },
|
|
74
|
-
build: {
|
|
75
|
-
targetName: buildTargetName,
|
|
76
|
-
configName: 'tsconfig.lib.json',
|
|
77
|
-
},
|
|
78
79
|
},
|
|
79
|
-
}
|
|
80
|
+
};
|
|
81
|
+
if (buildTargetName) {
|
|
82
|
+
registration.options.build = {
|
|
83
|
+
targetName: buildTargetName,
|
|
84
|
+
configName: 'tsconfig.lib.json',
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
nxJson.plugins.push(registration);
|
|
80
88
|
}
|
|
81
89
|
}
|
|
82
90
|
function ensureProjectIsExcludedFromPluginRegistrations(nxJson, projectRoot) {
|
|
@@ -115,8 +123,11 @@ function isTypeScriptPluginRegistration(plugin) {
|
|
|
115
123
|
return ((typeof plugin === 'string' && plugin === '@nx/js/typescript') ||
|
|
116
124
|
(typeof plugin !== 'string' && plugin.plugin === '@nx/js/typescript'));
|
|
117
125
|
}
|
|
118
|
-
function
|
|
126
|
+
function matchesBuildTargetDefinition(buildOptions, buildTargetName) {
|
|
119
127
|
if (buildOptions === undefined || buildOptions === false) {
|
|
128
|
+
return !buildTargetName;
|
|
129
|
+
}
|
|
130
|
+
if (!buildTargetName) {
|
|
120
131
|
return false;
|
|
121
132
|
}
|
|
122
133
|
if (buildOptions === true && buildTargetName === 'build') {
|
|
@@ -90,9 +90,7 @@ 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
|
-
|
|
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)),
|
|
93
|
+
outDir: 'dist',
|
|
96
94
|
rootDir,
|
|
97
95
|
...compilerOptions,
|
|
98
96
|
};
|
|
@@ -146,6 +144,10 @@ function updateTsconfigFiles(tree, projectRoot, runtimeTsconfigFileName, compile
|
|
|
146
144
|
}
|
|
147
145
|
}
|
|
148
146
|
function addProjectToTsSolutionWorkspace(tree, projectDir) {
|
|
147
|
+
const state = (0, package_manager_workspaces_1.getProjectPackageManagerWorkspaceState)(tree, projectDir);
|
|
148
|
+
if (state === 'included') {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
149
151
|
// If dir is "libs/foo" then use "libs/*" so we don't need so many entries in the workspace file.
|
|
150
152
|
// If dir is nested like "libs/shared/foo" then we add "libs/shared/*".
|
|
151
153
|
// If the dir is just "foo" then we have to add it as is.
|