dart-lang / build

A build system for Dart written in Dart
https://pub.dev/packages/build
BSD 3-Clause "New" or "Revised" License
789 stars 207 forks source link

Support server restarts using pub workspaces #3721

Open sigurdm opened 3 months ago

sigurdm commented 3 months ago

Currently one has to manually restart build_runner on each pub get when using workspaces.

Context being discussed in https://github.com/dart-lang/build/pull/3717

natebosch commented 3 months ago

I think this is the main problem

https://github.com/dart-lang/build/blob/b3d3ef1c6981c92d5f513d31240aa2e340f19cd3/build_runner_core/lib/src/generate/build_definition.dart#L105-L106

This is already broken for some non-standard setups if the file isn't at exactly the hardcoded path. We could fix this for unexpected paths under the root package, but as Jake mentioned this causes a problem when the package config is outside of any package.

My first hacky idea is to add a synthetic package for this, I think we discover the package config when building the package graph so we should have the information we need. We'll also need to communicate that path through to the above lines, so we probably need to add it as another field on both PackageGraph and TargetGraph.

jakemac53 commented 3 months ago

True, we could go the synthetic package route similar to how we handle SDK sources. Not sure what we want to call it, $workspace?

natebosch commented 1 day ago

Hmm, build_runner doesn't work at all for packages using pub workspaces. https://github.com/dart-lang/build/blob/039aecaab190c70077f69e72f090675c8df04685/build_runner_core/lib/src/package_graph/package_graph.dart#L221-L227

I'm not sure how we wouldn't have hit this earlier though...

natebosch commented 21 hours ago

Hmm, build_runner doesn't work at all for packages using pub workspaces.

This was a local issue, I still had some .packages files tripping things up.