Skip to content

Commit 67ecff1

Browse files
authored
fix(js): do not infer typecheck target for root tsconfig.json (#27950)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
1 parent 81d3529 commit 67ecff1

File tree

2 files changed

+6
-73
lines changed

2 files changed

+6
-73
lines changed

packages/js/src/plugins/typescript/plugin.spec.ts

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -34,85 +34,13 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => {
3434
process.env.NX_CACHE_PROJECT_GRAPH = originalCacheProjectGraph;
3535
});
3636

37-
it('should create nodes for root tsconfig.json files', async () => {
37+
it('should not create nodes for root tsconfig.json files', async () => {
3838
await applyFilesToTempFsAndContext(tempFs, context, {
3939
'package.json': `{}`,
4040
'project.json': `{}`,
4141
'tsconfig.json': `{}`,
4242
'src/index.ts': `console.log('Hello World!');`,
4343
});
44-
expect(await invokeCreateNodesOnMatchingFiles(context, {}))
45-
.toMatchInlineSnapshot(`
46-
{
47-
"projects": {
48-
".": {
49-
"projectType": "library",
50-
"targets": {
51-
"typecheck": {
52-
"cache": true,
53-
"command": "tsc --build --emitDeclarationOnly --pretty --verbose",
54-
"dependsOn": [
55-
"^typecheck",
56-
],
57-
"inputs": [
58-
"production",
59-
"^production",
60-
{
61-
"externalDependencies": [
62-
"typescript",
63-
],
64-
},
65-
],
66-
"metadata": {
67-
"description": "Runs type-checking for the project.",
68-
"help": {
69-
"command": "npx tsc --build --help",
70-
"example": {
71-
"args": [
72-
"--force",
73-
],
74-
},
75-
},
76-
"technologies": [
77-
"typescript",
78-
],
79-
},
80-
"options": {
81-
"cwd": ".",
82-
},
83-
"outputs": [
84-
"{projectRoot}/**/*.js",
85-
"{projectRoot}/**/*.cjs",
86-
"{projectRoot}/**/*.mjs",
87-
"{projectRoot}/**/*.jsx",
88-
"{projectRoot}/**/*.js.map",
89-
"{projectRoot}/**/*.jsx.map",
90-
"{projectRoot}/**/*.d.ts",
91-
"{projectRoot}/**/*.d.cts",
92-
"{projectRoot}/**/*.d.mts",
93-
"{projectRoot}/**/*.d.ts.map",
94-
"{projectRoot}/**/*.d.cts.map",
95-
"{projectRoot}/**/*.d.mts.map",
96-
"{projectRoot}/tsconfig.tsbuildinfo",
97-
],
98-
"syncGenerators": [
99-
"@nx/js:typescript-sync",
100-
],
101-
},
102-
},
103-
},
104-
},
105-
}
106-
`);
107-
});
108-
109-
it('should not create nodes when it is not a tsconfig.json file and there is no sibling tsconfig.json file', async () => {
110-
await applyFilesToTempFsAndContext(tempFs, context, {
111-
'package.json': `{}`,
112-
'project.json': `{}`,
113-
'tsconfig.base.json': `{}`,
114-
'src/index.ts': `console.log('Hello World!');`,
115-
});
11644
expect(await invokeCreateNodesOnMatchingFiles(context, {}))
11745
.toMatchInlineSnapshot(`
11846
{

packages/js/src/plugins/typescript/plugin.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ async function createNodesInternal(
128128
configFilePath
129129
);
130130

131+
// Do not create a project for the workspace root tsconfig files.
132+
if (projectRoot === '.') {
133+
return {};
134+
}
135+
131136
// Do not create a project if package.json and project.json isn't there.
132137
const siblingFiles = readdirSync(join(context.workspaceRoot, projectRoot));
133138
if (

0 commit comments

Comments
 (0)