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

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

Issue 47933006: Build fixes: adds arguments to the pub-build plugin to configure whether 'js' (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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
« no previous file with comments | « no previous file | pkg/polymer/lib/transformer.dart » ('j') | pkg/polymer/lib/transformer.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 import 'dart:convert'; 9 import 'dart:convert';
10 10
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 if (mainScriptTag == null) { 74 if (mainScriptTag == null) {
75 // We didn't find any main library, nothing to do. 75 // We didn't find any main library, nothing to do.
76 transform.addOutput(transform.primaryInput); 76 transform.addOutput(transform.primaryInput);
77 return; 77 return;
78 } 78 }
79 79
80 var bootstrapId = id.addExtension('_bootstrap.dart'); 80 var bootstrapId = id.addExtension('_bootstrap.dart');
81 mainScriptTag.attributes['src'] = 81 mainScriptTag.attributes['src'] =
82 path.url.basename(bootstrapId.path); 82 path.url.basename(bootstrapId.path);
83 83
84 libraries.add(mainLibraryId); 84 // TODO(sigmund): stop renaming the file (see dartbug.com/14554)
85 var modifiedMainId = mainLibraryId.addExtension('_modified.dart');
86
87 libraries.add(modifiedMainId);
85 var urls = libraries.map((id) => assetUrlFor(id, bootstrapId, logger)) 88 var urls = libraries.map((id) => assetUrlFor(id, bootstrapId, logger))
86 .where((url) => url != null).toList(); 89 .where((url) => url != null).toList();
87 var buffer = new StringBuffer()..writeln(MAIN_HEADER); 90 var buffer = new StringBuffer()..writeln(MAIN_HEADER);
88 int i = 0; 91 int i = 0;
89 for (; i < urls.length; i++) { 92 for (; i < urls.length; i++) {
90 buffer.writeln("import '${urls[i]}' as i$i;"); 93 buffer.writeln("import '${urls[i]}' as i$i;");
91 } 94 }
92 95
93 buffer..write('\n') 96 buffer..write('\n')
94 ..writeln('void main() {') 97 ..writeln('void main() {')
95 ..writeln(' configureForDeployment([') 98 ..writeln(' configureForDeployment([')
96 ..writeAll(urls.map((url) => " '$url',\n")) 99 ..writeAll(urls.map((url) => " '$url',\n"))
97 ..writeln(' ]);') 100 ..writeln(' ]);')
98 ..writeln(' i${i - 1}.main();') 101 ..writeln(' i${i - 1}.polymerMainWrapper();')
99 ..writeln('}'); 102 ..writeln('}');
100 103
101 transform.addOutput(new Asset.fromString( 104 transform.addOutput(new Asset.fromString(
102 bootstrapId, buffer.toString())); 105 bootstrapId, buffer.toString()));
103 transform.addOutput(new Asset.fromString(id, document.outerHtml)); 106 transform.addOutput(new Asset.fromString(id, document.outerHtml));
107
108 return transform.readInputAsString(mainLibraryId).then((contents) {
109 transform.addOutput(new Asset.fromString(modifiedMainId,
110 '$contents\n\npolymerMainWrapper() => main();\n'));
111 });
104 }); 112 });
105 }); 113 });
106 } 114 }
107 } 115 }
108 116
109 const MAIN_HEADER = """ 117 const MAIN_HEADER = """
110 library app_bootstrap; 118 library app_bootstrap;
111 119
112 import 'package:polymer/polymer.dart'; 120 import 'package:polymer/polymer.dart';
113 """; 121 """;
OLDNEW
« no previous file with comments | « no previous file | pkg/polymer/lib/transformer.dart » ('j') | pkg/polymer/lib/transformer.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698