Skip to content

Commit

Permalink
feat(js size): Add a default @MirrorsUsed to Angular.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbdeboer committed Jan 28, 2014
1 parent 857cd05 commit d23f9d7
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
6 changes: 6 additions & 0 deletions demo/todo/web/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import 'todo.dart';

import 'dart:html';

// Everything in this library should be preserved by MirrorsUsed
@MirrorsUsed(
targets: const['todo'],
override: '*')
import 'dart:mirrors';

main() {

print(window.location.search);
Expand Down
1 change: 1 addition & 0 deletions demo/todo/web/todo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ library todo;

import 'package:angular/angular.dart';


class Item {
String text;
bool done;
Expand Down
36 changes: 36 additions & 0 deletions lib/angular.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,42 @@ import 'dart:js' as js;
import 'package:di/di.dart';
import 'package:di/dynamic_injector.dart';

/**
* This @MirrorsUsed annotation is doing two things:
* - setting "override: *", which will cause any library that is not tagged
* with @MirrorsUsed to be potentially shaken out of the production binary.
* - setting targets. All classes inside of Angular will be preserved, as
* well as any class tagged with the annotations listed in metaTargets.
*
* If you are writing code accessed from Angular expressions, you must include
* your own @MirrorsUsed annotation or ensure that everything is tagged with
* the Ng annotations.
*
* This is a short-term fix until we implement a transformer-based solution
* which does not rely on mirrors.
*/
@MirrorsUsed(targets: const[
'angular',
'angular.core',
'angular.core.dom',
'angular.filter',
'angular.perf',
'angular.directive',
'angular.routing',
'angular.core.parser.dynamic_parser',
'angular.core.parser.lexer',
'perf_api',
'List',
'NodeTreeSanitizer',
],
metaTargets: const[
'NgInjectableService',
'NgDirective',
'NgController',
'NgComponent'
])
import 'dart:mirrors';

import 'package:angular/core/module.dart';
import 'package:angular/core_dom/module.dart';
import 'package:angular/directive/module.dart';
Expand Down
2 changes: 2 additions & 0 deletions lib/playback/playback_http.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import 'dart:convert' show JSON;
import 'dart:html';

import 'package:angular/core_dom/module.dart';
import 'package:angular/core/service.dart';
import 'package:angular/mock/module.dart' as mock;

import 'playback_data.dart' as playback_data;

@NgInjectableService()
class PlaybackHttpBackendConfig {
requestKey(String url,
{String method, bool withCredentials, String responseType,
Expand Down

0 comments on commit d23f9d7

Please sign in to comment.