Skip to content

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

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

Merged
merged 7 commits into from
Feb 11, 2025

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.

@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.

@jyameo
Copy link
Contributor Author

jyameo commented Feb 7, 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.

Thanks for the clarification! That makes sense. I'll undo the webdev changes in this PR and update DWDS to 24.3.5 instead of 24.3.5-wip.

I believe we also need to update the DWDS version in flutter_tools. Is there anything different I need to keep in mind when updating the DWDS version there?

Appreciate the guidance! Let me know if there's anything else I should keep in mind.

@srujzs
Copy link
Contributor

srujzs commented Feb 10, 2025

LGTM! Sorry for the delay, was OOO. :)

I believe we also need to update the DWDS version in flutter_tools. Is there anything different I need to keep in mind when updating the DWDS version there?

Indeed, we update packages in flutter by running the following script:

flutter update-packages --cherry-pick-package=dwds --cherry-pick-version=24.3.5

Since Flutter pins versions globally, this script goes through all the dependencies and updates their versions. The cherry-pick arguments tell it to only update DWDS. We should see the update in only one place (flutter_tools).

@jyameo jyameo merged commit 4246bbc into dart-lang:main Feb 11, 2025
51 of 52 checks passed
copybara-service bot pushed a commit to dart-lang/sdk that referenced this pull request Feb 13, 2025
Revisions updated by `dart tools/rev_sdk_deps.dart`.

ecosystem (https://github.com/dart-lang/ecosystem/compare/5b0d815..fe4979b):
  fe4979b  2025-02-10  Kevin Moore  [firehose] Set exit code and return instead of calling exit(X) (dart-lang/ecosystem#341)

http (https://github.com/dart-lang/http/compare/b7cdf61..e28f9f5):
  e28f9f5  2025-02-11  Sam Rawlins  Fix typo in example in README (dart-lang/http#1714)
  fc59d4a  2025-02-11  Brian Quinlan  Revert cronet_http gradle version (dart-lang/http#1712)

protobuf (https://github.com/dart-lang/protobuf/compare/d00f905..610943a):
  610943a  2025-02-12  Devon Carew  update the publish workflow; add a post_summaries one (google/protobuf.dart#961)
  35a1bd6  2025-02-12  Devon Carew  update the repo analysis config (google/protobuf.dart#962)
  d3f9ad1  2025-02-12  Devon Carew  updates to the gitignore files (google/protobuf.dart#960)
  950b6a7  2025-02-11  Ömer Sinan Ağacan  Remove redundant checkNotNull calls from pre-null-safe days (google/protobuf.dart#958)

shelf (https://github.com/dart-lang/shelf/compare/2a7442f..b39e611):
  b39e611  2025-02-11  dependabot[bot]  Bump actions/stale from 9.0.0 to 9.1.0 in the github-actions group (dart-lang/shelf#470)

webdev (https://github.com/dart-lang/webdev/compare/616da45..718c39c):
  718c39c3  2025-02-11  Jessy Yameogo  set packageConfigPath and update DWDS version to 24.3.5 (dart-lang/webdev#2589)
  4246bbc5  2025-02-11  Jessy Yameogo  Added method findPackageConfigFilePath to find the package_config.json file (dart-lang/webdev#2587)

Change-Id: I7e5940ad3b128d1e47c2185a1435006c2a277bc4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/409621
Commit-Queue: Devon Carew <[email protected]>
Reviewed-by: Konstantin Shcheglov <[email protected]>
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