-
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
Angular DART Hello World produces 2.8 mb of compiled js #14686
Comments
@MirrorsUsed is critical. It may be possible to embed them inside Angular.dart, but any use that I've seen lists them in your main.dart file. e.g. https://github.com/jbdeboer/angular-dart-js-size/blob/master/main.dart |
This comment was originally written by trace...@google.com I added the mirrors code described here: https://github.com/jbdeboer/angular-dart-js-size/blob/master/main.dart and the results are not what I expect. The size of the main.dart.js is exactly the same size, or in some cases, actually a little bit larger than when I don't have the MirrorsUsed annotation. Steps to reproduce.
@MirrorsUsed(targets: const[ import 'dart:mirrors'; main() {
import 'dart:mirrors'; @MirrorsUsed(targets: const[ main() {
in this last case, main.dart.js is actually slightly bigger. Not sure what's going on, or what the right magic incantation for MirrorsUsed should be. |
You might take a look at how polymer.dart is using @MirrorsUsed - see https://code.google.com/p/dart/source/browse/branches/bleeding_edge/dart/pkg/polymer/lib/polymer.dart . cc @jmesserly. |
That won't work -- it will be totally ignored. In Dart, @Foo is metadata. It is similar to metadata in Java and C#, and similar syntactically to Python's decorators. It must come before the member: @Foo() int bar = 42; // @Foo() is metadata on my variable here In the case of MirrorsUsed, it must appear as metadata of the import directive: @MirrorsUsed(...) |
here's what I just did: $ git clone https://github.com/jbdeboer/angular-dart-js-size.git --- a/pubspec.yaml
result: In my pubspec.lock, most packages are: Things to try:
|
This comment was originally written by trace...@google.com OK. I finally got some results from the Mirrors Used. I'm not sure what happened before. I copied James' code exactly, and the pub build did literally nothing to reduce the code size. That was on my development environment at home. Now I've done the same thing from my development environment at work, and I get the results I expect. I'm not sure what's different between the two environments. I'll have to go look at the version of Dart I've got in the non-functioning environment. I wonder if it's too old. without mirrors: with mirrors: |
This comment was originally written by robb...@robbieone.com Got the same here 2697KB for main.dart.js pub upgrade the build dir is around 6MO The same occurs by compiling with the IDE directly in the web dir. The explicit command --minify produce the same size when runned on main.dart. Dart Editor version 0.8.10_r29803 note : The pubspec was a reflink invalid under windows so I replace it with the content of the same one in the root dir. |
This comment was originally written by scribe....@gmail.com When I use the above code for MirrorsUsed according to the example in #2 and James' repo, I do see a reduction in code from 2.7M to around 700K, but it breaks the compiled js code, with a browser reported error something to the effect that Uncaught Unsupported Error: Cannot find class for: Ft. The error is reported from zone.dart. |
This comment was originally written by pavel.j...@gmail.com @scribe.griff |
This comment was originally written by scribe.gri...@gmail.com Even trying this on a simple example (ie, no other libraries than angular), I always get some sort of cannot find class error, but it could be I am not using it correctly. The example I am using is the following: Html: <html> Dart: @MirrorsUsed(targets: const[ import 'package:angular/angular.dart'; main() { Without using @MirrorsUsed, renders fine in both Dartium (run as Dart) and Chrome (run as js) minified to 2.8Mb. When the @MirrorsUsed is included, minified size is 678kb, but nothing renders in Chrome with js. Chrome reports the error Uncaught Unsupported operation: Cannot find class for: Ft. I can change what libraries I include for MirrorsUsed and can achieve different compiled js sizes, but it never renders. The only thing that changes is the "missing" class name (ie, Ft, Fr, and others I can't remember but are similar). Should I be including any other libraries here? Thanks a lot. |
This comment was originally written by pavel.j...@gmail.com Try running dart2js without --minify to see what is the original class name in "Cannot find class for: Ft" |
This comment was originally written by terry.w...@gmail.com I'm getting the same issue, the error response reported is "Uncaught Unsupported operation: Cannot find class for: NodeTreeSanitizer" NodeTreeSanitizer is included in the @MirrorsUsed. Thanks |
Yes... you need to include NodeTreeSanitizer in @MirrorsUsed as a Type literal (note no quotes and dart:html import): @MirrorsUsed(targets: const[ import 'dart:html'; |
This comment was originally written by terry.w...@gmail.com If we include NodeTreeSanitizer as Type literal (without quotes), the Dart Editor complains; |
did you import 'dart:html'? |
This comment was originally written by terry.w...@gmail.com Sorry, just realised I had import 'dart:html' as html, this worked. Thanks. |
This comment was originally written by scribe....@gmail.com I removed the minify tag, removed the quotes from NodeTreeSanitizer and imported 'dart:html'. Now the error is Uncaught TypeError: Cannot call method 'get$parameters' of undefined. Here's what I have now for a dart file: @MirrorsUsed(targets: const[ import 'dart:mirrors'; main() { |
This issue was originally filed by trace...@google.com
What steps will reproduce the problem?
What is the expected output? What do you see instead?
I expect to see a much smaller binary.
Attachment:
bug.zip (686.41 KB)
The text was updated successfully, but these errors were encountered: