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

Support server restarts using pub workspaces #3721

Open
sigurdm opened this issue Jun 21, 2024 · 12 comments
Open

Support server restarts using pub workspaces #3721

sigurdm opened this issue Jun 21, 2024 · 12 comments

Comments

@sigurdm
Copy link
Contributor

sigurdm commented Jun 21, 2024

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

Context being discussed in #3717

@natebosch
Copy link
Member

I think this is the main problem

var packageConfigId = AssetId(_targetGraph.rootPackageConfig.packageName,
'.dart_tool/package_config.json');

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
Copy link
Contributor

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
Copy link
Member

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

Map<String, DependencyType> _parseDependencyTypes(String rootPackagePath) {
final pubspecLock = File(p.join(rootPackagePath, 'pubspec.lock'));
if (!pubspecLock.existsSync()) {
throw StateError(
'Unable to generate package graph, no `pubspec.lock` found. '
'This program must be ran from the root directory of your package.');
}

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

@natebosch natebosch changed the title Find a way to support monitoring package_config when using workspaces Support packages using pub workspaces Oct 9, 2024
natebosch added a commit to dart-lang/source_gen that referenced this issue Oct 9, 2024
Use non-workspace resolution because `build_runner` does not support
packages where the `pubspec.lock` file is not at the package root.

See dart-lang/build#3721
@natebosch natebosch changed the title Support packages using pub workspaces Support server restarts using pub workspaces Oct 9, 2024
@natebosch
Copy link
Member

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.

@sigurdm
Copy link
Contributor Author

sigurdm commented Oct 22, 2024

I think this is done.

@sigurdm sigurdm closed this as completed Oct 22, 2024
@sigurdm sigurdm reopened this Oct 22, 2024
@sigurdm
Copy link
Contributor Author

sigurdm commented Oct 22, 2024

Sorry - I misread what this issue was about. We probably still should do this.

@SalihCanBinboga
Copy link

SalihCanBinboga commented Jan 1, 2025

.
├── app
│   ├── analysis_options.yaml
│   └── pubspec.yaml
├── modules
│   ├── common
│   │   ├── location_manager
│   │   │   ├── analysis_options.yaml
│   │   │   ├── index_generator.yaml
│   │   │   └── pubspec.yaml
│   │   └── ui
│   │   ├── analysis_options.yaml
│   │   ├── index_generator.yaml
│   │   └── pubspec.yaml
│   ├── core
│   │   ├── index_generator.yaml
│   │   └── pubspec.yaml
│   └── features
│   ├── back_office
│   │   ├── back_office_create_meeting
│   │   │   ├── analysis_options.yaml
│   │   │   ├── index_generator.yaml
│   │   │   └── pubspec.yaml
│   ├── client
│   │   ├── client_announcements
│   │   │   ├── analysis_options.yaml
│   │   │   ├── index_generator.yaml
│   │   │   └── pubspec.yaml
└── pubspec.yaml

Hi, everything under the app and modules directories is set to resolution: workspace. When I run dart run build_runner build at the root directory, the annotations within the workspace are not being generated. I have to navigate to the respective workspace and run dart run build_runner build there. Is this not supported? @sigurdm @natebosch

@jakemac53
Copy link
Contributor

Yes, this is not supported. You still have to run build_runner on each package individually.

@sigurdm
Copy link
Contributor Author

sigurdm commented Jan 6, 2025

Yes, this is not supported. You still have to run build_runner on each package individually.

Do we want to support this? How would it look?

@SalihCanBinboga
Copy link

Do we want to support this? How would it look?

My build_runner process takes 10-15 minutes to complete for my project. There are too many workspaces, and running it for each one individually is very costly. I think it would be great..

@jakemac53
Copy link
Contributor

I have certainly thought about supporting it, but it would require a fair bit of redesign work. There is currently an assumption that there is only one "root" package. That package is treated specially in a few ways, and it isn't clear what it would mean to remove that. Specifically:

  • Build to source builders only run on the root package
  • The root package anchors the ordering of the build, it isn't clear how ordering should work in a workspace setting (although we could just choose an arbitrary order).
  • The root package has all its sources available, instead of only its "public" sources (those under lib by default).

@jakemac53
Copy link
Contributor

It isn't clear that we would get a performance win from this either (could be worse actually).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants