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

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

Issue 22852013: Fix polymer transformers in windows. AssetId's always use posix style paths (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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
« no previous file with comments | « pkg/polymer/lib/src/transform/common.dart ('k') | no next file » | no next file with comments »
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.transform.script_compactor; 6 library polymer.src.transform.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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 if (libraryId == null) continue; 55 if (libraryId == null) continue;
56 libraries.add(libraryId); 56 libraries.add(libraryId);
57 } 57 }
58 58
59 if (!changed) { 59 if (!changed) {
60 transform.addOutput(new Asset.fromString(id, content)); 60 transform.addOutput(new Asset.fromString(id, content));
61 return; 61 return;
62 } 62 }
63 63
64 var bootstrapId = id.addExtension('_bootstrap.dart'); 64 var bootstrapId = id.addExtension('_bootstrap.dart');
65 var filename = path.basename(bootstrapId.path); 65 var filename = path.url.basename(bootstrapId.path);
66 document.body.nodes.add(parseFragment( 66 document.body.nodes.add(parseFragment(
67 '<script type="application/dart" src="$filename"></script>')); 67 '<script type="application/dart" src="$filename"></script>'));
68 68
69 var urls = libraries.map((id) => importUrlFor(id, bootstrapId, logger)) 69 var urls = libraries.map((id) => importUrlFor(id, bootstrapId, logger))
70 .where((url) => url != null).toList(); 70 .where((url) => url != null).toList();
71 var buffer = new StringBuffer()..write(_header); 71 var buffer = new StringBuffer()..write(_header);
72 for (int i = 0; i < urls.length; i++) { 72 for (int i = 0; i < urls.length; i++) {
73 buffer.writeln("import '${urls[i]}' as i$i;"); 73 buffer.writeln("import '${urls[i]}' as i$i;");
74 } 74 }
75 buffer..write(_mainPrefix) 75 buffer..write(_mainPrefix)
(...skipping 14 matching lines...) Expand all
90 if (id.path.startsWith('lib/')) { 90 if (id.path.startsWith('lib/')) {
91 return 'package:${id.package}/${id.path.substring(4)}'; 91 return 'package:${id.package}/${id.path.substring(4)}';
92 } 92 }
93 93
94 // Use relative urls only if it's possible. 94 // Use relative urls only if it's possible.
95 if (id.package != sourceId.package) { 95 if (id.package != sourceId.package) {
96 logger.error("don't know how to import $id from $sourceId"); 96 logger.error("don't know how to import $id from $sourceId");
97 return null; 97 return null;
98 } 98 }
99 99
100 var upPath = path.joinAll(path.split(sourceId.path).map((_) => '..')); 100 var urlBuilder = path.url;
101 return path.normalize(path.join(sourceId.path, upPath, id.path)); 101 var upPath = urlBuilder.joinAll(
102 urlBuilder.split(sourceId.path).map((_) => '..'));
103 return urlBuilder.normalize(
104 urlBuilder.join(sourceId.path, upPath, id.path));
102 } 105 }
103 } 106 }
104 107
105 const _header = """ 108 const _header = """
106 library app_bootstrap; 109 library app_bootstrap;
107 110
108 import 'package:polymer/polymer.dart'; 111 import 'package:polymer/polymer.dart';
109 import 'dart:mirrors' show currentMirrorSystem; 112 import 'dart:mirrors' show currentMirrorSystem;
110 113
111 """; 114 """;
112 115
113 const _mainPrefix = """ 116 const _mainPrefix = """
114 117
115 void main() { 118 void main() {
116 initPolymer([ 119 initPolymer([
117 """; 120 """;
118 121
119 // TODO(sigmund): investigate alternative to get the baseUri (dartbug.com/12612) 122 // TODO(sigmund): investigate alternative to get the baseUri (dartbug.com/12612)
120 const _mainSuffix = """ 123 const _mainSuffix = """
121 ], currentMirrorSystem().isolate.rootLibrary.uri.toString()); 124 ], currentMirrorSystem().isolate.rootLibrary.uri.toString());
122 } 125 }
123 """; 126 """;
OLDNEW
« no previous file with comments | « pkg/polymer/lib/src/transform/common.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698