Skip to content

Changes in .ts files are ignored on 2nd and next builds for indirect includes (--build) #49655

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
michal-minich opened this issue Jun 23, 2022 · 5 comments
Assignees
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@michal-minich
Copy link

michal-minich commented Jun 23, 2022

Bug Report

πŸ”Ž Search Terms

I tried many searches but did not find this issue. Though this issue looks related #49527

πŸ•— Version & Regression Information

This behaviors occurs at least on 4.7.4 and 4.8.0-beta.

⏯ Playground Link

I was not able to setup Bug Workbench playground because I was not able to make it work with @files switch, even if it is documented it should work.

πŸ’» Code

// @filename: index.ts
import  { pi } from "./utils";
console.log(pi);

// @filename: utils.ts
export const pi = 3.14;

// @filename: tsconfig.json
{
  "files": ["index.ts"],
  "compilerOptions": { "outDir": "./out" }
}

πŸ™ Actual behavior

  1. Invoke compiler with tsc --build, it builds successfully, producing index.ts and utils.ts, and skips files which are not imported, if any.
  2. Change the value of the pi constant or make syntactic error in utils.ts file.
  3. Invoke compiler again with the same command.
  4. The compiler finishes without error (if there is one), also .js files are not updated.

πŸ™‚ Expected behavior

  • I expect the compiler to emit an error in step 4, if there is one, and also emit .js file.
  • If this is invalid configuration, which I hope it isn't, then I would expect it will fail on first build.

There is another scenario which behave the same way. When instead of files the included options is used, but pointing only to folder where index.ts files is. The utils.ts has to be in different folder.


Originally I started investigating regression in 4.8.0-beta on existing project which uses incremental build and only one "index" file in the files tsconfig option. There the first build passes OK, but after I change code or make error in a file, the build finishes without doing any work (reporting error or emitting code). Also the 2nd and all next builds are very quick - less than 1s. Where for 4.7.4 it took several seconds. Yet in the case of the full project the 4.7.4 (and many previous versions) behaves as expected, which is not in case of this simplified code. So there might be more special cases of this issue.

@fatcerberus
Copy link

Possibly related: #49543?

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Jun 23, 2022
@sheetalkamat
Copy link
Member

This is working as intended. tsc --build at moment can only look at the files that are listed by your tsconfig, which in your case is index.ts so changes to utils.ts will not be picked up. composite option lets you make sure that all source files are root files.

You can use --explainFiles. Files included per tsconfig are the only ones that get checked against the output for upto date ness.

utils.ts
  Imported via "./utils" from file 'index.ts' 
index.ts
  Part of 'files' list in tsconfig.json

@sheetalkamat sheetalkamat added Working as Intended The behavior described is the intended behavior; this is not a bug and removed Needs Investigation This issue needs a team member to investigate its status. labels Jun 23, 2022
@michal-minich
Copy link
Author

On first compiler run, the --explainFiles produces file listing. On 2nd run, the listing is empty. Is this expected?

I tried to use touch index.ts to update modified date on the main file before build - and this enough to achieved expected behavior. Then the compiler will also check the imported files for modifications. Also it produces the "explain files" listing.

Please note that in my case it is not desirable to include all files using glob pattern like "*" as there are more builds, and each should output only files that are actually imported from the "main" file.

@sheetalkamat
Copy link
Member

On first compiler run, the --explainFiles produces file listing. On 2nd run, the listing is empty. Is this expected?

second run shows that based on your config, index.ts and index.js are uptodate and hence project is not built. You can run tsc --build --v to see if and why project is uptodate vs built

@typescript-bot
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

5 participants