-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
JS-interop example produces > 670kb .js file #11218
Comments
Attaching the sample app. Attachment: |
FWIW the version of the code w/out the js-interop bits compiles to 95k (unminified). |
And, adding the following lines increases size to 686k: hug.patBack(new js.Callback.once((msg) { |
Removed Type-Enhancement label. |
Yes, it imports dart:mirrors. I believe the only usage is MirrorSystem.getName. |
Vijay: I'll add an annotation to dart:mirrors called something like: @EnableTreeShaking. You'll have to use this annotation like this: @EnableTreeShaking Does that sound doable? Set owner to @peter-ahe-google. |
Added this to the M6 milestone. |
Removed Type-Bug label. |
Thanks for taking a look! |
Actually, since you only use MirrorSystem.getName, I should be able to detect that and preserve tree-shaking transparently. |
Oops: I was planning on fixing the problem that because JS-interop imports 'dart:mirrors' tree shaking is disabled. However, Seth hadn't even noticed that. When I compile the example today, the size is 2,6M and it takes almost 12 seconds to compile. I can fix that regression and bring the size back down to 656K and compile time down to 5 seconds. I have one further trick in my bag, but that will only get us down to 587K. With minification, it looks like I might be able to bring it down to 323K (this number includes a mapping from minified names to unminified names, so with a little more programming, I should be able to get JS-interop working in minified code). I don't know if 323K is small enough. If not, it is great that Vijay is working on a leaner alternative to JS-interop. |
https://codereview.chromium.org/16817002/ provides the first part I described in #13 (getting the size down to 656K). |
I plan these further actions on this bug:
Please let me know if you have any concerns about this plan. |
Added Started label. |
https://codereview.chromium.org/16830002/ restores global type inference (bringing the size down to 587K). |
I have a working prototype implementation that seems to work with dart_js_interop_example.zip in minified code. Currently, the size is 327K (80K gzipped), but I should be able shave off a few more Ks. |
The prototype is here: https://codereview.chromium.org/16851002/ |
This example:
import 'dart:html';
import 'package:js/js.dart' as js;
void main() {
var context = js.context;
js.scoped(() {
var hug = new js.Proxy(context.Hug);
var result = hug.embrace(10);
query('#output').text = result;
});
}
Calling this JS file:
function Hug(strength) {
this.strength = strength;
}
Hug.prototype.embrace = function(length) {
return 'thanks, that was a good hug for ' + length + ' minutes!';
}
Hug.prototype.patBack = function(onDone) {
onDone('all done');
}
produces a 676kb .js file.
I am using Dart Editor version 0.5.16_r23799
Note: minifying the output code breaks Dart-JS interop.
The text was updated successfully, but these errors were encountered: