Skip to content

Commit 7afc037

Browse files
committed
fix: recompute dependencies on every run
Currently, we recompute dependencies only if fileNames for the main configuration changes. It doesn't handle the case when we have project references.
1 parent dcd1a6f commit 7afc037

File tree

4 files changed

+36
-28
lines changed

4 files changed

+36
-28
lines changed

src/typescript-reporter/reporter/TypeScriptReporter.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -266,16 +266,15 @@ function createTypeScriptReporter(configuration: TypeScriptReporterConfiguration
266266
diagnosticsPerProject.clear();
267267
configurationChanged = true;
268268
} else {
269-
const previousParsedConfiguration = parsedConfiguration;
269+
const previousDependencies = dependencies;
270270
[parsedConfiguration, parseConfigurationDiagnostics] = parseConfiguration();
271+
dependencies = getDependencies();
271272

272273
if (
273-
previousParsedConfiguration &&
274-
JSON.stringify(previousParsedConfiguration.fileNames) !==
275-
JSON.stringify(parsedConfiguration.fileNames)
274+
previousDependencies &&
275+
JSON.stringify(previousDependencies) !== JSON.stringify(dependencies)
276276
) {
277-
// root files changed - we need to recompute dependencies and artifacts
278-
dependencies = getDependencies();
277+
// dependencies changed - we need to recompute artifacts
279278
artifacts = getArtifacts();
280279
shouldUpdateRootFiles = true;
281280
}

test/e2e/TypeScriptSolutionBuilderApi.spec.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ describe('TypeScript SolutionBuilder API', () => {
105105
await driver.waitForNoErrors();
106106

107107
await sandbox.write('packages/client/src/nested/additional.ts', 'export const x = 10;');
108+
109+
// this compilation should be successful
110+
await driver.waitForNoErrors();
111+
108112
await sandbox.patch(
109113
'packages/client/src/index.ts',
110114
'import { intersect, subtract } from "@project-references-fixture/shared";',
@@ -125,31 +129,31 @@ describe('TypeScript SolutionBuilder API', () => {
125129
break;
126130

127131
case 'write-tsbuildinfo':
128-
expect(await sandbox.exists('packages/shared/tsconfig.tsbuildinfo')).toEqual(true);
129-
expect(await sandbox.exists('packages/client/tsconfig.tsbuildinfo')).toEqual(true);
130-
expect(await sandbox.exists('packages/shared/lib')).toEqual(false);
131-
expect(await sandbox.exists('packages/client/lib')).toEqual(false);
132+
expect(await sandbox.exists('packages/shared/lib/tsconfig.tsbuildinfo')).toEqual(true);
133+
expect(await sandbox.exists('packages/client/lib/tsconfig.tsbuildinfo')).toEqual(true);
134+
expect(await sandbox.exists('packages/shared/lib')).toEqual(true);
135+
expect(await sandbox.exists('packages/client/lib')).toEqual(true);
136+
expect(await sandbox.exists('packages/shared/lib/index.js')).toEqual(false);
137+
expect(await sandbox.exists('packages/client/lib/index.js')).toEqual(false);
132138

133-
expect(await sandbox.read('packages/shared/tsconfig.tsbuildinfo')).not.toEqual('');
134-
expect(await sandbox.read('packages/client/tsconfig.tsbuildinfo')).not.toEqual('');
139+
expect(await sandbox.read('packages/shared/lib/tsconfig.tsbuildinfo')).not.toEqual('');
140+
expect(await sandbox.read('packages/client/lib/tsconfig.tsbuildinfo')).not.toEqual('');
135141

136-
await sandbox.remove('packages/shared/tsconfig.tsbuildinfo');
137-
await sandbox.remove('packages/client/tsconfig.tsbuildinfo');
142+
await sandbox.remove('packages/shared/lib');
143+
await sandbox.remove('packages/client/lib');
138144
break;
139145

140146
case 'write-references':
141-
expect(await sandbox.exists('packages/shared/tsconfig.tsbuildinfo')).toEqual(true);
142-
expect(await sandbox.exists('packages/client/tsconfig.tsbuildinfo')).toEqual(true);
147+
expect(await sandbox.exists('packages/shared/lib/tsconfig.tsbuildinfo')).toEqual(true);
148+
expect(await sandbox.exists('packages/client/lib/tsconfig.tsbuildinfo')).toEqual(true);
143149
expect(await sandbox.exists('packages/shared/lib')).toEqual(true);
144150
expect(await sandbox.exists('packages/client/lib')).toEqual(true);
145151
expect(await sandbox.exists('packages/shared/lib/index.js')).toEqual(true);
146152
expect(await sandbox.exists('packages/client/lib/index.js')).toEqual(true);
147153

148-
expect(await sandbox.read('packages/shared/tsconfig.tsbuildinfo')).not.toEqual('');
149-
expect(await sandbox.read('packages/client/tsconfig.tsbuildinfo')).not.toEqual('');
154+
expect(await sandbox.read('packages/shared/lib/tsconfig.tsbuildinfo')).not.toEqual('');
155+
expect(await sandbox.read('packages/client/lib/tsconfig.tsbuildinfo')).not.toEqual('');
150156

151-
await sandbox.remove('packages/shared/tsconfig.tsbuildinfo');
152-
await sandbox.remove('packages/client/tsconfig.tsbuildinfo');
153157
await sandbox.remove('packages/shared/lib');
154158
await sandbox.remove('packages/client/lib');
155159
break;

test/e2e/fixtures/environment/typescript-monorepo.fixture

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
}
2424
}
2525

26-
/// tsconfig.json
26+
/// tsconfig.base.json
2727
{
2828
"compilerOptions": {
2929
"target": "es5",
@@ -42,7 +42,12 @@
4242
"declarationMap": true,
4343
"sourceMap": true,
4444
"rootDir": "./packages"
45-
},
45+
}
46+
}
47+
48+
/// tsconfig.json
49+
{
50+
"extends": "./tsconfig.base.json",
4651
"files": [],
4752
"references": [
4853
{ "path": "./packages/shared" },

test/e2e/fixtures/implementation/typescript-monorepo.fixture

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212

1313
/// packages/shared/tsconfig.json
1414
{
15-
"extends": "../../tsconfig",
15+
"extends": "../../tsconfig.base.json",
1616
"compilerOptions": {
1717
"rootDir": "./src",
1818
"outDir": "./lib",
19+
"tsBuildInfoFile": "lib/tsconfig.tsbuildinfo",
1920
"sourceRoot": "./src",
2021
"baseUrl": "./src"
2122
},
22-
"include": ["src"],
23-
"exclude": ["node_modules", "lib"]
23+
"include": ["src"]
2424
}
2525

2626
/// packages/shared/src/intersect.ts
@@ -63,16 +63,16 @@ export {
6363

6464
/// packages/client/tsconfig.json
6565
{
66-
"extends": "../../tsconfig",
66+
"extends": "../../tsconfig.base.json",
6767
"compilerOptions": {
6868
"rootDir": "./src",
6969
"outDir": "./lib",
70+
"tsBuildInfoFile": "lib/tsconfig.tsbuildinfo",
7071
"sourceRoot": "./src",
7172
"baseUrl": "./src"
7273
},
7374
"references": [{ "path": "../shared" }],
74-
"include": ["src"],
75-
"exclude": ["node_modules", "lib"]
75+
"include": ["src"]
7676
}
7777

7878

0 commit comments

Comments
 (0)