Skip to content

Data assets feature #54003

@dcharkes

Description

@dcharkes

Problems:

  • Flutter has an assets system, Dart does not. This is problematic when wanting to access bytes at runtime in a platform independent way.
  • Various types of assets could benefit from minifying and/or tree-shaking. For example a translation package might only want include translations in a translations.json asset with keys that are actually reachable from Dart code after Dart AOT optimizations.

High level outline:

  • Bring AssetBundle to dart:
  • Make build.dart (from ☂️ [vm/ffi] Build hooks & Code assets #50565) be able to output data assets besides code assets.
  • Introduce a link.dart that runs after dart AOT compilation that can do minifying and tree-shaking for data assets.

The tree-shaking info that link.dart would be getting is const values from arguments to static function calls and constructors:

// package:foo/foo.dart

void main() {
  for(int i = 0; i < 10; i++){
    foo(i, 'foo');
    foo(i, 'bar');
  }
}

@someTreeShakingAnnotationToBeDecided
foo (int i, string s) {
  // ...
}

->

[
  {
    "uri": "package:foo/foo.dart",
    "name": "foo",
    "callers" : [
      { "s" : "foo" },
      { "s" : "bar" },
    ]    
  }
]

Some WIP format in the test cases: https://dart-review.googlesource.com/c/sdk/+/329961

More details to follow. Filing an issue so we have somewhere to point to.

Metadata

Metadata

Labels

area-metaCross-cutting, high-level issues (for tracking many other implementation issues, ...).

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions