Skip to content

[native_assets_builder] Add hook/link.dart // Tree shaking #153

Open
@dcharkes

Description

@dcharkes

The hook/build.dart is run before kernel compilation.

We should consider running a hook/link.dart after kernel compilation. In AOT we would have access to tree-shaking information that would enable us to:

  1. Not include an asset at all if it's not referenced from Dart code.
  2. Shrinking the contents of an asset if only a subset of its contents are used.

Use cases:

  1. If a dynamic library (native code asset) is not used at all, don't bundle it.
  2. For localization, we want to bundle a message file, and we want to tree-shake that message file based on what is reachable from the code. (If we would have icons, it would probably follow something similar to locazation.) https://github.com/dart-lang/sdk/blob/main/pkg/compiler/doc/resource_identifiers.md

For use case 2, we want to standardize the annotations and output format for what is reachable, so that any user can implement tree-shaking for any type of resource they want to bundle (e.g. icons, images, localization, nothing is special.)

Flutter tracking issue:

Dart tracking issue:

Metadata

Metadata

Assignees

Labels

P1A high priority bug; for example, a single project is unusable or has many test failurespackage:hooks_runner

Type

No type

Projects

Status

No status

Relationships

None yet

Development

No branches or pull requests

Issue actions