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

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

Closed
dcharkes opened this issue Feb 4, 2025 · 4 comments · Fixed by #2031
Closed

Comments

@dcharkes
Copy link
Collaborator

dcharkes commented Feb 4, 2025

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.

@sigurdm
Copy link

sigurdm commented 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.

@sigurdm
Copy link

sigurdm commented Feb 24, 2025

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

@sigurdm sigurdm closed this as completed Feb 24, 2025
@dcharkes
Copy link
Collaborator Author

dcharkes commented Feb 24, 2025

Thanks @sigurdm! 🙏

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

@dcharkes dcharkes reopened this Feb 24, 2025
@sigurdm
Copy link

sigurdm commented Feb 24, 2025

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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants