Skip to content

Wrong detection of up-to-date state composite project with no included files #31288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
timocov opened this issue May 7, 2019 · 0 comments · Fixed by #32027
Closed

Wrong detection of up-to-date state composite project with no included files #31288

timocov opened this issue May 7, 2019 · 0 comments · Fixed by #32027
Assignees
Labels
Bug A bug in TypeScript Domain: tsc -b Issues related to build mode Fixed A PR has been merged for this issue

Comments

@timocov
Copy link
Contributor

timocov commented May 7, 2019

TypeScript Version: 3.5.0-dev.20190507, 3.4.4

Search Terms: composite projects

Let's say we have a composite project with the following structure:

├── src
│   ├── folder
│   │   ├── index.ts
│   │   ├── tsconfig.json
│   ├── folder2
│   │   ├── index.ts
│   │   ├── tsconfig.json
│   └── tsconfig.json
├── tests
│   ├── index.ts
│   ├── tsconfig.json
└── tsconfig.json

where src/tsconfig.json refers to src/folder and src/folder2 composite sub-projects, tests/tsconfig.json refers to src/ and includes tests/index.ts module. Both src/folder and src/folder2 projects includes they local index.ts modules.

tsconfig.json from the root refers to src/ and tests/ sub-projects.

So, such project we build via ./node_modules/.bin/tsc -b . --verbose.

For the first run we have the following output:

[15:55:32] Projects in this build:
    * src/folder/tsconfig.json
    * src/folder2/tsconfig.json
    * src/tsconfig.json
    * tests/tsconfig.json
    * tsconfig.json

[15:55:32] Project 'src/folder/tsconfig.json' is out of date because output file 'src/folder/index.js' does not exist

[15:55:32] Building project 'src/folder/tsconfig.json'...

[15:55:35] Project 'src/folder2/tsconfig.json' is out of date because output file 'src/folder2/index.js' does not exist

[15:55:35] Building project 'src/folder2/tsconfig.json'...

[15:55:36] Project 'tests/tsconfig.json' is out of date because its dependency 'src' is out of date

[15:55:36] Building project 'tests/tsconfig.json'...

It looks fine for now. But if we compile it in the next time without any change of the code we'll get the following:

[15:57:11] Projects in this build:
    * src/folder/tsconfig.json
    * src/folder2/tsconfig.json
    * src/tsconfig.json
    * tests/tsconfig.json
    * tsconfig.json

[15:57:11] Project 'src/folder/tsconfig.json' is up to date because newest input 'src/folder/index.ts' is older than oldest output 'src/folder/index.js'

[15:57:11] Project 'src/folder2/tsconfig.json' is up to date because newest input 'src/folder2/index.ts' is older than oldest output 'src/folder2/index.js'

[15:57:11] Project 'tests/tsconfig.json' is out of date because its dependency 'src' is out of date

[15:57:11] Building project 'tests/tsconfig.json'...

[15:57:12] Updating unchanged output timestamps of project 'tests/tsconfig.json'...

As you can see, the compiler treats tests/tsconfig.json project as out of date because of out of date src project. But we don't change anything.

It looks like the problem happens only if a project refers to another project(s) without including any file (src/tsconfig.json refers to src/folder and src/folder2 and include nothing).

If we add any file to src/tsconfig.json project no recompilation of tests happened.

Note: according #3469 (comment)

Another good practice is to have a "solution" tsconfig.json file that simply has references to all of your leaf-node projects.

Code

Here is zip with a project I describe above, just unzip it, run npm install and then run twice npm run build.

bug.zip

Expected behavior:

No recompilation in the second time if we change nothing.

Actual behavior:

Recompilation on each build even if we change nothing.

Related Issues: #3469

@weswigham weswigham added Bug A bug in TypeScript Domain: tsc -b Issues related to build mode labels May 8, 2019
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.6.0 milestone Jun 12, 2019
@sheetalkamat sheetalkamat added the Fixed A PR has been merged for this issue label Jun 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: tsc -b Issues related to build mode Fixed A PR has been merged for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants