OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library initialize.build.loader_replacer; | 4 library initialize.build.loader_replacer; |
5 | 5 |
6 import 'dart:async'; | 6 import 'dart:async'; |
7 import 'package:barback/barback.dart'; | 7 import 'package:barback/barback.dart'; |
8 | 8 |
9 /// Removes `mirror_loader.dart` and replaces it with `static_loader.dart`. | 9 /// Removes `mirror_loader.dart` and replaces it with `static_loader.dart`. |
10 class LoaderReplacer extends Transformer { | 10 class LoaderReplacer extends Transformer { |
11 LoaderReplacer.asPlugin(); | 11 LoaderReplacer.asPlugin(); |
12 | 12 |
13 bool isPrimary(AssetId id) => | 13 bool isPrimary(AssetId id) => |
14 id.package == 'initialize' && id.path == 'lib/initialize.dart'; | 14 id.package == 'initialize' && id.path == 'lib/initialize.dart'; |
15 | 15 |
16 Future apply(Transform transform) { | 16 Future apply(Transform transform) { |
17 var id = transform.primaryInput.id; | 17 var id = transform.primaryInput.id; |
18 return transform.primaryInput.readAsString().then((code) { | 18 return transform.primaryInput.readAsString().then((code) { |
19 transform.addOutput(new Asset.fromString( | 19 transform.addOutput(new Asset.fromString( |
20 id, code.replaceFirst('mirror_loader.dart', 'static_loader.dart'))); | 20 id, code.replaceFirst('mirror_loader.dart', 'static_loader.dart'))); |
21 }); | 21 }); |
22 } | 22 } |
23 } | 23 } |
OLD | NEW |