Enable dart2js to split output into N files to reduce initial download size #3940

Closed
DartBot opened this Issue Jun 29, 2012 · 19 comments

Comments

Projects
None yet
7 participants
Member

DartBot commented Jun 29, 2012

This issue was originally filed by andreb...@gmail.com


When using dart2js the generate javascript contains everything required to run the code, but sometimes the application don't need to use the entire code to execute.

An example:
mainPage:
  load the std library and mainPage.dart
configPage:
  load only the configPage.dart code and use the rest that was loaded
in the mainPage

The idea is to have something similar to what is done in GWT (with runAsync) and closure-compiler (with modules).

Contributor

kasperl commented Jul 6, 2012

Added Area-Dart2JS, Triaged labels.

Contributor

kasperl commented Sep 3, 2012

Added this to the Later milestone.

Contributor

kasperl commented Oct 17, 2012

Removed this from the Later milestone.

Contributor

kasperl commented Oct 17, 2012

Added this to the Later milestone.

Contributor

kasperl commented Jan 29, 2013

Set owner to @peter-ahe-google.
Removed this from the Later milestone.
Added this to the M3 milestone.
Added Accepted label.

Contributor

peter-ahe-google commented Jan 29, 2013

Removed Priority-Medium label.
Added Priority-High label.

Contributor

peter-ahe-google commented Jan 29, 2013

Progress so far:

API proposal for deferred loading: https://codereview.chromium.org/11784018/

Compiler API changed to support multiple output files using Sinks/Streams (committed r17749).

Implemented deferred loading of static/top-level functions: https://codereview.chromium.org/12033003/

Missing: deferred loading of classes.

Contributor

peter-ahe-google commented Feb 9, 2013

Added Started label.

Contributor

peter-ahe-google commented Feb 19, 2013

Removed this from the M3 milestone.
Added this to the M4 milestone.

Contributor

peter-ahe-google commented Feb 19, 2013

I have landed the CL with the API (r18637), and the CL for deferred loading of static/top-level functions (r18671).

I'm still working on deferring load of classes.

Member

sethladd commented Feb 19, 2013

Thanks, where is this documented? A quick check of the spec didn't come up with anything.

Contributor

peter-ahe-google commented Feb 19, 2013

There is a new class called DeferredLibrary in dart:async. I don't know where to find up-to-date bleeding_edge documentation, so I cannot give you a link to it.

But this feature is nowhere near complete, please don't announce anything yet.

Member

sethladd commented Feb 19, 2013

For those following along at home: http://api.dartlang.org/docs/bleeding_edge/dart_async.html

Don't worry, just following along. Excited!

Contributor

peter-ahe-google commented Feb 19, 2013

https://codereview.chromium.org/12224010 implements deferred loading of classes.

I'm aware of the following major short-comings that will persist after CL 12224010 is landed:

* The deferred code will often force Isolate.prototype to become a "slow" object. This means that calling top-level or static methods that have been lazily loaded becomes really slow (this also applies to Dart constructors).

* Only the library that is marked with DeferredLibrary is deferred. Instead, we need to perform something like tree-shaking to ensure that stuff only used by the the deferred library doesn't get included in the main JS file.

* Constants using deferred classes are broken.

* You can split the output in at most two files.

All these limitations are short-term, and I'm working on eliminating them. However, I think that once CL 12224010 lands, people can start using this for real apps.

Contributor

peter-ahe-google commented Mar 4, 2013

Deferred loading of classes landed in r18834, and deferred loading of constants landed in r19378.

I'm currently working on computing the transitive closure of deferred libraries to ensure that the initial download doesn't include stuff only needed by a deferred library.

Contributor

peter-ahe-google commented Mar 6, 2013

https://codereview.chromium.org/12525007/ implements basic dependency graph segmentation. This means that the initial download should not be polluted with unneeded code from shared libraries.

Contributor

peter-ahe-google commented Mar 11, 2013

Submitted CL 12525007 as r19793. The compiler will now segment the dependency graph. This should make the initial download much smaller.

Owner

dgrove commented Mar 21, 2013

Added C1 label.

Member

DartBot commented Apr 9, 2013

This comment was originally written by @seaneagan


The "You can split the output in at most two files" limitation is what I am hitting right now. I am trying to split it into about 170 files. My code is at:

https://github.com/seaneagan/intlx/blob/master/lib/src/plural/load_locale.dart

Each of the 170 correspond to libraries which contain plural rules code for given locales from this directory:

https://github.com/seaneagan/intlx/tree/master/lib/src/plural/locale

Will this amount of files ever be possible/performant? If yes, I'll create a separate issue to track support for more than 2 files. If no, that would be a regression from JavaScript, where this is commonly done.

sigurdm was assigned by DartBot Apr 9, 2013

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment