ojkelly / yarn.build

Build 🛠 and Bundle 📦 your local workspaces. Like Bazel, Buck, Pants and Please but for Yarn Berry. Build any language, mix javascript, typescript, golang and more in one polyglot repo. Ship your bundles to AWS Lambda, Docker, or any nodejs runtime.
https://yarn.BUILD
MIT License
325 stars 28 forks source link

`yarn build` looking at last modified date #265

Closed tibo-mllr closed 1 year ago

tibo-mllr commented 1 year ago

Describe the bug Hi everyone, I ran into a problem with yarn build, because I cancelled changes and deleted files in a folder, but when rebuilding, it still kept those files, which wasn't okay with the other apps using this folder. While searching for a solution, I arrived on this issue: https://github.com/ojkelly/yarn.build/discussions/169 In the answer, it is mentioned "[yarn build] look at the whole folder and check the last modified date for each file." I think that's a huge problem?.. That's exactly because of that that the bug occurred: I stashed the changes on git. So, after that, the "last modified" date was before my own changes... What made it was just adding a useless comment in the root index.ts...

To Reproduce Steps to reproduce the behavior:

  1. Using git or any VSC I guess
  2. Build your thing
  3. Change some files, add some, etc...
  4. Build your changes
  5. Stash your changes
  6. Try to rebuild
  7. Now if you look in the list, you still have the files you don't want anymore

Expected behavior I know looking by last modified date is the easiest, but clearly not how it should be done... (I have no idea how though)

Desktop OS: macOS yarn 1.22.19 (maybe it's already fixed in a newer version, just want to make sure this is taken into account)

ojkelly commented 1 year ago

Yep this is the tradeoff with last modified, it's faster but less resilient to edge cases than either per file hashing (computationally expensive) or IO events.

IIRC stashing files will remove them from the folder, but may not leave any trace. We might be able to cover this by looking for last modified per folder as well as per file.

I'm working on Gold the successor to yarn.build over at gold.build, I roughly planning an initial release towards the end of the year. I'm still merging fixes here, but I'm focussing most of my energy on Gold.

Tracking file changes is one of the areas where many problems and concerns come together. As a quick example you can only have so many file watchers (on some OS's) so you really want to have a program watching the IO events and relaying them to you, this is what watchman is built for.

But, just because you know a file has changed, doesn't mean its contents have meaningfully changed—thats what hashing can get you.

The scope of Gold is a bit bigger than this project, and this is one of the bigger problems I'm addressing with it.

tibo-mllr commented 1 year ago

Alright, thanks for your explanation!