Skip to content

[native_assets_builder] dart pub deps --json and .package_config.json could disagree #1968

Closed
@dcharkes

Description

@dcharkes

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

sigurdm commented on Feb 4, 2025

@sigurdm

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.

sigurdm

sigurdm commented on Feb 24, 2025

@sigurdm

We have something close to this now in .dart_tool/package_graph.json. (dart-lang/pub#4524)

dcharkes

dcharkes commented on Feb 24, 2025

@dcharkes
CollaboratorAuthor

Thanks @sigurdm! 🙏

I'm going to keep this open until we consume this shiney new thing. 😄

sigurdm

sigurdm commented on Feb 24, 2025

@sigurdm

Ah - this issue covered the discrepancy in native_assets_builder - not the feature request for pub - sorry for closing!

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @dcharkes@sigurdm

      Issue actions

        [native_assets_builder] `dart pub deps --json` and `.package_config.json` could disagree · Issue #1968 · dart-lang/native