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 used for pub-serve and pub-deploy. | 5 /// Transfomer used for pub-serve and pub-deploy. |
6 library polymer.transformer; | 6 library polymer.transformer; |
7 | 7 |
8 import 'package:barback/barback.dart'; | 8 import 'package:barback/barback.dart'; |
9 import 'package:observe/transformer.dart'; | 9 import 'package:observe/transformer.dart'; |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 /// * Inline imported html files | 21 /// * Inline imported html files |
22 /// * Combine scripts from multiple files into a single script tag | 22 /// * Combine scripts from multiple files into a single script tag |
23 /// * Inject extra polyfills needed to run on all browsers. | 23 /// * Inject extra polyfills needed to run on all browsers. |
24 /// | 24 /// |
25 /// At the end of these phases, this tranformer produces a single entrypoint | 25 /// At the end of these phases, this tranformer produces a single entrypoint |
26 /// HTML file with a single Dart script that can later be compiled with dart2js. | 26 /// HTML file with a single Dart script that can later be compiled with dart2js. |
27 class PolymerTransformerGroup implements TransformerGroup { | 27 class PolymerTransformerGroup implements TransformerGroup { |
28 final Iterable<Iterable> phases; | 28 final Iterable<Iterable> phases; |
29 | 29 |
30 PolymerTransformerGroup(TransformOptions options) | 30 PolymerTransformerGroup(TransformOptions options) |
31 : phases = _createDeployPhases(options); | 31 : phases = createDeployPhases(options); |
32 | 32 |
33 PolymerTransformerGroup.asPlugin(BarbackSettings settings) | 33 PolymerTransformerGroup.asPlugin(BarbackSettings settings) |
34 : this(_parseSettings(settings)); | 34 : this(_parseSettings(settings)); |
35 } | 35 } |
36 | 36 |
37 TransformOptions _parseSettings(BarbackSettings settings) { | 37 TransformOptions _parseSettings(BarbackSettings settings) { |
38 var args = settings.configuration; | 38 var args = settings.configuration; |
39 bool releaseMode = settings.mode == BarbackMode.RELEASE; | 39 bool releaseMode = settings.mode == BarbackMode.RELEASE; |
40 bool jsOption = args['js']; | 40 bool jsOption = args['js']; |
41 bool csp = args['csp'] == true; // defaults to false | 41 bool csp = args['csp'] == true; // defaults to false |
(...skipping 20 matching lines...) Expand all Loading... |
62 if (error) { | 62 if (error) { |
63 print('Invalid value for "entry_points" in the polymer transformer.'); | 63 print('Invalid value for "entry_points" in the polymer transformer.'); |
64 } | 64 } |
65 return entryPoints; | 65 return entryPoints; |
66 } | 66 } |
67 | 67 |
68 /// Create deploy phases for Polymer. Note that inlining HTML Imports | 68 /// Create deploy phases for Polymer. Note that inlining HTML Imports |
69 /// comes first (other than linter, if [options.linter] is enabled), which | 69 /// comes first (other than linter, if [options.linter] is enabled), which |
70 /// allows the rest of the HTML-processing phases to operate only on HTML that | 70 /// allows the rest of the HTML-processing phases to operate only on HTML that |
71 /// is actually imported. | 71 /// is actually imported. |
72 List<List<Transformer>> _createDeployPhases(TransformOptions options) { | 72 List<List<Transformer>> createDeployPhases( |
| 73 TransformOptions options, {String sdkDir}) { |
73 var phases = options.lint ? [[new Linter(options)]] : []; | 74 var phases = options.lint ? [[new Linter(options)]] : []; |
74 return phases..addAll([ | 75 return phases..addAll([ |
75 [new ImportInliner(options)], | 76 [new ImportInliner(options)], |
76 [new ObservableTransformer()], | 77 [new ObservableTransformer()], |
77 [new ScriptCompactor(options)], | 78 [new ScriptCompactor(options, sdkDir: sdkDir)], |
78 [new PolyfillInjector(options)], | 79 [new PolyfillInjector(options)], |
79 [new BuildFilter(options)] | 80 [new BuildFilter(options)] |
80 ]); | 81 ]); |
81 } | 82 } |
OLD | NEW |