Skip to content
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

tsc --build takes wrong assumption on project rootDir #41801

Closed
sguillia opened this issue Dec 3, 2020 · 5 comments · Fixed by #41811
Closed

tsc --build takes wrong assumption on project rootDir #41801

sguillia opened this issue Dec 3, 2020 · 5 comments · Fixed by #41811
Assignees
Labels
Bug A bug in TypeScript Duplicate An existing issue was already created Fix Available A PR has been opened for this issue

Comments

@sguillia
Copy link

sguillia commented Dec 3, 2020

TypeScript Version: 4.2.0-dev.2020120

Search Terms: tsc, project reference, inconsistent rootdir, builds again

Code

https://github.com/sguillia/ts-bug-repro-II

// No code, an empty TS file is enough to reproduce.
tsc --build --verbose
tsc --build --verbose

Expected behavior:

Project was built once.

Actual behavior:

Project was built twice.

Playground Link:

No playground link. Typescript Playground does not offer the outDir option.

Related Issues: not found, sorry

Additional information

Second build logs this message:

[14:36:00] Project 'tsconfig.json' is out of date because output file 'dist/src/index.js' does not exist

dist/src/index.js is not supposed to exist. dist/index.js does.

Setting the following setting in the tsconfig.json fixes the problem:

"rootDir": "./src"

But the actual behavior should be consistent even without the rootDir setting

As explained here in the docs, tsc --build is supposed to consistently detect whether the project is up-to-date.

@benmccann
Copy link
Contributor

benmccann commented Dec 3, 2020

This is the same behavior I reported in #41780. In that bug, getOutputFileNames was being called directly by the Rollup Plugin and returning dist/src/index.js instead of dist/index.js. I wonder if tsc follows a different code path that also uses the broken implementation of getOutputFileNames when the --build option is used. I have a lot of details in that bug about the issue. I'd love if we could get it looked at before 4.2.1 since that means it won't be addressed for months still despite hitting so many people

@sheetalkamat sheetalkamat added Bug A bug in TypeScript Duplicate An existing issue was already created Fix Available A PR has been opened for this issue labels Dec 3, 2020
@sheetalkamat
Copy link
Member

Duplicate of #41780

@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

sheetalkamat added a commit that referenced this issue Dec 7, 2020
…am emit file path calculation (#41811)

* Baseline showing #41801 and other issues with output path calculation

* Add a way to note descripencies between clean and incremental build

* Add descripency when no rootDir is specified but project is composite

* if rootDir is specified, irrespective of whether all files belong to rootDir, the paths should be calculated from rootDir

* Fix the output file names api to use the correct common source directory

* Tests for #41780

* Spelling
scalder27 pushed a commit to scalder27/TypeScript that referenced this issue Dec 7, 2020
…am emit file path calculation (microsoft#41811)

* Baseline showing microsoft#41801 and other issues with output path calculation

* Add a way to note descripencies between clean and incremental build

* Add descripency when no rootDir is specified but project is composite

* if rootDir is specified, irrespective of whether all files belong to rootDir, the paths should be calculated from rootDir

* Fix the output file names api to use the correct common source directory

* Tests for microsoft#41780

* Spelling
@klauszhang
Copy link

Why this is still happening after almost one year? This wasted me entire afternoon :(

@sguillia
Copy link
Author

sguillia commented Nov 8, 2021

@klauszhang The bug described above does not happen anymore on my computer with latest typescript version.
Consider updating typescript or opening a new ticket

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Duplicate An existing issue was already created Fix Available A PR has been opened for this issue
Projects
None yet
5 participants