Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(473)

Side by Side Diff: pkg/polymer/lib/transformer.dart

Issue 427623002: Polymer transformer logs now show on the frontend for pub serve. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: dont wrap the logger in release mode Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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;
11 11
12 import 'src/build/build_filter.dart'; 12 import 'src/build/build_filter.dart';
13 import 'src/build/common.dart'; 13 import 'src/build/common.dart';
14 import 'src/build/import_inliner.dart'; 14 import 'src/build/import_inliner.dart';
15 import 'src/build/linter.dart'; 15 import 'src/build/linter.dart';
16 import 'src/build/build_log_combiner.dart';
16 import 'src/build/polyfill_injector.dart'; 17 import 'src/build/polyfill_injector.dart';
17 import 'src/build/script_compactor.dart'; 18 import 'src/build/script_compactor.dart';
18 19
19 /// The Polymer transformer, which internally runs several phases that will: 20 /// The Polymer transformer, which internally runs several phases that will:
20 /// * Extract inlined script tags into their separate files 21 /// * Extract inlined script tags into their separate files
21 /// * Apply the observable transformer on every Dart script. 22 /// * Apply the observable transformer on every Dart script.
22 /// * Inline imported html files 23 /// * Inline imported html files
23 /// * Combine scripts from multiple files into a single script tag 24 /// * Combine scripts from multiple files into a single script tag
24 /// * Inject extra polyfills needed to run on all browsers. 25 /// * Inject extra polyfills needed to run on all browsers.
25 /// 26 ///
26 /// At the end of these phases, this tranformer produces a single entrypoint 27 /// At the end of these phases, this tranformer produces a single entrypoint
27 /// HTML file with a single Dart script that can later be compiled with dart2js. 28 /// HTML file with a single Dart script that can later be compiled with dart2js.
28 class PolymerTransformerGroup implements TransformerGroup { 29 class PolymerTransformerGroup implements TransformerGroup {
29 final Iterable<Iterable> phases; 30 final Iterable<Iterable> phases;
30 31
31 PolymerTransformerGroup(TransformOptions options) 32 PolymerTransformerGroup(TransformOptions options)
32 : phases = createDeployPhases(options); 33 : phases = createDeployPhases(options);
33 34
34 PolymerTransformerGroup.asPlugin(BarbackSettings settings) 35 PolymerTransformerGroup.asPlugin(BarbackSettings settings)
35 : this(_parseSettings(settings)); 36 : this(_parseSettings(settings));
36 } 37 }
37 38
38 TransformOptions _parseSettings(BarbackSettings settings) { 39 TransformOptions _parseSettings(BarbackSettings settings) {
39 var args = settings.configuration; 40 var args = settings.configuration;
40 bool releaseMode = settings.mode == BarbackMode.RELEASE; 41 bool releaseMode = settings.mode == BarbackMode.RELEASE;
41 bool jsOption = args['js']; 42 bool jsOption = args['js'];
42 bool csp = args['csp'] == true; // defaults to false 43 bool csp = args['csp'] == true; // defaults to false
43 bool lint = args['lint'] != false; // defaults to true 44 bool lint = args['lint'] != false; // defaults to true
45 bool injectBuildLogs =
46 !releaseMode && args['inject_build_logs_in_output'] != false;
44 return new TransformOptions( 47 return new TransformOptions(
45 entryPoints: _readEntrypoints(args['entry_points']), 48 entryPoints: _readEntrypoints(args['entry_points']),
46 inlineStylesheets: _readInlineStylesheets(args['inline_stylesheets']), 49 inlineStylesheets: _readInlineStylesheets(args['inline_stylesheets']),
47 directlyIncludeJS: jsOption == null ? releaseMode : jsOption, 50 directlyIncludeJS: jsOption == null ? releaseMode : jsOption,
48 contentSecurityPolicy: csp, 51 contentSecurityPolicy: csp,
49 releaseMode: releaseMode, 52 releaseMode: releaseMode,
50 lint: lint); 53 lint: lint,
54 injectBuildLogsInOutput: injectBuildLogs);
51 } 55 }
52 56
53 _readEntrypoints(value) { 57 _readEntrypoints(value) {
54 if (value == null) return null; 58 if (value == null) return null;
55 var entryPoints = []; 59 var entryPoints = [];
56 bool error; 60 bool error;
57 if (value is List) { 61 if (value is List) {
58 entryPoints = value; 62 entryPoints = value;
59 error = value.any((e) => e is! String); 63 error = value.any((e) => e is! String);
60 } else if (value is String) { 64 } else if (value is String) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 TransformOptions options, {String sdkDir}) { 116 TransformOptions options, {String sdkDir}) {
113 // TODO(sigmund): this should be done differently. We should lint everything 117 // TODO(sigmund): this should be done differently. We should lint everything
114 // that is reachable and have the option to lint the rest (similar to how 118 // that is reachable and have the option to lint the rest (similar to how
115 // dart2js can analyze reachable code or entire libraries). 119 // dart2js can analyze reachable code or entire libraries).
116 var phases = options.lint ? [[new Linter(options)]] : []; 120 var phases = options.lint ? [[new Linter(options)]] : [];
117 return phases..addAll([ 121 return phases..addAll([
118 [new ImportInliner(options)], 122 [new ImportInliner(options)],
119 [new ObservableTransformer()], 123 [new ObservableTransformer()],
120 [new ScriptCompactor(options, sdkDir: sdkDir)], 124 [new ScriptCompactor(options, sdkDir: sdkDir)],
121 [new PolyfillInjector(options)], 125 [new PolyfillInjector(options)],
122 [new BuildFilter(options)] 126 [new BuildFilter(options)],
127 [new BuildLogCombiner(options)],
123 ]); 128 ]);
124 } 129 }
125 130
126 final RegExp _PACKAGE_PATH_REGEX = new RegExp(r'packages\/([^\/]+)\/(.*)'); 131 final RegExp _PACKAGE_PATH_REGEX = new RegExp(r'packages\/([^\/]+)\/(.*)');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698