Open matanlurey opened 6 days ago
Summary: The issue is about excluding dev dependencies from Flutter release builds. Currently, Flutter includes all dependencies, including dev dependencies, in release builds. This is problematic because it can lead to unnecessary code being included in the final app. The issue proposes a solution to identify and exclude dev dependencies from the build process.
Forking this from an internal discussion:
@matanlurey:
My solution ended up being to use
dart pub deps --json
and some parsing; see https://github.com/flutter/flutter/pull/157462.From talking to @sigurdm and @jonasfj, we may want to pick an alternate strategy in the future. Some discussion:
@matanlurey:
To be clear, the build process does consume that file - but if you remember, the plugin configuration is in pubspec.yaml. Here is one example: https://github.com/flutter/packages/blob/e0c4f55cd355a704981b96914edf9e93c50a76af/packages/video_player/video_player_android/pubspec.yaml#L11-L18 - so the pub dependency tree is read and is required as part of the (Flutter) build process today.
Maybe
package_config.json
should be extensible and be able to include more things? But it does not today.@matanlurey:
I could misunderstand, but let's explain really briefly what we're trying to do. Today, we (transitively) read all
pubspec.yaml
files, and build a file called.flutter-plugins-dependencies
, which is sort of likepackage_config.json
but for plugins. It looks something like this:(https://docs.flutter.dev/release/breaking-changes/flutter-plugins-configuration)
That file in turn is read by various native build systems (like Gradle, or Xcode), and used to assemble the right Gradle/Xcode/etc projects to include these native plugins. One such example:
(https://github.com/flutter/flutter/blob/add7e81f4f5cb9903cbfe583f06e08f4566c5639/examples/hello_world/android/settings.gradle.kts#L35-L36)
/cc @dcharkes as well.