Skip to content

Allow plugin authors to force their code to only execute in development/ dev_dependencies #23154

Closed

Description

@brianegan

Hey there -- I have a plugin (flutter_stetho) that should be used only during development for inspecting Network requests and Databases for Flutter apps.

I ask users to use a main.dart and main_dev.dart so they can instantiate the code only during their dev process, and to include the plugin only in the dev_dependencies section in the pubspec.yaml file.

However, if you build the app in production mode using the main.dart entry point, I believe the Dart code will be properly removed / tree shaken, but the Android plugin code is still being shipped. That makes the app size larger, and potentially makes Stetho a security risk (might accidentally allow users to inspect the Database or network requests)

Is there a way for plugin authors to indicate to Flutter: "Hey, only include this Android/iOS for Dev builds, but not for production builds"?

Also, more of a General Question: I was a bit confused as to why dev_dependencies are being included in Production builds at all. Is this by design? If so, could you describe why / when those are included?

Activity

  1. added
    c: new featureNothing broken; request for a new capability
    p: toolingAffects the flutter_plugin_tools package
    on Oct 16, 2018
  2. added this to the milestone on Oct 16, 2018
  3. added
    toolAffects the "flutter" command-line tool. See also t: labels.
    p: toolingAffects the flutter_plugin_tools package
    and removed
    p: toolingAffects the flutter_plugin_tools package
    on Oct 16, 2018
  4. modified the milestones: , on Jan 7, 2020
  5. changed the title [-]Remove Plugin in Production Build[/-] [+]Allow plugin authors to force their code to only execute in development/ dev_dependencies[/+] on Jan 18, 2020
  6. jmagman commented on Jan 18, 2020

    @jmagman
    Member

    I split out that last question about dev_dependencies re: iOS to #49101

  7. jonahwilliams commented on Jan 18, 2020

    @jonahwilliams
    Contributor

    I think this is essentially the same as #45714

  8. jmagman commented on Jan 21, 2020

    @jmagman
    Member

    @jonahwilliams Does that one need to be re-titled then and this one duped over? I can't say I got the request from the "native buildscripts" part (at least for iOS, this would require changing CocoaPods logic):

    pod 'dev_only_plugin', :configuration => 'Debug'
    
  9. jonahwilliams commented on Jan 21, 2020

    @jonahwilliams
    Contributor

    I think it is similar in spirit. Though FWIW I think it would be a mistake to conditionally include dependencies based on runtime mode

  10. added
    P3Issues that are less important to the Flutter project
    on May 29, 2020
  11. removed this from the milestone on Aug 17, 2020
  12. jonahwilliams commented on Sep 26, 2020

    @jonahwilliams
    Contributor

    Closing as a duplicate of #45714

  13. github-actions commented on Aug 12, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  14. locked as resolved and limited conversation to collaborators on Aug 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityp: toolingAffects the flutter_plugin_tools packagetoolAffects the "flutter" command-line tool. See also t: labels.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions