Skip to content

Commit 42c0171

Browse files
author
Tim Blasi
committed
chore(dart/transform): Create targets for serving transformed Dart code
- Allow pub (build|serve) to specify mode - Update pubbuild.js & pubserve.js to allow the caller to provide a `mode` value. - Update settings to allow the di benchmark to be transformed to run statically.
1 parent 1a99090 commit 42c0171

File tree

5 files changed

+35
-37
lines changed

5 files changed

+35
-37
lines changed

gulpfile.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ var CONFIG = {
183183
},
184184
dart: {
185185
src: [
186-
'modules/**/*.md', '!modules/**/*.js.md', 'modules/**/*.png',
186+
'modules/**/*.md', '!modules/**/*.js.md', 'modules/**/*.png', 'modules/**/*.html',
187187
'modules/**/*.dart', 'modules/*/pubspec.yaml', 'modules/**/*.css', '!modules/**/e2e_test/**'
188188
],
189189
pipes: {
@@ -608,6 +608,24 @@ gulp.task('serve/benchmarks_external.dart', pubserve(gulp, gulpPlugins, {
608608
path: CONFIG.dest.dart + '/benchmarks_external'
609609
}));
610610

611+
gulp.task('serve/examples.dart.static', pubserve(gulp, gulpPlugins, {
612+
command: DART_SDK.PUB,
613+
mode: 'ngstatic',
614+
path: CONFIG.dest.dart + '/examples'
615+
}));
616+
617+
gulp.task('serve/benchmarks.dart.static', pubserve(gulp, gulpPlugins, {
618+
command: DART_SDK.PUB,
619+
mode: 'ngstatic',
620+
path: CONFIG.dest.dart + '/benchmarks'
621+
}));
622+
623+
gulp.task('serve/benchmarks_external.dart.static', pubserve(gulp, gulpPlugins, {
624+
command: DART_SDK.PUB,
625+
mode: 'ngstatic',
626+
path: CONFIG.dest.dart + '/benchmarks_external'
627+
}));
628+
611629
// --------------
612630
// doc generation
613631
var Dgeni = require('dgeni');
@@ -758,12 +776,6 @@ gulp.task('test.transpiler.unittest', function (done) {
758776
}))
759777
});
760778

761-
// Copy test resources to dist
762-
gulp.task('tests/transform.dart', function() {
763-
return gulp.src('modules/angular2/test/transform/**')
764-
.pipe(gulp.dest('dist/dart/angular2/test/transform'));
765-
});
766-
767779

768780

769781
// -----------------
@@ -773,7 +785,6 @@ gulp.task('tests/transform.dart', function() {
773785
gulp.task('build/packages.dart', function(done) {
774786
runSequence(
775787
['build/transpile.dart.ts2dart', 'build/transpile.dart', 'build/html.dart', 'build/copy.dart', 'build/multicopy.dart'],
776-
'tests/transform.dart',
777788
// the two format steps don't need to be sequential, but we have seen flakiness in
778789
// dartstyle:format with connecting to localhost.
779790
'build/format.dart.ts2dart',

modules/benchmarks/pubspec.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ dependency_overrides:
1515
angular2:
1616
path: ../angular2
1717
transformers:
18+
- angular2:
19+
entry_point: web/src/di/di_benchmark.dart
1820
- $dart2js:
1921
minify: false
2022
commandLineOptions: ['--dump-info', '--trust-type-annotations', '--trust-primitives']

modules/benchmarks/src/di/di_benchmark.js

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,13 @@
1-
import {Injector, Key} from "angular2/di";
1+
import {Injectable, Injector, Key} from "angular2/di";
22
import {reflector} from 'angular2/src/reflection/reflection';
3+
import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities';
34
import {getIntParameter, bindAction, microBenchmark} from 'angular2/src/test_lib/benchmark_util';
45
import {BrowserDomAdapter} from 'angular2/src/dom/browser_adapter';
56

67
var count = 0;
78

89
function setupReflector() {
9-
reflector.registerType(A, {
10-
'factory': () => new A(),
11-
'parameters': [],
12-
'annotations' : []
13-
});
14-
reflector.registerType(B, {
15-
'factory': (a) => new B(a),
16-
'parameters': [[A]],
17-
'annotations' : []
18-
});
19-
reflector.registerType(C, {
20-
'factory': (b) => new C(b),
21-
'parameters': [[B]],
22-
'annotations' : []
23-
});
24-
reflector.registerType(D, {
25-
'factory': (c,b) => new D(c,b),
26-
'parameters': [[C],[B]],
27-
'annotations' : []
28-
});
29-
reflector.registerType(E, {
30-
'factory': (d,c) => new E(d,c),
31-
'parameters': [[D],[C]],
32-
'annotations' : []
33-
});
10+
reflector.reflectionCapabilities = new ReflectionCapabilities();
3411
}
3512

3613
export function main() {
@@ -97,31 +74,35 @@ export function main() {
9774

9875

9976

100-
77+
@Injectable()
10178
class A {
10279
constructor() {
10380
count++;
10481
}
10582
}
10683

84+
@Injectable()
10785
class B {
10886
constructor(a:A) {
10987
count++;
11088
}
11189
}
11290

91+
@Injectable()
11392
class C {
11493
constructor(b:B) {
11594
count++;
11695
}
11796
}
11897

98+
@Injectable()
11999
class D {
120100
constructor(c:C, b:B) {
121101
count++;
122102
}
123103
}
124104

105+
@Injectable()
125106
class E {
126107
constructor(d:D, c:C) {
127108
count++;

tools/build/pubbuild.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ module.exports = function(gulp, plugins, config) {
1717
}
1818
var folder = path.resolve(path.join(webFolders.shift(), '..'));
1919
var destFolder = path.resolve(path.join(config.dest, path.basename(folder)));
20-
return util.processToPromise(spawn(config.command, ['build', '-o', destFolder], {
20+
var pubMode = config.mode || 'release';
21+
var pubArgs = ['build', '--mode', pubMode, '-o', destFolder];
22+
return util.processToPromise(spawn(config.command, pubArgs, {
2123
stdio: 'inherit',
2224
cwd: folder
2325
})).then(function() {

tools/build/pubserve.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ var spawn = require('child_process').spawn;
33

44
module.exports = function(gulp, plugins, config, module) {
55
return function() {
6-
return util.streamToPromise(spawn(config.command, ['serve'], {
6+
var pubMode = config.mode || 'debug';
7+
var pubArgs = ['serve', '--mode', pubMode];
8+
return util.streamToPromise(spawn(config.command, pubArgs, {
79
cwd: config.path, stdio: 'inherit'
810
}));
911
};

0 commit comments

Comments
 (0)