Skip to content

package assets declared under dev_dependency shouldn't be included in release bundle #79261

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

Closed
rh-id opened this issue Mar 29, 2021 · 11 comments · Fixed by #160443
Closed

package assets declared under dev_dependency shouldn't be included in release bundle #79261

rh-id opened this issue Mar 29, 2021 · 11 comments · Fixed by #160443
Labels
a: assets Packaging, accessing, or using assets a: build Building flutter applications with the tool a: release Challenges faced when attempting to productionize an app a: size Reducing IPA/APK/JS sizes c: proposal A detailed proposal for a change to Flutter P3 Issues that are less important to the Flutter project team-tool Owned by Flutter Tool team tool Affects the "flutter" command-line tool. See also t: labels. triaged-tool Triaged by Flutter Tool team

Comments

@rh-id
Copy link

rh-id commented Mar 29, 2021

Steps to Reproduce

See example project https://github.com/rh-id/example_dev_dependency_fi for the steps

Expected results: Flutter should ignore package assets declared under dev_dependency on release bundle / version

Actual results: Flutter include the package assets declared under dev_dependency on release bundle / version

Logs
[✓] Flutter (Channel stable, 2.0.2, on Linux, locale en_US.UTF-8)
    • Flutter version 2.0.2 at /home/rubyh/Flutter/flutter
    • Framework revision 8962f6dc68 (3 weeks ago), 2021-03-11 13:22:20 -0800
    • Engine revision 5d8bf811b3
    • Dart version 2.12.1

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /home/rubyh/Android/Sdk
    • Platform android-30, build-tools 30.0.3
    • ANDROID_HOME = /home/rubyh/Android/Sdk
    • ANDROID_SDK_ROOT = /home/rubyh/Android/Sdk
    • Java binary at: /usr/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+9-Ubuntu-0ubuntu1.20.04)
    • All Android licenses accepted.

Related Issues:

Do not create plugins from dev_dependencies #56591
Don't include dev_dependencies in native build scripts #45714
integration_test embedded in shipping iOS apps when added to pubspec #74274

@pedromassangocode pedromassangocode added the in triage Presently being triaged by the triage team label Mar 29, 2021
@pedromassangocode
Copy link

After reading this StackOverflow and https://dart.dev/tools/pub/dependencies#dev-dependencies I'm considering this as proposal as there is not documentation saying that assets from dev dependencies will not be included into the final app bundle.

If you have any reference about that please share the link.
Thank you

@pedromassangocode pedromassangocode added a: assets Packaging, accessing, or using assets a: release Challenges faced when attempting to productionize an app a: size Reducing IPA/APK/JS sizes passed first triage platform-android Android applications specifically c: proposal A detailed proposal for a change to Flutter and removed in triage Presently being triaged by the triage team labels Mar 29, 2021
@rh-id
Copy link
Author

rh-id commented Mar 29, 2021

Hi, @pedromassangocode I'm not sure why it is a proposal not a bug, if the reason to label this as proposal was documentation,
so far I didn't find any flutter documentation saying anything on how dev_dependencies behave with final app bundle as well. by that reasoning dev_dependencies shouldn't work with flutter at all.

If flutter follows dart documentation on dev_dependencies which means ignoring the package on the final app bundle, then flutter should ignore the assets declared as well.

@rh-id
Copy link
Author

rh-id commented Apr 6, 2021

hi @pedromassangocode Additional findings:

When adding integration_test package to dev_dependencies, GeneratedPluginRegistrant class generate the integration test class as well.

pubspec.yaml

dev_dependencies:
  flutter_test:
    sdk: flutter
  another_package:
    path: another_package
  integration_test:
    sdk: flutter
public final class GeneratedPluginRegistrant {
  public static void registerWith(@NonNull FlutterEngine flutterEngine) {
    flutterEngine.getPlugins().add(new dev.flutter.plugins.integration_test.IntegrationTestPlugin());
  }
}

after checking classes.dex in my release bundle, the IntegrationTestPlugin is included, so basically everything under dev_dependencies is included in the release bundle? I'm not sure how to check if the dart code is included in the release bundle. since there is no documentation mentioning this does it mean it is as per existing behavior? so including integration test in the final release bundle is normal ?

@stuartmorgan-g stuartmorgan-g added tool Affects the "flutter" command-line tool. See also t: labels. a: build Building flutter applications with the tool P3 Issues that are less important to the Flutter project and removed platform-android Android applications specifically labels Aug 30, 2022
@fzyzcjy
Copy link
Contributor

fzyzcjy commented Apr 6, 2023

Hi, is there any updates? I am seeing the same issue as well

@blackmenthor
Copy link

Up for this issue (sorry for not just reacting), but one use-case that might be quite annoying is: say you have an assets that are only meant to be shipped during development and you don't want that to be included in the release bundle, it won't be possible until some exclusion of assets for production build is done.

Right now there's couple of solution that might work (e.g. using script that deletes some dependency or assets during flutter build, but I'd have to admit that's not pretty.

@flutter-triage-bot flutter-triage-bot bot added team-tool Owned by Flutter Tool team triaged-tool Triaged by Flutter Tool team labels Jul 8, 2023
@like-clockwork
Copy link

I'm here because I just discovered that in one of my projects I've been placing essential package references under 'dev_dependencies' this whole time - and yet, my release builds have been running flawlessly. I figure it might have something to do with this

@chandrabezzo
Copy link

Just curious is there a plugin/package on dev_dependencies that contains large enough assets? Because I have never found a plugin/package that has very large assets on dev_dependencies 🤔

@MeandNi
Copy link
Contributor

MeandNi commented Apr 15, 2024

Just curious is there a plugin/package on dev_dependencies that contains large enough assets? Because I have never found a plugin/package that has very large assets on dev_dependencies 🤔↳

Sometimes we want to use certain resources only under debug.

@rh-id
Copy link
Author

rh-id commented Apr 28, 2024

Hi all, adding related issues above. It seemed to occur on other platforms

@zhujiageng
Copy link

any update?

@taltap-jake
Copy link

We were affected by this issue today. The inclusion of integration_test in dev_dependencies caused a crash in our release build. Very unintuitive, as dev_dependencies was far from the first place we went looking for the cause of a crash in the release build.

As it seems this is actually the way flutter behaves - we basically have no option but to inject the integration test dependencies into the pubspec.yaml as part of the runner script launching the tests. Not optimal.

github-merge-queue bot pushed a commit that referenced this issue May 19, 2025
#160443)

Fixes dart-lang/pub#4486
Fixes dart-lang/pub#4473
Fixes #79261
Fixes #160142
Fixes #155242

Use the new `.dart_tool/package_graph.json` file to compute the
dependency graph. Determining

* which are transitive dependencies of the main app's direct and
dev-dependencies, (not other packages from the workspace)
* which of these are only in the transitive set of the direct
dependencies

Bundles assets from dev_dependencies when running `flutter test`, but
not otherwise.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: assets Packaging, accessing, or using assets a: build Building flutter applications with the tool a: release Challenges faced when attempting to productionize an app a: size Reducing IPA/APK/JS sizes c: proposal A detailed proposal for a change to Flutter P3 Issues that are less important to the Flutter project team-tool Owned by Flutter Tool team tool Affects the "flutter" command-line tool. See also t: labels. triaged-tool Triaged by Flutter Tool team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy