dart-lang / pub

The pub command line tool
https://dart.dev/tools/pub/cmd
BSD 3-Clause "New" or "Revised" License
1.04k stars 224 forks source link

Change `dart pub global activate` to use `dart build exe` #4313

Open dcharkes opened 2 months ago

dcharkes commented 2 months ago

We should change dart pub global to use AOT instead of JIT.

Also, we should not let pub need to worry about how dart is compiled and run, dart should be responsible for that.

@jonasfj suggested that dart pub global activate should use dart build exe.

Subsequently, $PUB_CACHE/bin/ could contain symlinks to the executables in $PUB_CACHE/global_packages/<package_name>/outputdir/<package_name>.exe.

This would

  1. remove logic from pub-global about how Dart is compiled,
  2. speedup startup of pub-global activated packages, and
  3. make native assets work (https://github.com/dart-lang/sdk/issues/56044).

Since the executables would include a dart precompiled runtime. The Dart version which is running would be the one that was used to run dart pub global activate. If we ever want to re-activate a package with a different Dart SDK version, we might need some way to detect what version of the Dart SDK was used to compile the executable.

@jonasfj and @sigurdm probably know much more constraints and considerations. I'm filing an issue so that we have something to point to.

sigurdm commented 2 months ago

One stumbling block is the lack of dart:mirrors support in AOT compilation