Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
DartBot opened this issue Jun 29, 2012 · 19 comments
Closed
Assignees
Labels
type-enhancement A request for a change that isn't a bug web-dart2js

Comments

@DartBot
Copy link

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).

@kasperl
Copy link

kasperl commented Jul 6, 2012

Added Area-Dart2JS, Triaged labels.

@kasperl
Copy link

kasperl commented Sep 3, 2012

Added this to the Later milestone.

@kasperl
Copy link

kasperl commented Oct 17, 2012

Removed this from the Later milestone.

@kasperl
Copy link

kasperl commented Oct 17, 2012

Added this to the Later milestone.

@kasperl
Copy link

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.

@peter-ahe-google
Copy link
Contributor

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

@peter-ahe-google
Copy link
Contributor

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.

@peter-ahe-google
Copy link
Contributor

Added Started label.

@peter-ahe-google
Copy link
Contributor

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

@peter-ahe-google
Copy link
Contributor

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.

@sethladd
Copy link
Contributor

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

@peter-ahe-google
Copy link
Contributor

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.

@sethladd
Copy link
Contributor

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

Don't worry, just following along. Excited!

@peter-ahe-google
Copy link
Contributor

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.

@peter-ahe-google
Copy link
Contributor

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.

@peter-ahe-google
Copy link
Contributor

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.

@peter-ahe-google
Copy link
Contributor

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

@dgrove
Copy link
Contributor

dgrove commented Mar 21, 2013

Added C1 label.

@DartBot
Copy link
Author

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.

@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed type-enhancement labels Mar 1, 2016
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-enhancement A request for a change that isn't a bug web-dart2js
Projects
None yet
Development

No branches or pull requests

7 participants