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

Added method findPackageConfigFilePath to find the package_config.json file #2587

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

jyameo
Copy link
Contributor

@jyameo jyameo commented Feb 4, 2025

Added a method that returns the absolute file path of the package_config.json file in the .dart_tool directory, by searching recursively from the current directory hierarchy to ensure packageConfigPath is initialized in LoadStrategy at construction.

Fixes #2575

@jyameo jyameo requested a review from srujzs February 4, 2025 20:19
Copy link
Contributor

@srujzs srujzs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking this on Jessy!

@@ -20,7 +21,7 @@ abstract class LoadStrategy {
LoadStrategy(
this._assetReader, {
String? packageConfigPath,
}) : _packageConfigPath = packageConfigPath;
}) : _packageConfigPath = packageConfigPath ?? _findPackageConfigFilePath();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should instead provide this as an optional named parameter (optional named to avoid a breaking change) to each of the FrontendServerStrategyProviders e.g.:

FrontendServerDdcLibraryBundleStrategyProvider(
and avoid computing this in DWDS.

Flutter already calculates this, so we'd end up calculating it again. Flutter may also choose to configure the locations differently in tests for example.

I'd then imagine webdev calculating this separately and passing it to the provider (I guess in its case it'd use the BuildRunnerRequireStrategyProvider, which should also be updated in this PR).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about this approach and it makes sense to update each of the providers to allow passing a _packageConfigPath. It works for the flutter tools case since the info is already computed, we can simply pass it to the provider. However, for Webdev we don't have this details so what about we allow setting the value of _packageConfigPath for all the providers but in case we don't pass this value explicitly, we can compute it with _findPackageConfigFilePath. That way we can ensure that we always have this value set in all cases. Wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My original thought was maybe webdev should calculate it separately and then pass it to DWDS, but maybe it doesn't matter. I do like the idea of our default being a bit more robust for the case of monorepos, so I think your plan makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a similar method in Webdev to find the package config path and pass to DWDS and I also kept the default method in the load strategy class in case the value is not being passed.

dwds/CHANGELOG.md Outdated Show resolved Hide resolved
@jyameo jyameo requested a review from srujzs February 5, 2025 18:42
@jyameo
Copy link
Contributor Author

jyameo commented Feb 5, 2025

@srujzs I'm not too familiar with the release process but It looks like I need to update webdev.pubspec.yaml as well as it's currently pointing to 24.2.0? Do I need to release a new version of DWDS first before I can push my changes to Webdev?

@srujzs
Copy link
Contributor

srujzs commented Feb 5, 2025

I'd avoid making changes to webdev in this PR as it relies on DWDS and I remember the bots having trouble publishing both versions at once.

I'd do the following if you want to publish webdev with a new version of dwds:

  • Undo your webdev changes in this PR.
  • Change the pubspec, changelog, and version.dart to use 24.3.5 instead of 24.3.5-wip as you're releasing a new version of DWDS.
  • Once landed, you can go to checks and check the publish section e.g. https://github.com/dart-lang/webdev/actions/runs/13164273124. There should be a tag in the Publish tag (post-merge) section. Once you click on it and publish a new tag, the new version is published to pub.
  • After you publish the new version of DWDS, I'd upload your changes to webdev, including updating the webdev version and updating its dependencies to use your new version of DWDS.

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

Successfully merging this pull request may close these issues.

"Cannot read packages spec" when running Flutter app in Pub Workspace, affecting debugging/breakpoints
2 participants