Skip to content

Commit 57b3297

Browse files
committed
refactor: always use js2dart traceur and make examples run again
1 parent e5224d2 commit 57b3297

12 files changed

Lines changed: 47 additions & 39 deletions

File tree

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,3 @@
44
[submodule "tools/rtts-assert"]
55
path = tools/rtts-assert
66
url = git@github.com:angular/assert.git
7-
[submodule "tools/traceur"]
8-
path = tools/traceur
9-
url = git@github.com:google/traceur-compiler.git

gulpfile.js

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ var glob = require('glob');
1010
var ejs = require('gulp-ejs');
1111
var path = require('path');
1212

13-
// import js2dart and traceur build tasks
13+
// import js2dart build tasks
1414
var js2dartTasks = require('./tools/js2dart/gulp-tasks');
1515
js2dartTasks.install(gulp);
1616

17-
var traceurJsOptions = {
17+
var js2es5Options = {
1818
annotations: true, // parse annotations
1919
types: true, // parse types
2020
script: false, // parse as a module
@@ -24,15 +24,39 @@ var traceurJsOptions = {
2424
moduleName: true
2525
};
2626

27+
var js2dartOptions = {
28+
annotations: true, // parse annotations
29+
types: true, // parse types
30+
script: false, // parse as a module
31+
outputLanguage: 'dart',
32+
moduleName: true
33+
};
34+
2735
var traceur = require('./tools/js2dart/gulp-traceur');
28-
var js2dart = require('./tools/js2dart/gulp-js2dart');
36+
37+
// ---------
38+
// rtts-assert and traceur runtime
39+
40+
gulp.task('jsRuntime/build', function() {
41+
return jsRuntime(false);
42+
});
43+
44+
function jsRuntime(isWatch) {
45+
var srcFn = isWatch ? watch : gulp.src.bind(gulp);
46+
var rttsAssert = srcFn('tools/rtts-assert/src/assert.js')
47+
.pipe(traceur(js2es5Options))
48+
.pipe(gulp.dest('build/js'));
49+
var traceurRuntime = srcFn('tools/js2dart/node_modules/traceur/bin/traceur-runtime.js')
50+
.pipe(gulp.dest('build/js'));
51+
return mergeStreams(rttsAssert, traceurRuntime);
52+
}
2953

3054
// -----------------------
3155
// modules
3256
var sourceTypeConfigs = {
3357
dart: {
3458
compiler: function() {
35-
return js2dart({replace: true});
59+
return traceur(js2dartOptions, true);
3660
},
3761
transpileSrc: ['modules/**/*.es6d'],
3862
htmlSrc: ['modules/*/src/**/*.html'],
@@ -43,11 +67,11 @@ var sourceTypeConfigs = {
4367
},
4468
js: {
4569
compiler: function() {
46-
return traceur(traceurJsOptions);
70+
return traceur(js2es5Options, true);
4771
},
48-
transpileSrc: ['modules/**/*.es*', 'tools/rtts-assert/src/assert.js'],
72+
transpileSrc: ['modules/**/*.es*'],
4973
htmlSrc: ['modules/*/src/**/*.html'],
50-
copySrc: ['tools/traceur/bin/traceur-runtime.js'],
74+
copySrc: ['modules/**/*.js'],
5175
outputDir: 'build/js',
5276
outputExt: 'js'
5377
}
@@ -102,37 +126,28 @@ gulp.task('serve', connect.server({
102126
// --------------
103127
// general targets
104128

105-
gulp.task('clean', function(done) {
106-
return runSequence(['traceur/clean', 'js2dart/clean', 'modules/clean'], done);
107-
});
129+
gulp.task('clean', ['js2dart/clean', 'modules/clean']);
108130

109131
gulp.task('build', function() {
110132
return runSequence(
111133
// sequential
112-
'traceur/build', 'js2dart/build',
134+
'js2dart/build',
113135
// parallel
114-
['modules/build.dart', 'modules/build.js']
136+
['jsRuntime/build', 'modules/build.dart', 'modules/build.js']
115137
);
116138
});
117139

118140
gulp.task('watch', function() {
119-
var traceurWatch = watch(js2dartTasks.paths.traceurSrc, function(_, done) {
120-
runSequence(
121-
// sequential
122-
'traceur/build', 'js2dart/build', 'js2dart/test',
123-
// parallel
124-
['modules/build.dart', 'modules/build.js'],
125-
done);
126-
});
141+
runSequence('js2dart/test/watch');
127142
var js2dartWatch = watch(js2dartTasks.paths.js2dartSrc, function(_, done) {
128143
runSequence(
129144
// sequential
130145
'js2dart/build', 'js2dart/test',
131146
// parallel
132-
['modules/build.dart', 'modules/build.js'],
147+
['jsRuntime/build', 'modules/build.dart', 'modules/build.js'],
133148
done);
134149
});
135150
var dartModuleWatch = createModuleTask(sourceTypeConfigs.dart, true)();
136151
var jsModuleWatch = createModuleTask(sourceTypeConfigs.js, true)();
137-
return mergeStreams(traceurWatch, js2dartWatch, dartModuleWatch, jsModuleWatch);
152+
return mergeStreams(js2dartWatch, dartModuleWatch, jsModuleWatch, jsRuntime(true));
138153
});

modules/core/src/compiler/compiler.es6d

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import {ProtoView} from './proto_view';
44
export class Compiler {
55
/**
66
* # Why future?
7-
* - compilation will load templates. Instantiating views before templates are loaded will
7+
* - compilation will load templates. Instantiating views before templates are loaded will
88
* complicate the Directive code. BENEFIT: view instantiation become synchrnous.
99
* # Why result that is independent of injector?
1010
* - don't know about injector in deserialization
1111
* - compile does not need the injector, only the ViewFactory does
1212
*/
13-
@of(ProtoView) Future compile(TemplateElement element) {
13+
@of(ProtoView) compile(element:TemplateElement):Future {
1414
}
1515

1616
}

modules/core/src/compiler/proto_view.es6d

Whitespace-only changes.

modules/core/src/facade.dart

Whitespace-only changes.

modules/core/src/facade.es6

Whitespace-only changes.

modules/examples/src/todo/app.es6d

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ export class App {
1313
var html = DOM.getInnerHTML(this.list);
1414
html += '<li>'+this.input.value+'</li>';
1515
DOM.setInnerHTML(this.list, html);
16+
this.input.value = '';
1617
}
1718
}

modules/examples/src/todo/index.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
<% if(type === 'dart') { %>
99
<script src="main.dart" type="application/dart"></script>
1010
<% } else { %>
11-
<script src="../../traceur-runtime.js" type="text/javascript"></script>
12-
<script src="../../assert.js" type="text/javascript"></script>
11+
<script src="../../../traceur-runtime.js" type="text/javascript"></script>
12+
<script src="../../../assert.js" type="text/javascript"></script>
13+
1314
<script src="app.js" type="text/javascript"></script>
1415
<script src="dom.js" type="text/javascript"></script>
15-
<script>
16-
new (System.get("examples/todo/app").App)().run();
17-
</script>
16+
17+
<script src="main.js"></script>
1818
<% } %>
1919
</body>
2020
</html>

modules/examples/src/todo/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
new (System.get("examples/src/todo/app").App)().run();

postinstall.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
#! /bin/sh
22
git submodule init && git submodule update
33

4-
rm node_modules/traceur
5-
ln -s ../tools/traceur node_modules/traceur
6-
74
rm node_modules/js2dart
85
ln -s ../tools/js2dart node_modules/js2dart
96

10-
(cd tools/traceur; npm install)
11-
127
(cd tools/js2dart; npm install)

0 commit comments

Comments
 (0)