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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer/lib/transformer.dart
diff --git a/pkg/polymer/lib/transformer.dart b/pkg/polymer/lib/transformer.dart
index a0e4902cf48c464d75d7d0ca5596ed2d89273462..512014324aa6533344e4a104e946935071af4e82 100644
--- a/pkg/polymer/lib/transformer.dart
+++ b/pkg/polymer/lib/transformer.dart
@@ -2,9 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-/** Transfomers used for pub-serve and pub-deploy. */
-// TODO(sigmund): move into a plugin directory when pub supports it.
-library polymer.src.transform;
+/** Transfomer used for pub-serve and pub-deploy. */
+library polymer.transformer;
import 'package:barback/barback.dart';
import 'package:observe/transform.dart';
@@ -14,14 +13,51 @@ import 'src/build/script_compactor.dart';
import 'src/build/polyfill_injector.dart';
import 'src/build/common.dart';
-export 'src/build/code_extractor.dart';
-export 'src/build/import_inliner.dart';
-export 'src/build/script_compactor.dart';
-export 'src/build/polyfill_injector.dart';
-export 'src/build/common.dart' show TransformOptions;
+/**
+ * The Polymer transformer, which internally runs several phases that will:
+ * * Extract inlined script tags into their separate files
+ * * Apply the observable transformer on every Dart script.
+ * * Inline imported html files
+ * * Combine scripts from multiple files into a single script tag
+ * * Inject extra polyfills needed to run on all browsers.
+ *
+ * At the end of these phases, this tranformer produces a single entrypoint HTML
+ * file with a single Dart script that can later be compiled with dart2js.
+ */
+class PolymerTransformerGroup implements TransformerGroup {
+ final Iterable<Iterable> phases;
-/** Creates phases to deploy a polymer application. */
-List<List<Transformer>> createDeployPhases(TransformOptions options) {
+ PolymerTransformerGroup(TransformOptions options)
+ : phases = _createDeployPhases(options);
+
+ PolymerTransformerGroup.asPlugin(Map args) : this(_parseArgs(args));
+}
+
+
+TransformOptions _parseArgs(Map args) {
+ var entryPoints;
+ if (args.containsKey('entry_points')) {
+ entryPoints = [];
+ var value = args['entry_points'];
+ bool error;
+ if (value is List) {
+ entryPoints = value;
+ error = value.any((e) => e is! String);
+ } else if (value is String) {
+ entryPoints = [value];
+ error = false;
+ } else {
+ error = true;
+ }
+
+ if (error) {
+ print('Invalid value for "entry_points" in the polymer transformer.');
+ }
+ }
+ return new TransformOptions(entryPoints);
+}
+
+List<List<Transformer>> _createDeployPhases(TransformOptions options) {
return [
[new InlineCodeExtractor(options)],
[new ObservableTransformer()],
« 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