chore(transform): move transform module to modules_dart

The build/pure-packages.dart gulp task has also been updated to move the files into the angular2 tree.
Closes #3729
This commit is contained in:
Jeff Cross
2015-08-19 10:36:52 -07:00
parent 92da5430e7
commit 88a5b8da0f
245 changed files with 16 additions and 3 deletions

View File

@ -0,0 +1,58 @@
library angular2.test.transform.deferred_rewriter.all_tests;
import 'package:barback/barback.dart';
import 'package:angular2/src/transform/deferred_rewriter/transformer.dart';
import 'package:angular2/src/transform/common/annotation_matcher.dart';
import 'package:angular2/src/transform/common/asset_reader.dart';
import 'package:angular2/src/transform/common/logging.dart' as log;
import 'package:code_transformers/messages/build_logger.dart';
import 'package:dart_style/dart_style.dart';
import 'package:guinness/guinness.dart';
import 'package:path/path.dart' as path;
import '../common/read_file.dart';
var formatter = new DartFormatter();
main() {
allTests();
}
void allTests() {
_testRewriteDeferredLibraries(
'should return null when no deferred libraries found.',
'no_deferred_libraries/index.dart');
_testRewriteDeferredLibraries(
'should return null when deferred libraries with no ng_deps.',
'no_ng_deps_libraries/index.dart');
_testRewriteDeferredLibraries(
'should rewrite deferred libraries with ng_deps.',
'simple_deferred_example/index.dart');
_testRewriteDeferredLibraries(
'should not rewrite deferred libraries without ng_deps.',
'deferred_example_no_ng_deps/index.dart');
_testRewriteDeferredLibraries(
'should rewrite deferred libraries with ng_deps leave other deferred library alone.',
'complex_deferred_example/index.dart');
}
void _testRewriteDeferredLibraries(String name, String inputPath) {
it(name, () async {
var inputId = _assetIdForPath(inputPath);
var reader = new TestAssetReader();
var expectedPath = path.join(
path.dirname(inputPath), 'expected', path.basename(inputPath));
var expectedId = _assetIdForPath(expectedPath);
var output = await rewriteDeferredLibraries(reader, inputId);
var input = await reader.readAsString(expectedId);
if (input == null) {
// Null input signals no output. Ensure that is true.
expect(output).toBeNull();
} else {
expect(formatter.format(output)).toEqual(formatter.format(input));
}
});
}
AssetId _assetIdForPath(String path) =>
new AssetId('angular2', 'test/transform/deferred_rewriter/$path');

View File

@ -0,0 +1,17 @@
library web_foo;
import 'package:angular2/src/core/application.dart';
import 'package:angular2/src/reflection/reflection.dart';
import 'package:angular2/src/reflection/reflection_capabilities.dart';
import 'hello.ng_deps.dart' deferred as a; // ng_deps. Should be rewritten.
import 'b.dart' deferred as b; // No ng_deps. Shouldn't be rewritten.
void main() {
reflector.reflectionCapabilities = new ReflectionCapabilities();
a.loadLibrary().then((_) {
a.initReflector();
}).then((_) {
bootstrap(a.HelloCmp);
});
b.loadLibrary();
}

View File

@ -0,0 +1,8 @@
library examples.src.hello_world.absolute_url_expression_files;
import 'package:angular2/angular2.dart'
show bootstrap, Component, Directive, View, NgElement;
@Component(selector: 'hello-app')
@View(templateUrl: 'package:other_package/template.html')
class HelloCmp {}

View File

@ -0,0 +1,22 @@
library examples.src.hello_world.absolute_url_expression_files.ng_deps.dart;
import 'hello.dart';
export 'hello.dart';
import 'package:angular2/src/reflection/reflection.dart' as _ngRef;
import 'package:angular2/angular2.dart'
show bootstrap, Component, Directive, View, NgElement;
var _visited = false;
void initReflector() {
if (_visited) return;
_visited = true;
_ngRef.reflector
..registerType(
HelloCmp,
new _ngRef.ReflectionInfo(const [
const Component(selector: 'hello-app'),
const View(
template: r'''{{greeting}}''',
templateUrl: r'package:other_package/template.html')
], const [], () => new HelloCmp()));
}

