| 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/transform.dart'; | 9 import 'package:observe/transform.dart'; |
| 10 import 'src/build/code_extractor.dart'; | 10 import 'src/build/code_extractor.dart'; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 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.transformer; | 38 var args = settings.configuration; |
| 39 bool release = settings.mode == BarbackMode.RELEASE; |
| 40 bool jsOption = args['js']; |
| 41 bool csp = args['csp'] == true; // defaults to false |
| 39 return new TransformOptions( | 42 return new TransformOptions( |
| 40 entryPoints: _readEntrypoints(args['entry_points']), | 43 entryPoints: _readEntrypoints(args['entry_points']), |
| 41 directlyIncludeJS: args['js'] != false, // default to true | 44 directlyIncludeJS: jsOption == null ? release : jsOption, |
| 42 contentSecurityPolicy: args['csp'] == true); // default to false | 45 contentSecurityPolicy: csp); |
| 43 } | 46 } |
| 44 | 47 |
| 45 _readEntrypoints(value) { | 48 _readEntrypoints(value) { |
| 46 if (value == null) return null; | 49 if (value == null) return null; |
| 47 var entryPoints = []; | 50 var entryPoints = []; |
| 48 bool error; | 51 bool error; |
| 49 if (value is List) { | 52 if (value is List) { |
| 50 entryPoints = value; | 53 entryPoints = value; |
| 51 error = value.any((e) => e is! String); | 54 error = value.any((e) => e is! String); |
| 52 } else if (value is String) { | 55 } else if (value is String) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 63 | 66 |
| 64 List<List<Transformer>> _createDeployPhases(TransformOptions options) { | 67 List<List<Transformer>> _createDeployPhases(TransformOptions options) { |
| 65 return [ | 68 return [ |
| 66 [new InlineCodeExtractor(options)], | 69 [new InlineCodeExtractor(options)], |
| 67 [new ObservableTransformer()], | 70 [new ObservableTransformer()], |
| 68 [new ImportInliner(options)], | 71 [new ImportInliner(options)], |
| 69 [new ScriptCompactor(options)], | 72 [new ScriptCompactor(options)], |
| 70 [new PolyfillInjector(options)] | 73 [new PolyfillInjector(options)] |
| 71 ]; | 74 ]; |
| 72 } | 75 } |
| OLD | NEW |