| OLD | NEW |
| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 tag.remove(); | 67 tag.remove(); |
| 68 continue; | 68 continue; |
| 69 } | 69 } |
| 70 mainLibraryId = resolve(id, src, logger, tag.sourceSpan); | 70 mainLibraryId = resolve(id, src, logger, tag.sourceSpan); |
| 71 mainScriptTag = tag; | 71 mainScriptTag = tag; |
| 72 } | 72 } |
| 73 | 73 |
| 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 null; |
| 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 // TODO(sigmund): stop renaming the file (see dartbug.com/14554) | 84 // TODO(sigmund): stop renaming the file (see dartbug.com/14554) |
| 85 var modifiedMainId = mainLibraryId.addExtension('_modified.dart'); | 85 var modifiedMainId = mainLibraryId.addExtension('_modified.dart'); |
| 86 | 86 |
| 87 libraries.add(modifiedMainId); | 87 libraries.add(modifiedMainId); |
| 88 var urls = libraries.map((id) => assetUrlFor(id, bootstrapId, logger)) | 88 var urls = libraries.map((id) => assetUrlFor(id, bootstrapId, logger)) |
| 89 .where((url) => url != null).toList(); | 89 .where((url) => url != null).toList(); |
| 90 var buffer = new StringBuffer()..writeln(MAIN_HEADER); | 90 var buffer = new StringBuffer()..writeln(MAIN_HEADER); |
| 91 int i = 0; | 91 int i = 0; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 112 }); | 112 }); |
| 113 }); | 113 }); |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 | 116 |
| 117 const MAIN_HEADER = """ | 117 const MAIN_HEADER = """ |
| 118 library app_bootstrap; | 118 library app_bootstrap; |
| 119 | 119 |
| 120 import 'package:polymer/polymer.dart'; | 120 import 'package:polymer/polymer.dart'; |
| 121 """; | 121 """; |
| OLD | NEW |