Pergunta

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?

Foi útil?

Solução

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

Outras dicas

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!

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top