View File

@ -0,0 +1,15 @@
library web_foo;
import 'package:angular2/src/core/application.dart';
import 'package:angular2/src/reflection/reflection.dart';
import 'package:angular2/src/reflection/reflection_capabilities.dart';
import 'hello.dart' deferred as a; // ng_deps. Should be rewritten.
import 'b.dart' deferred as b; // No ng_deps. Shouldn't be rewritten.
void main() {
reflector.reflectionCapabilities = new ReflectionCapabilities();
a.loadLibrary().then((_) {
bootstrap(a.HelloCmp);
});
b.loadLibrary();
}

View File

@ -0,0 +1,8 @@
library examples.src.hello_world.absolute_url_expression_files;
import 'package:angular2/angular2.dart'
show bootstrap, Component, Directive, View, NgElement;
@Component(selector: 'hello-app')
@View(templateUrl: 'package:other_package/template.html')
class HelloCmp {}

View File

@ -0,0 +1,13 @@
library web_foo;
import 'package:angular2/src/core/application.dart';
import 'package:angular2/src/reflection/reflection.dart';
import 'package:angular2/src/reflection/reflection_capabilities.dart';
import 'hello.dart' deferred as a;
void main() {
reflector.reflectionCapabilities = new ReflectionCapabilities();
a.loadLibrary().then((_) {
bootstrap(a.HelloCmp);
});
}

View File

@ -0,0 +1,10 @@
library web_foo;
import 'package:angular2/src/core/application.dart';
import 'package:angular2/src/reflection/reflection.dart';
import 'package:angular2/src/reflection/reflection_capabilities.dart';
void main() {
reflector.reflectionCapabilities = new ReflectionCapabilities();
bootstrap(MyComponent);
}

View File

@ -0,0 +1,11 @@
library web_foo;
import 'package:angular2/src/core/application.dart';
import 'package:angular2/src/reflection/reflection.dart';
import 'package:angular2/src/reflection/reflection_capabilities.dart';
import 'a.dart' deferred as a;
void main() {
reflector.reflectionCapabilities = new ReflectionCapabilities();
bootstrap(MyComponent);
}

View File

@ -0,0 +1,15 @@
library web_foo;
import 'package:angular2/src/core/application.dart';
import 'package:angular2/src/reflection/reflection.dart';
import 'package:angular2/src/reflection/reflection_capabilities.dart';
import 'hello.ng_deps.dart' deferred as a;
void main() {
reflector.reflectionCapabilities = new ReflectionCapabilities();
a.loadLibrary().then((_) {
a.initReflector();
}).then((_) {
bootstrap(a.HelloCmp);
});
}

View File

@ -0,0 +1,8 @@
library examples.src.hello_world.absolute_url_expression_files;
import 'package:angular2/angular2.dart'
show bootstrap, Component, Directive, View, NgElement;
@Component(selector: 'hello-app')
@View(templateUrl: 'package:other_package/template.html')
class HelloCmp {}

View File

@ -0,0 +1,22 @@
library examples.src.hello_world.absolute_url_expression_files.ng_deps.dart;
import 'hello.dart';
export 'hello.dart';
import 'package:angular2/src/reflection/reflection.dart' as _ngRef;
import 'package:angular2/angular2.dart'
show bootstrap, Component, Directive, View, NgElement;
var _visited = false;
void initReflector() {
if (_visited) return;
_visited = true;
_ngRef.reflector
..registerType(
HelloCmp,
new _ngRef.RegistrationInfo(const [
const Component(selector: 'hello-app'),
const View(
template: r'''{{greeting}}''',
templateUrl: r'package:other_package/template.html')
], const [], () => new HelloCmp()));
}

View File

@ -0,0 +1,13 @@
library web_foo;
import 'package:angular2/src/core/application.dart';
import 'package:angular2/src/reflection/reflection.dart';
import 'package:angular2/src/reflection/reflection_capabilities.dart';
import 'hello.dart' deferred as a;
void main() {
reflector.reflectionCapabilities = new ReflectionCapabilities();
a.loadLibrary().then((_) {
bootstrap(a.HelloCmp);
});
}