Changes in deferred loading experiments.

已查看 49 次
跳至第一个未读帖子

Sigurd Meldgaard

未读,
2014年8月29日 07:20:482014/8/29
收件人 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.
回复全部
回复作者
转发
0 个新帖子