Too large JS-file generated
Asked Answered
I

3

7

I have this code:

// main.dart
import "package:angular/angular.dart";
main () => ngBootstrap();

I make dart2js --minify --out=main.dart.js main.dart

Then i have main.dart.js with size 2.6 MiB (2,744,320 bytes). It is not normal. What i'm doing wrong?

Is angular.dart usable for production at this stage?

Irretentive answered 21/11, 2013 at 11:31 Comment(1)
stackoverflow.com/questions/21212131 question/answers have relevant information related to this question too.Maidenly
S
5

@media-slave24

Maybe this will be helpful for You: https://code.google.com/p/dart/issues/detail?id=14686

It's reported on dart bug tracking system. Some people using mirrors got 760kb. So it's definitely a bug.

Sissy answered 21/11, 2013 at 12:35 Comment(3)
Thanks, it works for me, i declared @MirrorsUsed and now main.dart.js is 670.6 KiB (686,736 bytes). But HOW it works? Official documentation says nothing useful for this.Irretentive
@Irretentive api.dartlang.org/docs/channels/stable/latest/dart_mirrors/… and api.dartlang.org/docs/channels/stable/latest/dart_mirrors.html It's not stable API so it can be changed in future. I hope it will be helpful.Sissy
@Irretentive 670KiB is 17 times bigger than angular.min.js. Are you really considering embedding 670KB of javascript in a webpage? I do not understand why they do not mention anything about this problem on angulardart.org. (By the way, [angulardart.org/demo/] loads 2MB of javascript...).Exploiter
Q
5

UPDATE (Jan '14): AngularDart 0.9.5 now includes a standard MirrorsUsed list. To finalize it and trigger Dart's tree-shaking optimizations, you need to add a MirrorsUsed to your program

  • listing all the classes you introduce.
  • override: '*' to finalize the MirrorsUsed.

Since helloworld has no new classes, say:

@MirrorsUsed(override: '*')
import 'dart:mirrors';

See Github for the complete helloworld program

The key is to include a @MirrorsUsed annotation in your Dart file. Pavel's link to the AngularDart tutorial is an excellent resource.

To actually answer your question: Yes, AngularDart can be used in production but be aware that it is in "beta" release right now. We expect many breaking API changes!

Quenby answered 8/12, 2013 at 0:35 Comment(0)
A
4

Take a look at angular.dart.tutorial Chapter 7 about deployment. It has a section on managing compiled code size:

https://github.com/angular/angular.dart.tutorial/tree/master/Chapter_07

Autotrophic answered 5/12, 2013 at 22:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.