dart-lang / package_config

Support for working with Package Resolution Configuration files
https://pub.dev/packages/package_config
BSD 3-Clause "New" or "Revised" License
16 stars 17 forks source link

Introduce some synchronous APIs #95

Open srawlins opened 4 years ago

srawlins commented 4 years ago

Migrating from all of the deprecated APIs/libraries (like packages_file.parse) to supported ones (like package_config_discovery.loadPackageConfigUri) currently requires a change to asynchronous code.

I'd like to use the internal synchronous functions, like lib/src/package_config_io.dart's parseAnyConfigFile, as it is synchronous, and the public loadPackageConfigUri is more-or-less an asynchronous wrapper around it.

lrhn commented 3 years ago

We do not plan to make any new APIs available for parsing .packages files. That is not a goal for this package. The support we do have for reading .packages files is temporary. We will stop supporting .packages files as soon as possible since they cannot support language versioning and therefore not support null safety.

We could potentially expose the "parse-any" function, and not promise to keep supporting .packages, but since that's what you are going to use it for exclusively, it doesn't seem to be what you need.

If you need to support parsing .packages files, I recommend copying the code instead.

jakemac53 commented 3 years ago

I think that @srawlins was looking for a synchronous way of parsing the new package config format?

lrhn commented 3 years ago

The code that was changed was only reading the old .packages format, so providing a synchronous way to read the new format will not help here. Providing API to just read the old format is a non-goal.

We also decided early on to not have synchronous APIs for I/O.

A general synchronous parseConfigurationFile function might make sense. It'll be taking a Uint8List in UTF-8 format as input (because that's what we have). It can perhaps be available as a static PackageConfig.parseFile().

It's not intended as a long-term support for .packages, but then, the analyzer shouldn't need it forever either.