fix(transformer): fix 'pub build' in examples

This commit is contained in:
Sigmund Cherem 2015-07-09 13:59:36 -07:00 committed by yjbanov
parent 749d043258
commit 62589293aa
19 changed files with 38 additions and 21 deletions

View File

@ -269,6 +269,11 @@ class AnnotationsTransformVisitor extends ToSourceVisitor {
writer.print("template: r'''"); writer.print("template: r'''");
writer.asyncPrint(_readOrEmptyString(url)); writer.asyncPrint(_readOrEmptyString(url));
writer.print("'''"); writer.print("'''");
// We keep the templateUrl in case the body of the template includes
// relative urls that might be inlined later on (e.g. @import
// directives or url() css values in style tags).
writer.print(", templateUrl: r'$url'");
return null; return null;
} else { } else {
logger.warning('template url is not a String $url'); logger.warning('template url is not a String $url');

View File

@ -122,7 +122,7 @@ class _CodegenState {
localNames.map((name) => '_${name}_pipe').toList(); localNames.map((name) => '_${name}_pipe').toList();
void _writeToBuf(StringBuffer buf) { void _writeToBuf(StringBuffer buf) {
buf.write(''' buf.write('''\n
class $_changeDetectorTypeName extends $_BASE_CLASS { class $_changeDetectorTypeName extends $_BASE_CLASS {
final dynamic $_DISPATCHER_ACCESSOR; final dynamic $_DISPATCHER_ACCESSOR;
$_GEN_PREFIX.PipeRegistry $_PIPE_REGISTRY_ACCESSOR; $_GEN_PREFIX.PipeRegistry $_PIPE_REGISTRY_ACCESSOR;

View File

@ -1,4 +1,4 @@
library examples.src.hello_world.index_common_dart.ng_deps.dart; library examples.src.hello_world.absolute_url_expression_files.ng_deps.dart;
import 'hello.dart'; import 'hello.dart';
import 'package:angular2/angular2.dart' import 'package:angular2/angular2.dart'
@ -16,6 +16,7 @@ void initReflector(reflector) {
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View( const View(
template: r'''{{greeting}}''', template: r'''{{greeting}}''',
templateUrl: r'package:other_package/template.html',
styles: const [r'''.greeting { .color: blue; }''',]) styles: const [r'''.greeting { .color: blue; }''',])
] ]
}); });

View File

@ -1,4 +1,4 @@
library examples.src.hello_world.index_common_dart; library examples.src.hello_world.absolute_url_expression_files;
import 'package:angular2/angular2.dart' import 'package:angular2/angular2.dart'
show bootstrap, Component, Directive, View, NgElement; show bootstrap, Component, Directive, View, NgElement;

View File

@ -124,8 +124,8 @@ void _testNgDeps(String name, String inputPath,
if (output == null) { if (output == null) {
expect(await reader.hasInput(expectedId)).toBeFalse(); expect(await reader.hasInput(expectedId)).toBeFalse();
} else { } else {
expect(formatter.format(output)).toEqual( var input = await reader.readAsString(expectedId);
(await reader.readAsString(expectedId)).replaceAll('\r\n', '\n')); expect(formatter.format(output)).toEqual(formatter.format(input));
} }
if (expectedLogs != null) { if (expectedLogs != null) {

View File

@ -16,6 +16,7 @@ void initReflector(reflector) {
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View( const View(
template: r'''{{greeting}}''', template: r'''{{greeting}}''',
templateUrl: r'template.html',
styles: const [ styles: const [
r'''.greeting { .color: blue; }''', r'''.greeting { .color: blue; }''',
r'''.hello { .color: red; }''', r'''.hello { .color: red; }''',

View File

@ -1,4 +1,4 @@
library test.transform.directive_processor.url_expression_files.hello.ng_deps.dart; library test.transform.directive_processor.invalid_url_files.hello.ng_deps.dart;
import 'hello.dart'; import 'hello.dart';
import 'package:angular2/angular2.dart' import 'package:angular2/angular2.dart'
@ -14,7 +14,10 @@ void initReflector(reflector) {
'parameters': const [], 'parameters': const [],
'annotations': const [ 'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View(template: r'''''', styles: const [r'''''', r'''''',]) const View(
template: r'''''',
templateUrl: r'/bad/absolute/url.html',
styles: const [r'''''', r'''''',])
] ]
}); });
} }

View File

@ -1,4 +1,4 @@
library test.transform.directive_processor.url_expression_files.hello; library test.transform.directive_processor.invalid_url_files.hello;
import 'package:angular2/angular2.dart' import 'package:angular2/angular2.dart'
show bootstrap, Component, Directive, View, NgElement; show bootstrap, Component, Directive, View, NgElement;

View File

@ -1,4 +1,4 @@
library examples.src.hello_world.index_common_dart.ng_deps.dart; library examples.src.hello_world.multiple_style_urls_files.ng_deps.dart;
import 'hello.dart'; import 'hello.dart';
import 'package:angular2/angular2.dart' import 'package:angular2/angular2.dart'
@ -16,6 +16,7 @@ void initReflector(reflector) {
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View( const View(
template: r'''{{greeting}}''', template: r'''{{greeting}}''',
templateUrl: r'template.html',
styles: const [ styles: const [
r'''.greeting { .color: blue; }''', r'''.greeting { .color: blue; }''',
r'''.hello { .color: red; }''', r'''.hello { .color: red; }''',

View File

@ -1,4 +1,4 @@
library examples.src.hello_world.index_common_dart; library examples.src.hello_world.multiple_style_urls_files;
import 'package:angular2/angular2.dart' import 'package:angular2/angular2.dart'
show bootstrap, Component, Directive, View, NgElement; show bootstrap, Component, Directive, View, NgElement;

View File

@ -1,4 +1,4 @@
library examples.src.hello_world.index_common_dart.ng_deps.dart; library examples.src.hello_world.multiple_style_urls_not_inlined_files.ng_deps.dart;
import 'hello.dart'; import 'hello.dart';
import 'package:angular2/angular2.dart' import 'package:angular2/angular2.dart'

View File

@ -1,4 +1,4 @@
library examples.src.hello_world.index_common_dart; library examples.src.hello_world.multiple_style_urls_not_inlined_files;
import 'package:angular2/angular2.dart' import 'package:angular2/angular2.dart'
show bootstrap, Component, Directive, View, NgElement; show bootstrap, Component, Directive, View, NgElement;

View File

@ -1,4 +1,4 @@
library examples.src.hello_world.index_common_dart.ng_deps.dart; library examples.src.hello_world.split_url_expression_files.ng_deps.dart;
import 'hello.dart'; import 'hello.dart';
import 'package:angular2/angular2.dart' import 'package:angular2/angular2.dart'
@ -14,7 +14,7 @@ void initReflector(reflector) {
'parameters': const [], 'parameters': const [],
'annotations': const [ 'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View(template: r'''{{greeting}}''') const View(template: r'''{{greeting}}''', templateUrl: r'template.html')
] ]
}); });
} }

View File

@ -1,4 +1,4 @@
library examples.src.hello_world.index_common_dart; library examples.src.hello_world.split_url_expression_files;
import 'package:angular2/angular2.dart' import 'package:angular2/angular2.dart'
show bootstrap, Component, Directive, View, NgElement; show bootstrap, Component, Directive, View, NgElement;

View File

@ -1,4 +1,4 @@
library examples.src.hello_world.index_common_dart.ng_deps.dart; library examples.src.hello_world.url_expression_files.ng_deps.dart;
import 'hello.dart'; import 'hello.dart';
import 'package:angular2/angular2.dart' import 'package:angular2/angular2.dart'
@ -14,7 +14,7 @@ void initReflector(reflector) {
'parameters': const [], 'parameters': const [],
'annotations': const [ 'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View(template: r'''{{greeting}}''') const View(template: r'''{{greeting}}''', templateUrl: r'template.html')
] ]
}); });
} }

View File

@ -1,4 +1,4 @@
library examples.src.hello_world.index_common_dart; library examples.src.hello_world.url_expression_files;
import 'package:angular2/angular2.dart' import 'package:angular2/angular2.dart'
show bootstrap, Component, Directive, View, NgElement; show bootstrap, Component, Directive, View, NgElement;

View File

@ -123,7 +123,8 @@ void allTests() {
}); });
}); });
testPhases(config.name, [[transform]], config.assetPathToInputPath, testPhases(config.name, [[transform]], config.assetPathToInputPath,
config.assetPathToExpectedOutputPath, []); config.assetPathToExpectedOutputPath, [],
StringFormatter.noNewlinesOrSurroundingWhitespace);
} }
} }

View File

@ -16,6 +16,9 @@ dependency_overrides:
path: ../angular2_material path: ../angular2_material
transformers: transformers:
- angular2: - angular2:
# The build currently fails on material files because there is not yet
# support for transforming cross-package urls.
$exclude: 'web/src/material/**'
entry_points: entry_points:
- web/src/hello_world/index_common.dart - web/src/hello_world/index_common.dart
- web/src/todo/index.dart - web/src/todo/index.dart

View File

@ -181,11 +181,13 @@ label[for='toggle-all'] {
} }
#todo-list li .toggle:after { #todo-list li .toggle:after {
content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="-10 -18 100 135"><circle cx="50" cy="50" r="50" fill="none" stroke="#ededed" stroke-width="3"/></svg>'); /*encoded url: 'data:image/svg+xml;charset=utf8,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="-10 -18 100 135"><circle cx="50" cy="50" r="50" fill="none" stroke="#ededed" stroke-width="3"/></svg>'*/
content: url('data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2240%22%20height%3D%2240%22%20viewBox%3D%22-10%20-18%20100%20135%22%3E%3Ccircle%20cx%3D%2250%22%20cy%3D%2250%22%20r%3D%2250%22%20fill%3D%22none%22%20stroke%3D%22%23ededed%22%20stroke-width%3D%223%22%2F%3E%3C%2Fsvg%3E');
} }
#todo-list li .toggle:checked:after { #todo-list li .toggle:checked:after {
content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="-10 -18 100 135"><circle cx="50" cy="50" r="50" fill="none" stroke="#bddad5" stroke-width="3"/><path fill="#5dc2af" d="M72 25L42 71 27 56l-4 4 20 20 34-52z"/></svg>'); /*encoded url: 'data:image/svg+xml;charset=utf8,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="-10 -18 100 135"><circle cx="50" cy="50" r="50" fill="none" stroke="#bddad5" stroke-width="3"/><path fill="#5dc2af" d="M72 25L42 71 27 56l-4 4 20 20 34-52z"/></svg>'*/
content: url('data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2240%22%20height%3D%2240%22%20viewBox%3D%22-10%20-18%20100%20135%22%3E%3Ccircle%20cx%3D%2250%22%20cy%3D%2250%22%20r%3D%2250%22%20fill%3D%22none%22%20stroke%3D%22%23bddad5%22%20stroke-width%3D%223%22%2F%3E%3Cpath%20fill%3D%22%235dc2af%22%20d%3D%22M72%2025L42%2071%2027%2056l-4%204%2020%2020%2034-52z%22%2F%3E%3C%2Fsvg%3E');
} }
#todo-list li label { #todo-list li label {