build icon indicating copy to clipboard operation
build copied to clipboard

Support pub workspaces

Open lishaduck opened this issue 8 months ago • 6 comments

When running dart run build_runner clean in a Pub Workspace, I get this

[WARNING] Deleting cache and generated source files.
This shouldn't be necessary for most applications, unless you have made intentional edits to generated files (i.e. for testing). Consider filing a bug at https://github.com/dart-lang/build/issues/new if you are using this to work around an apparent (and reproducible) bug.
[WARNING] No asset graph found. Skipping cleanup of generated files in source directories.
[INFO] Cleaning up source outputs completed, took 39ms
[INFO] Cleaning up cache directory completed, took 262ms

It does clear the cache, but it doesn't delete the files which slightly reduces its utility.

  • The Dart SDK Version: Dart SDK version: 3.7.2 (stable) (Tue Mar 11 04:27:50 2025 -0700) on "macos_arm64"
  • build_runner 2.4.15
  • Builders: n/a?
  • macOS
  • Browser: n/a
  • n/a?

lishaduck avatar Apr 06 '25 17:04 lishaduck

I don't think clean is intended to do anything in a monorepo ... you'd have to run it in each individual package.

It makes sense to support something better, as part of better supporting monorepos generally.

Thanks for filing, I'll add it to the pile :)

davidmorgan avatar Apr 07 '25 06:04 davidmorgan

I don't think clean is intended to do anything in a monorepo ... you'd have to run it in each individual package.

I'm sorry, I wasn't clear above. While I'd love to be able to clean the entire monorepo, the issue I was filing was that running it in an individual package doesn't clear source files.

lishaduck avatar Apr 07 '25 13:04 lishaduck

Oh, interesting, that does sound more like a bug :)

I'll take a look once the performance work is done and build_runner is back to being able to do regular releases ... hopefully not too long now.

Thanks.

davidmorgan avatar Apr 07 '25 13:04 davidmorgan

I would really like workspace support too, because it'd better deal with the order in which to generate code.

I often have custom code-generators for my projects. And sometimes, my generators depend on generators themselves. In which case, we can't just run dart run build_runner build in all folders at once, and the order matters. Otherwise we end-up with a race condition where we may have a compilation error.

rrousselGit avatar Jul 15 '25 10:07 rrousselGit

I would really like workspace support too, because it'd better deal with the order in which to generate code.

I often have custom code-generators for my projects. And sometimes, my generators depend on generators themselves. In which case, we can't just run dart run build_runner build in all folders at once, and the order matters. Otherwise we end-up with a race condition where we may have a compilation error.

Yes, for sure.

Usability + performance with workspaces is high priority. If we're headed for IDE integration we need a reasonable story for multiple packages without workspaces, too.

Doing it properly means refactoring so we can use one analyzer context across all the packages, which ... might take a while, hopefully not as long as the previous refactoring.

davidmorgan avatar Jul 15 '25 11:07 davidmorgan

Renamed to just "support pub workspaces" as there are a pile of things to do to handle workspaces better. (Or at all).

davidmorgan avatar Oct 16 '25 10:10 davidmorgan