Changes in deferred loading experiments.

49 views
Skip to first unread message

Sigurd Meldgaard

unread,
Aug 29, 2014, 7:20:48 AM8/29/14
to mi...@dartlang.org
TL;DR: In the next stable release (1.7), dart2js will not support the `DeferredLibrary` annotation anymore.

Deferred loading of libraries is a crucial feature for applications of moderate complexity. The dart2js team therefore experimented with different approaches of this feature for some time. In particular the `DeferredLibrary` annotation has been part of dart2js for some time.
Now, with the release of v1.6, where dart2js and the VM implement a consistent spec, we can now turn off this old experiment. We are in the process of removing the class, and ask all testers to update their code.

How to update your code:
Before:

import "dart:async";
@lazy import "lib.dart" as lib;
const lazy = const DeferredLibrary("lib");

main() {
  lazy.load().then((_) {
    lib.foo();
    // ...
  }
}

After:

import "lib.dart" deferred as lib;

main() {
  lib.loadLibrary().then((_) {
    lib.foo();
    // ...
  }
}

Furthermore:
When using this feature with dart2js, dart2js outputs extra files - the parts to be loaded later.
The exact number and file name of the part.js files is not guaranteed to be stable as the output depends on a static view of the program that could be affected by optimizations.
One should deploy all created part.js files along with the main output file.
Reply all
Reply to author
Forward
0 new messages