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

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

Issue 28053008: Transformer plugin for polymer. This will make it possible (one day) to use (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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
« no previous file with comments | « pkg/polymer/lib/src/build/common.dart ('k') | pkg/polymer/test/build/all_phases_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 /** Transfomers used for pub-serve and pub-deploy. */ 5 /** Transfomer used for pub-serve and pub-deploy. */
6 // TODO(sigmund): move into a plugin directory when pub supports it. 6 library polymer.transformer;
7 library polymer.src.transform;
8 7
9 import 'package:barback/barback.dart'; 8 import 'package:barback/barback.dart';
10 import 'package:observe/transform.dart'; 9 import 'package:observe/transform.dart';
11 import 'src/build/code_extractor.dart'; 10 import 'src/build/code_extractor.dart';
12 import 'src/build/import_inliner.dart'; 11 import 'src/build/import_inliner.dart';
13 import 'src/build/script_compactor.dart'; 12 import 'src/build/script_compactor.dart';
14 import 'src/build/polyfill_injector.dart'; 13 import 'src/build/polyfill_injector.dart';
15 import 'src/build/common.dart'; 14 import 'src/build/common.dart';
16 15
17 export 'src/build/code_extractor.dart'; 16 /**
18 export 'src/build/import_inliner.dart'; 17 * The Polymer transformer, which internally runs several phases that will:
19 export 'src/build/script_compactor.dart'; 18 * * Extract inlined script tags into their separate files
20 export 'src/build/polyfill_injector.dart'; 19 * * Apply the observable transformer on every Dart script.
21 export 'src/build/common.dart' show TransformOptions; 20 * * Inline imported html files
21 * * Combine scripts from multiple files into a single script tag
22 * * Inject extra polyfills needed to run on all browsers.
23 *
24 * At the end of these phases, this tranformer produces a single entrypoint HTML
25 * file with a single Dart script that can later be compiled with dart2js.
26 */
27 class PolymerTransformerGroup implements TransformerGroup {
28 final Iterable<Iterable> phases;
22 29
23 /** Creates phases to deploy a polymer application. */ 30 PolymerTransformerGroup(TransformOptions options)
24 List<List<Transformer>> createDeployPhases(TransformOptions options) { 31 : phases = _createDeployPhases(options);
32
33 PolymerTransformerGroup.asPlugin(Map args) : this(_parseArgs(args));
34 }
35
36
37 TransformOptions _parseArgs(Map args) {
38 var entryPoints;
39 if (args.containsKey('entry_points')) {
40 entryPoints = [];
41 var value = args['entry_points'];
42 bool error;
43 if (value is List) {
44 entryPoints = value;
45 error = value.any((e) => e is! String);
46 } else if (value is String) {
47 entryPoints = [value];
48 error = false;
49 } else {
50 error = true;
51 }
52
53 if (error) {
54 print('Invalid value for "entry_points" in the polymer transformer.');
55 }
56 }
57 return new TransformOptions(entryPoints);
58 }
59
60 List<List<Transformer>> _createDeployPhases(TransformOptions options) {
25 return [ 61 return [
26 [new InlineCodeExtractor(options)], 62 [new InlineCodeExtractor(options)],
27 [new ObservableTransformer()], 63 [new ObservableTransformer()],
28 [new ImportInliner(options)], 64 [new ImportInliner(options)],
29 [new ScriptCompactor(options)], 65 [new ScriptCompactor(options)],
30 [new PolyfillInjector(options)] 66 [new PolyfillInjector(options)]
31 ]; 67 ];
32 } 68 }
OLDNEW
« no previous file with comments | « pkg/polymer/lib/src/build/common.dart ('k') | pkg/polymer/test/build/all_phases_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698