refactor: always use js2dart traceur and make examples run again
This commit is contained in:
parent
e5224d2cb3
commit
57b3297bf6
|
@ -4,6 +4,3 @@
|
|||
[submodule "tools/rtts-assert"]
|
||||
path = tools/rtts-assert
|
||||
url = git@github.com:angular/assert.git
|
||||
[submodule "tools/traceur"]
|
||||
path = tools/traceur
|
||||
url = git@github.com:google/traceur-compiler.git
|
||||
|
|
59
gulpfile.js
59
gulpfile.js
|
@ -10,11 +10,11 @@ var glob = require('glob');
|
|||
var ejs = require('gulp-ejs');
|
||||
var path = require('path');
|
||||
|
||||
// import js2dart and traceur build tasks
|
||||
// import js2dart build tasks
|
||||
var js2dartTasks = require('./tools/js2dart/gulp-tasks');
|
||||
js2dartTasks.install(gulp);
|
||||
|
||||
var traceurJsOptions = {
|
||||
var js2es5Options = {
|
||||
annotations: true, // parse annotations
|
||||
types: true, // parse types
|
||||
script: false, // parse as a module
|
||||
|
@ -24,15 +24,39 @@ var traceurJsOptions = {
|
|||
moduleName: true
|
||||
};
|
||||
|
||||
var js2dartOptions = {
|
||||
annotations: true, // parse annotations
|
||||
types: true, // parse types
|
||||
script: false, // parse as a module
|
||||
outputLanguage: 'dart',
|
||||
moduleName: true
|
||||
};
|
||||
|
||||
var traceur = require('./tools/js2dart/gulp-traceur');
|
||||
var js2dart = require('./tools/js2dart/gulp-js2dart');
|
||||
|
||||
// ---------
|
||||
// rtts-assert and traceur runtime
|
||||
|
||||
gulp.task('jsRuntime/build', function() {
|
||||
return jsRuntime(false);
|
||||
});
|
||||
|
||||
function jsRuntime(isWatch) {
|
||||
var srcFn = isWatch ? watch : gulp.src.bind(gulp);
|
||||
var rttsAssert = srcFn('tools/rtts-assert/src/assert.js')
|
||||
.pipe(traceur(js2es5Options))
|
||||
.pipe(gulp.dest('build/js'));
|
||||
var traceurRuntime = srcFn('tools/js2dart/node_modules/traceur/bin/traceur-runtime.js')
|
||||
.pipe(gulp.dest('build/js'));
|
||||
return mergeStreams(rttsAssert, traceurRuntime);
|
||||
}
|
||||
|
||||
// -----------------------
|
||||
// modules
|
||||
var sourceTypeConfigs = {
|
||||
dart: {
|
||||
compiler: function() {
|
||||
return js2dart({replace: true});
|
||||
return traceur(js2dartOptions, true);
|
||||
},
|
||||
transpileSrc: ['modules/**/*.es6d'],
|
||||
htmlSrc: ['modules/*/src/**/*.html'],
|
||||
|
@ -43,11 +67,11 @@ var sourceTypeConfigs = {
|
|||
},
|
||||
js: {
|
||||
compiler: function() {
|
||||
return traceur(traceurJsOptions);
|
||||
return traceur(js2es5Options, true);
|
||||
},
|
||||
transpileSrc: ['modules/**/*.es*', 'tools/rtts-assert/src/assert.js'],
|
||||
transpileSrc: ['modules/**/*.es*'],
|
||||
htmlSrc: ['modules/*/src/**/*.html'],
|
||||
copySrc: ['tools/traceur/bin/traceur-runtime.js'],
|
||||
copySrc: ['modules/**/*.js'],
|
||||
outputDir: 'build/js',
|
||||
outputExt: 'js'
|
||||
}
|
||||
|
@ -102,37 +126,28 @@ gulp.task('serve', connect.server({
|
|||
// --------------
|
||||
// general targets
|
||||
|
||||
gulp.task('clean', function(done) {
|
||||
return runSequence(['traceur/clean', 'js2dart/clean', 'modules/clean'], done);
|
||||
});
|
||||
gulp.task('clean', ['js2dart/clean', 'modules/clean']);
|
||||
|
||||
gulp.task('build', function() {
|
||||
return runSequence(
|
||||
// sequential
|
||||
'traceur/build', 'js2dart/build',
|
||||
'js2dart/build',
|
||||
// parallel
|
||||
['modules/build.dart', 'modules/build.js']
|
||||
['jsRuntime/build', 'modules/build.dart', 'modules/build.js']
|
||||
);
|
||||
});
|
||||
|
||||
gulp.task('watch', function() {
|
||||
var traceurWatch = watch(js2dartTasks.paths.traceurSrc, function(_, done) {
|
||||
runSequence(
|
||||
// sequential
|
||||
'traceur/build', 'js2dart/build', 'js2dart/test',
|
||||
// parallel
|
||||
['modules/build.dart', 'modules/build.js'],
|
||||
done);
|
||||
});
|
||||
runSequence('js2dart/test/watch');
|
||||
var js2dartWatch = watch(js2dartTasks.paths.js2dartSrc, function(_, done) {
|
||||
runSequence(
|
||||
// sequential
|
||||
'js2dart/build', 'js2dart/test',
|
||||
// parallel
|
||||
['modules/build.dart', 'modules/build.js'],
|
||||
['jsRuntime/build', 'modules/build.dart', 'modules/build.js'],
|
||||
done);
|
||||
});
|
||||
var dartModuleWatch = createModuleTask(sourceTypeConfigs.dart, true)();
|
||||
var jsModuleWatch = createModuleTask(sourceTypeConfigs.js, true)();
|
||||
return mergeStreams(traceurWatch, js2dartWatch, dartModuleWatch, jsModuleWatch);
|
||||
return mergeStreams(js2dartWatch, dartModuleWatch, jsModuleWatch, jsRuntime(true));
|
||||
});
|
||||
|
|
|
@ -4,13 +4,13 @@ import {ProtoView} from './proto_view';
|
|||
export class Compiler {
|
||||
/**
|
||||
* # Why future?
|
||||
* - compilation will load templates. Instantiating views before templates are loaded will
|
||||
* - compilation will load templates. Instantiating views before templates are loaded will
|
||||
* complicate the Directive code. BENEFIT: view instantiation become synchrnous.
|
||||
* # Why result that is independent of injector?
|
||||
* - don't know about injector in deserialization
|
||||
* - compile does not need the injector, only the ViewFactory does
|
||||
*/
|
||||
@of(ProtoView) Future compile(TemplateElement element) {
|
||||
@of(ProtoView) compile(element:TemplateElement):Future {
|
||||
}
|
||||
|
||||
}
|
|
@ -13,5 +13,6 @@ export class App {
|
|||
var html = DOM.getInnerHTML(this.list);
|
||||
html += '<li>'+this.input.value+'</li>';
|
||||
DOM.setInnerHTML(this.list, html);
|
||||
this.input.value = '';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
<% if(type === 'dart') { %>
|
||||
<script src="main.dart" type="application/dart"></script>
|
||||
<% } else { %>
|
||||
<script src="../../traceur-runtime.js" type="text/javascript"></script>
|
||||
<script src="../../assert.js" type="text/javascript"></script>
|
||||
<script src="../../../traceur-runtime.js" type="text/javascript"></script>
|
||||
<script src="../../../assert.js" type="text/javascript"></script>
|
||||
|
||||
<script src="app.js" type="text/javascript"></script>
|
||||
<script src="dom.js" type="text/javascript"></script>
|
||||
<script>
|
||||
new (System.get("examples/todo/app").App)().run();
|
||||
</script>
|
||||
|
||||
<script src="main.js"></script>
|
||||
<% } %>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1 @@
|
|||
new (System.get("examples/src/todo/app").App)().run();
|
|
@ -1,12 +1,7 @@
|
|||
#! /bin/sh
|
||||
git submodule init && git submodule update
|
||||
|
||||
rm node_modules/traceur
|
||||
ln -s ../tools/traceur node_modules/traceur
|
||||
|
||||
rm node_modules/js2dart
|
||||
ln -s ../tools/js2dart node_modules/js2dart
|
||||
|
||||
(cd tools/traceur; npm install)
|
||||
|
||||
(cd tools/js2dart; npm install)
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 3f5e00b6be9ba8c2920732a08e2eb113f1485631
|
||||
Subproject commit 19b058e6f45325999cc55a4ba1cb670e8431cd89
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 573ac4091b79167532ef929993e82fda96325718
|
Loading…
Reference in New Issue