| 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 import 'package:path/path.dart' as path; | 10 import 'package:path/path.dart' as path; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 : this(_parseSettings(settings)); | 37 : this(_parseSettings(settings)); |
| 38 } | 38 } |
| 39 | 39 |
| 40 TransformOptions _parseSettings(BarbackSettings settings) { | 40 TransformOptions _parseSettings(BarbackSettings settings) { |
| 41 var args = settings.configuration; | 41 var args = settings.configuration; |
| 42 bool releaseMode = settings.mode == BarbackMode.RELEASE; | 42 bool releaseMode = settings.mode == BarbackMode.RELEASE; |
| 43 bool jsOption = args['js']; | 43 bool jsOption = args['js']; |
| 44 bool csp = args['csp'] == true; // defaults to false | 44 bool csp = args['csp'] == true; // defaults to false |
| 45 bool injectBuildLogs = | 45 bool injectBuildLogs = |
| 46 !releaseMode && args['inject_build_logs_in_output'] != false; | 46 !releaseMode && args['inject_build_logs_in_output'] != false; |
| 47 bool injectPlatformJs = args['inject_platform_js'] != false; | 47 bool injectWebComponentsJs = true; |
| 48 if (args['inject_platform_js'] != null) { |
| 49 print( |
| 50 'Deprecated polymer transformer option `inject_platform_js`. This has ' |
| 51 'been renamed `inject_web_components_js` to match the new file name.'); |
| 52 injectWebComponentsJs = args['inject_platform_js'] != false; |
| 53 } |
| 54 if (args['inject_webcomponents_js'] != null) { |
| 55 injectWebComponentsJs = args['inject_webcomponents_js'] != false; |
| 56 } |
| 48 return new TransformOptions( | 57 return new TransformOptions( |
| 49 entryPoints: readFileList(args['entry_points']), | 58 entryPoints: readFileList(args['entry_points']), |
| 50 inlineStylesheets: _readInlineStylesheets(args['inline_stylesheets']), | 59 inlineStylesheets: _readInlineStylesheets(args['inline_stylesheets']), |
| 51 directlyIncludeJS: jsOption == null ? releaseMode : jsOption, | 60 directlyIncludeJS: jsOption == null ? releaseMode : jsOption, |
| 52 contentSecurityPolicy: csp, | 61 contentSecurityPolicy: csp, |
| 53 releaseMode: releaseMode, | 62 releaseMode: releaseMode, |
| 54 lint: _parseLintOption(args['lint']), | 63 lint: _parseLintOption(args['lint']), |
| 55 injectBuildLogsInOutput: injectBuildLogs, | 64 injectBuildLogsInOutput: injectBuildLogs, |
| 56 injectPlatformJs: injectPlatformJs); | 65 injectWebComponentsJs: injectWebComponentsJs); |
| 57 } | 66 } |
| 58 | 67 |
| 59 // Lint option can be empty (all files), false, true, or a map indicating | 68 // Lint option can be empty (all files), false, true, or a map indicating |
| 60 // include/exclude files. | 69 // include/exclude files. |
| 61 _parseLintOption(value) { | 70 _parseLintOption(value) { |
| 62 var lint = null; | 71 var lint = null; |
| 63 if (value == null || value == true) return new LintOptions(); | 72 if (value == null || value == true) return new LintOptions(); |
| 64 if (value == false) return new LintOptions.disabled(); | 73 if (value == false) return new LintOptions.disabled(); |
| 65 if (value is Map && value.length == 1) { | 74 if (value is Map && value.length == 1) { |
| 66 var key = value.keys.single; | 75 var key = value.keys.single; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 [new BuildFilter(options)], | 169 [new BuildFilter(options)], |
| 161 [new BuildLogCombiner(options)], | 170 [new BuildLogCombiner(options)], |
| 162 ]); | 171 ]); |
| 163 if (!options.releaseMode) { | 172 if (!options.releaseMode) { |
| 164 phases.add([new IndexPageBuilder(options)]); | 173 phases.add([new IndexPageBuilder(options)]); |
| 165 } | 174 } |
| 166 return phases; | 175 return phases; |
| 167 } | 176 } |
| 168 | 177 |
| 169 final RegExp _PACKAGE_PATH_REGEX = new RegExp(r'packages\/([^\/]+)\/(.*)'); | 178 final RegExp _PACKAGE_PATH_REGEX = new RegExp(r'packages\/([^\/]+)\/(.*)'); |
| OLD | NEW |