Skip to content

hook/link.dart support in flutter_tools #146263

@dcharkes

Description

@dcharkes

In #129757, we've added hook/build.dart which runs before kernel compilation.

The link hook (hook/link.dart) will run after kernel compilation and enable tree-shaking assets:

  • Completely removing an asset if it's not used.
  • Shrinking the contents of an asset if only a subset of it is used.

This issue tracks the flutter_tools implementation of invoking link hooks.

  • MacOS
  • iOS (including add2app)
  • Linux
  • Android (including add2app)
  • Windows

Only in AOT compilation (flutter release) will tree-shaking be available.

However, link hooks should also be invoked on all JIT paths (including hot-restart).

The relevant code can be found in the PRs mentioning #129757 (note that many files moved in #143055).

Tracking issue for the link hook for both Dart and Flutter combined:

Umbrella issue for native assets:

cc @mosuem you don't seem to be part of the flutter org yet on GitHub, so I can't assign you to this issue.

FYI @andrewkolos @christopherfujino

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: new featureNothing broken; request for a new capabilityteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions