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

Incremental doesn't rebuild when dependent package's type changed in a workspace/monorepo #57780

Closed
curtisman opened this issue Mar 14, 2024 · 5 comments
Labels
Not a Defect This behavior is one of several equally-correct options

Comments

@curtisman
Copy link
Member

curtisman commented Mar 14, 2024

πŸ”Ž Search Terms

incremental, monorepo, workspaces, rebuild

πŸ•— Version & Regression Information

Repro since --incremental is introduced in 3.4

⏯ Playground Link

https://github.com/curtisman/repro

πŸ’» Code

--incremental with--build doesn't rebuild packages if when dependent package's .d.ts files changed in a workspace/monorepo setup. This repo demostrates the setup.

It has two packages a and b in a npm workspace (should repo with other workspace/monorepo setup).
Package a depends on b. When the type of the function export from b is changed, the incremental build in package a doesn't detect the change and rebuild (and error) when -b is used.

Repro steps:

  • Clone the repo
  • npm install at root
  • npm run build at root
  • Go to packages/b/src/b.ts and change the return value from the number 3 to string "b"
  • npm run build at root again.

πŸ™ Actual behavior

No error detect in the package a.

πŸ™‚ Expected behavior

Error detected in the package a.

src/part1/a1.ts:3:7 - error TS2322: Type 'string' is not assignable to type 'number'.

3 const value: number = a2();
        ~~~~~


Found 1 error in src/part1/a1.ts:3

Additional information about the issue

npm run build:project in the repo will use -p to build instead of -b, and it has the expected behavior.

@sheetalkamat
Copy link
Member

This is working as intended. ``--build only cares about time stamps of your project files or any references in tsconfig. packages/a does not reference package/b so there is no way of knowing changes in b should also be accounted for. (--build` does not account for failed resolutions/ files already compiled as part of your projects etc)

@curtisman
Copy link
Member Author

I see. I guess the recommendation is to not use --build in this kind of set up, or specify cross package project references (which doesn't feel right)?

@curtisman
Copy link
Member Author

Also, doesn't the tsbuildinfo file has all the input and referenced files and hash, can that be used to detect if b.d.ts changed?

@sheetalkamat
Copy link
Member

Two things play there: Not all projects will have tsbuildInfo .. its not mandatory if the project is not referenced. We have so far kept similar approach but have thought of doing extra in case of buildInfo but it involves checking modified time of more files and in repro where there are many projects with lots of d.ts files (that arent listed as files the project depends on explicitly) it adds up so this has been in backlog to experiment for a while and not guaranteed to change soon.

@RyanCavanaugh RyanCavanaugh added the Not a Defect This behavior is one of several equally-correct options label Mar 15, 2024
@typescript-bot
Copy link
Collaborator

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

@typescript-bot typescript-bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Not a Defect This behavior is one of several equally-correct options
Projects
None yet
Development

No branches or pull requests

4 participants