Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: pkg/polymer/lib/src/build/script_compactor.dart

Issue 26967004: add @MirrorsUsed to observe/polymer/polymer_exprs pkgs (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix typo in comment Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** Transfomer that combines multiple dart script tags into a single one. */ 5 /** Transfomer that combines multiple dart script tags into a single one. */
6 library polymer.src.build.script_compactor; 6 library polymer.src.build.script_compactor;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 9
10 import 'package:barback/barback.dart'; 10 import 'package:barback/barback.dart';
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 document.body.nodes.add(parseFragment( 86 document.body.nodes.add(parseFragment(
87 '<script src="packages/browser/dart.js"></script>')); 87 '<script src="packages/browser/dart.js"></script>'));
88 } else if (dartLoaderTag.parent != document.body) { 88 } else if (dartLoaderTag.parent != document.body) {
89 document.body.nodes.add(bootstrapScript); 89 document.body.nodes.add(bootstrapScript);
90 } else { 90 } else {
91 document.body.insertBefore(bootstrapScript, dartLoaderTag); 91 document.body.insertBefore(bootstrapScript, dartLoaderTag);
92 } 92 }
93 93
94 var urls = libraries.map((id) => assetUrlFor(id, bootstrapId, logger)) 94 var urls = libraries.map((id) => assetUrlFor(id, bootstrapId, logger))
95 .where((url) => url != null).toList(); 95 .where((url) => url != null).toList();
96 var buffer = new StringBuffer()..write(_header); 96 var buffer = new StringBuffer()..writeln(MAIN_HEADER);
97 for (int i = 0; i < urls.length; i++) { 97 for (int i = 0; i < urls.length; i++) {
98 buffer.writeln("import '${urls[i]}' as i$i;"); 98 buffer.writeln("import '${urls[i]}' as i$i;");
99 } 99 }
100 buffer..write(_mainPrefix) 100 buffer..write(_mainPrefix)
101 ..writeAll(urls.map((url) => " '$url',\n")) 101 ..writeAll(urls.map((url) => " '$url',\n"))
102 ..write(_mainSuffix); 102 ..write(_mainSuffix);
103 103
104 transform.addOutput(new Asset.fromString(bootstrapId, buffer.toString())); 104 transform.addOutput(new Asset.fromString(bootstrapId, buffer.toString()));
105 transform.addOutput(new Asset.fromString(id, document.outerHtml)); 105 transform.addOutput(new Asset.fromString(id, document.outerHtml));
106 }); 106 });
107 } 107 }
108 } 108 }
109 109
110 const _header = """ 110 const MAIN_HEADER = """
111 library app_bootstrap; 111 library app_bootstrap;
112 112
113 import 'package:polymer/polymer.dart'; 113 import 'package:polymer/polymer.dart';
114 import 'dart:mirrors' show currentMirrorSystem; 114 @MirrorsUsed(symbols: 'main', override: 'app_bootstrap')
Siggi Cherem (dart-lang) 2013/10/15 21:52:18 same here, remove override?
Jennifer Messerly 2013/10/15 22:03:29 I'd prefer not to, otherwise we risk breaking mirr
115 115 import 'dart:mirrors' show currentMirrorSystem, MirrorsUsed;
116 """; 116 """;
117 117
118 const _mainPrefix = """ 118 const _mainPrefix = """
119 119
120 void main() { 120 void main() {
121 initPolymer([ 121 initPolymer([
122 """; 122 """;
123 123
124 // TODO(sigmund): investigate alternative to get the baseUri (dartbug.com/12612) 124 // TODO(sigmund): investigate alternative to get the baseUri (dartbug.com/12612)
125 const _mainSuffix = """ 125 const _mainSuffix = """
126 ], currentMirrorSystem().isolate.rootLibrary.uri.toString()); 126 ], currentMirrorSystem().isolate.rootLibrary.uri.toString());
127 } 127 }
128 """; 128 """;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698