Description
We run dart pub deps --json
internally to get a dependencies graph to determine in what order to run the build hooks.
(And if we move forward with version-isolated output directories, we'll also start using it for figuring out if something is a published, git, or root dependency. #1962 (comment))
However, dartdev
and flutter_tools
now need to guarantee that the package_config.json
they pass in is up to date with regards to the pubspec.yaml
. This seems fragile.
It would be better if the information from dart pub deps --json
would also be persisted.
Proposed solution: .dart_tool/pub_deps.json
We could make pub get
output a json file next to the package config. This would make the files persist at the same time.
Not proposed solution: embed inside package_config.json
The package_config.json
is a file needed for the Dart core language, and it should only contain information for the core language. The core language doesn't require additional information. The SDKs (Dart standalone and Flutter) contain pub and support for native assets. We shouldn't leak information from the outer layer into the inner layer.
(I'm advocating against dart-lang/pub#3795)
cc @jonasfj @sigurdm for symbiotic relationship between pub
and the native assets feature (both the dependencies graph and the 'source' hosted/git/root are needed).
cc @bkonyi for the pubspec.yaml
-> package_config.json
"contract" in dartdev and flutter_tools.
@bkonyi Should we consider forcibly running pub get
if we notice the timestamp of the pubspec.yaml
is new than the package_config.json
. That's definitely not what we do in dartdev currently. We only run pub get
if can't find a package_config.json
.
Activity
sigurdm commentedon Feb 4, 2025
I think persisting something along the lines of pub deps --json into .dart_tool makes sense!
We should probably go through that output and verify that it is the desired information we output.
package_config.json
dart-lang/pub#3795sigurdm commentedon Feb 24, 2025
We have something close to this now in
.dart_tool/package_graph.json
. (dart-lang/pub#4524)dcharkes commentedon Feb 24, 2025
Thanks @sigurdm! 🙏
I'm going to keep this open until we consume this shiney new thing. 😄
sigurdm commentedon Feb 24, 2025
Ah - this issue covered the discrepancy in native_assets_builder - not the feature request for pub - sorry for closing!
.dart_tool/package_graph.json
#2031