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 web_components.build.mirrors_remover; | 4 library web_components.build.mirrors_remover; |
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_initializer.dart` and replaces it with | 9 /// Removes `mirror_initializer.dart` and replaces it with |
10 /// `static_initializer.dart`. | 10 /// `static_initializer.dart`. |
11 class MirrorsRemoverTransformer extends Transformer { | 11 class MirrorsRemoverTransformer extends Transformer { |
12 MirrorsRemoverTransformer(); | 12 MirrorsRemoverTransformer(); |
13 MirrorsRemoverTransformer.asPlugin(BarbackSettings settings); | 13 MirrorsRemoverTransformer.asPlugin(BarbackSettings settings); |
14 | 14 |
15 bool isPrimary(AssetId id) => id.path == 'lib/src/init.dart'; | 15 bool isPrimary(AssetId id) => id.path == 'lib/src/init.dart'; |
16 | 16 |
17 @override | 17 @override |
18 Future apply(Transform transform) async { | 18 Future apply(Transform transform) async { |
19 String source = await transform.primaryInput.readAsString(); | 19 String source = await transform.primaryInput.readAsString(); |
20 source = | 20 source = |
21 source.replaceAll('mirror_initializer.dart', 'static_initializer.dart'); | 21 source.replaceAll('mirror_initializer.dart', 'static_initializer.dart'); |
22 transform | 22 transform |
23 .addOutput(new Asset.fromString(transform.primaryInput.id, source)); | 23 .addOutput(new Asset.fromString(transform.primaryInput.id, source)); |
24 } | 24 } |
25 } | 25 } |
OLD | NEW |