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 library pub.dart_forwarding_transformer; | 5 library pub.dart_forwarding_transformer; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:barback/barback.dart'; | 9 import 'package:barback/barback.dart'; |
10 | 10 |
11 import '../utils.dart'; | 11 import '../utils.dart'; |
12 | 12 |
13 /// A single transformer that just forwards any ".dart" file as an output when | 13 /// A single transformer that just forwards any ".dart" file as an output when |
14 /// not in release mode. | 14 /// not in release mode. |
15 /// | 15 /// |
16 /// Since the [Dart2JSTransformer] consumes its inputs, this is used in | 16 /// Since the [Dart2JSTransformer] consumes its inputs, this is used in |
17 /// parallel to make sure the original Dart file is still available for use by | 17 /// parallel to make sure the original Dart file is still available for use by |
18 /// Dartium. In release mode, it's used to the do the exact opposite: it | 18 /// Dartium. |
19 /// ensures that no Dart files are emitted, since all that is deployed is the | |
20 /// compiled JavaScript. | |
21 class DartForwardingTransformer extends Transformer { | 19 class DartForwardingTransformer extends Transformer { |
22 /// The mode that the transformer is running in. | 20 /// The mode that the transformer is running in. |
23 final BarbackMode _mode; | 21 final BarbackMode _mode; |
24 | 22 |
25 DartForwardingTransformer(this._mode); | 23 DartForwardingTransformer(this._mode); |
26 | 24 |
27 String get allowedExtensions => ".dart"; | 25 String get allowedExtensions => ".dart"; |
28 | 26 |
29 Future apply(Transform transform) { | 27 Future apply(Transform transform) { |
30 return newFuture(() { | 28 return newFuture(() { |
31 if (_mode != BarbackMode.RELEASE) { | 29 transform.addOutput(transform.primaryInput); |
32 transform.addOutput(transform.primaryInput); | |
33 } | |
34 }); | 30 }); |
35 } | 31 } |
36 } | 32 } |
OLD | NEW |