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

Unified Diff: pkg/polymer/lib/src/build/script_compactor.dart

Issue 239433012: Detect and warn about missing scripts (rather than fail during the build) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/polymer/lib/src/build/import_inliner.dart ('k') | pkg/polymer/test/build/code_extractor.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer/lib/src/build/script_compactor.dart
diff --git a/pkg/polymer/lib/src/build/script_compactor.dart b/pkg/polymer/lib/src/build/script_compactor.dart
index 0af62005d1065a4e596edd0373b63b93c616331d..4ca5537ba8845a6dd335b9b72211313931341da0 100644
--- a/pkg/polymer/lib/src/build/script_compactor.dart
+++ b/pkg/polymer/lib/src/build/script_compactor.dart
@@ -139,12 +139,8 @@ class _ScriptCompactor extends PolymerTransformer {
/// Emits the main HTML and Dart bootstrap code for the application. If there
/// were not Dart entry point files, then this simply emits the original HTML.
Future _emitNewEntrypoint(_) {
- if (entryLibraries.isEmpty) {
- // We didn't find code, nothing to do.
- transform.addOutput(transform.primaryInput);
- return null;
- }
-
+ // If we don't find code, there is nothing to do.
+ if (entryLibraries.isEmpty) return null;
return _initResolver()
.then(_extractUsesOfMirrors)
.then(_emitFiles)
@@ -157,10 +153,17 @@ class _ScriptCompactor extends PolymerTransformer {
/// [entryLibraries], then use it to initialize the [recorder] (for import
/// resolution) and to resolve specific elements (for analyzing the user's
/// code).
- Future _initResolver() => resolvers.get(transform, entryLibraries).then((r) {
- resolver = r;
- types = new _ResolvedTypes(resolver);
- });
+ Future _initResolver() {
+ // We include 'polymer.dart' to simplify how we do resolution below. This
+ // way we can assume polymer is there, even if the user didn't include an
+ // import to it.
+ var libsToLoad = [new AssetId('polymer', 'lib/polymer.dart')]
Jennifer Messerly 2014/04/18 00:53:33 based on the test, is the idea here that we don't
Siggi Cherem (dart-lang) 2014/04/18 01:05:16 Right
+ ..addAll(entryLibraries);
+ return resolvers.get(transform, libsToLoad).then((r) {
+ resolver = r;
+ types = new _ResolvedTypes(resolver);
+ });
+ }
/// Inspects the entire program to find out anything that polymer accesses
/// using mirrors and produces static information that can be used to replace
@@ -345,15 +348,21 @@ class _ScriptCompactor extends PolymerTransformer {
generator.writeTopLevelDeclarations(code);
code.writeln('\nvoid main() {');
generator.writeInitCall(code);
- code.writeln(' startPolymer([');
+ code.write(' startPolymer([');
// Include initializers to switch from mirrors_loader to static_loader.
- for (var init in initializers) {
- var initCode = init.asCode(prefixes[init.assetId]);
- code.write(" $initCode,\n");
+ if (!initializers.isEmpty) {
+ code.writeln();
+ for (var init in initializers) {
+ var initCode = init.asCode(prefixes[init.assetId]);
+ code.write(" $initCode,\n");
+ }
+ code.writeln(' ]);');
+ } else {
+ logger.warning('no polymer initializers were found.');
Jennifer Messerly 2014/04/18 00:53:33 I wonder if we should add more to this msg about h
Siggi Cherem (dart-lang) 2014/04/18 01:05:16 Good idea. Done.
+ code.writeln(']);');
}
- code..writeln(' ]);')
- ..writeln('}');
+ code.writeln('}');
transform.addOutput(new Asset.fromString(bootstrapId, code.toString()));
« no previous file with comments | « pkg/polymer/lib/src/build/import_inliner.dart ('k') | pkg/polymer/test/build/code_extractor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698