2015-04-09 18:56:54 -04:00
|
|
|
var Funnel = require('broccoli-funnel');
|
|
|
|
var mergeTrees = require('broccoli-merge-trees');
|
|
|
|
var stew = require('broccoli-stew');
|
2015-04-10 19:45:24 -04:00
|
|
|
var TraceurCompiler = require('./dist/broccoli/traceur');
|
|
|
|
var TypescriptCompiler = require('./dist/broccoli/typescript');
|
2015-04-09 18:56:54 -04:00
|
|
|
var renderLodashTemplate = require('broccoli-lodash');
|
|
|
|
|
2015-04-10 16:28:35 -04:00
|
|
|
var modulesTree = new Funnel(
|
|
|
|
'modules', {include: ['**/**'], exclude: ['angular2/src/core/zone/vm_turn_zone.es6']});
|
2015-04-09 18:56:54 -04:00
|
|
|
|
2015-04-10 16:28:35 -04:00
|
|
|
// Use Traceur to transpile original sources to ES5
|
|
|
|
var traceurOpts = {
|
2015-04-09 18:56:54 -04:00
|
|
|
sourceMaps: true,
|
|
|
|
annotations: true, // parse annotations
|
|
|
|
types: true, // parse types
|
|
|
|
script: false, // parse as a module
|
|
|
|
memberVariables: true, // parse class fields
|
|
|
|
typeAssertionModule: 'rtts_assert/rtts_assert',
|
|
|
|
// Don't use type assertions since this is partly transpiled by typescript
|
|
|
|
typeAssertions: false,
|
|
|
|
modules: 'commonjs'
|
2015-04-10 16:28:35 -04:00
|
|
|
};
|
|
|
|
var cjsTree = new TraceurCompiler(modulesTree, '.js', '.map', traceurOpts);
|
2015-04-09 18:56:54 -04:00
|
|
|
|
2015-04-10 16:28:35 -04:00
|
|
|
// Add the LICENSE file in each module
|
2015-04-09 18:56:54 -04:00
|
|
|
['angular2', 'benchmarks', 'benchmarks_external', 'benchpress', 'examples', 'rtts_assert'].forEach(
|
|
|
|
function(destDir) {
|
2015-04-10 16:28:35 -04:00
|
|
|
cjsTree = mergeTrees([cjsTree, new Funnel('.', {files: ['LICENSE'], destDir: destDir})]);
|
2015-04-09 18:56:54 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
extras = new Funnel(modulesTree, {include: ['**/*.md', '**/*.png'], exclude: ['**/*.dart.md']});
|
|
|
|
extras = stew.rename(extras, 'README.js.md', 'README.md');
|
|
|
|
|
|
|
|
var BASE_PACKAGE_JSON = require('./package.json');
|
|
|
|
var COMMON_PACKAGE_JSON = {
|
|
|
|
version: BASE_PACKAGE_JSON.version,
|
|
|
|
homepage: BASE_PACKAGE_JSON.homepage,
|
|
|
|
bugs: BASE_PACKAGE_JSON.bugs,
|
|
|
|
license: BASE_PACKAGE_JSON.license,
|
|
|
|
contributors: BASE_PACKAGE_JSON.contributors,
|
|
|
|
dependencies: BASE_PACKAGE_JSON.dependencies,
|
|
|
|
devDependencies: {
|
|
|
|
"yargs": BASE_PACKAGE_JSON.devDependencies['yargs'],
|
|
|
|
"gulp-sourcemaps": BASE_PACKAGE_JSON.devDependencies['gulp-sourcemaps'],
|
|
|
|
"gulp-traceur": BASE_PACKAGE_JSON.devDependencies['gulp-traceur'],
|
|
|
|
"gulp": BASE_PACKAGE_JSON.devDependencies['gulp'],
|
|
|
|
"gulp-rename": BASE_PACKAGE_JSON.devDependencies['gulp-rename'],
|
|
|
|
"through2": BASE_PACKAGE_JSON.devDependencies['through2']
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Add a .template extension since renderLodashTemplate strips one extension
|
2015-04-10 16:28:35 -04:00
|
|
|
var packageJsons =
|
|
|
|
stew.rename(new Funnel(modulesTree, {include: ['**/package.json']}), '.json', '.json.template');
|
|
|
|
packageJsons = renderLodashTemplate(
|
|
|
|
packageJsons, {files: ["**/**"], context: {'packageJson': COMMON_PACKAGE_JSON}});
|
|
|
|
|
|
|
|
var typescriptTree = new TypescriptCompiler(modulesTree, {
|
|
|
|
target: 'ES5',
|
|
|
|
sourceMap: true,
|
|
|
|
mapRoot: '', /* force sourcemaps to use relative path */
|
|
|
|
module: /*system.js*/'commonjs',
|
|
|
|
allowNonTsExtensions: false,
|
|
|
|
typescript: require('typescript'),
|
|
|
|
//declarationFiles: true,
|
|
|
|
noEmitOnError: true,
|
|
|
|
outDir: 'angular2'
|
2015-04-09 18:56:54 -04:00
|
|
|
});
|
|
|
|
|
2015-04-10 16:28:35 -04:00
|
|
|
// For now, we just overwrite the Traceur-compiled files with their Typescript equivalent
|
|
|
|
cjsTree = mergeTrees([cjsTree, typescriptTree], { overwrite: true });
|
2015-04-09 18:56:54 -04:00
|
|
|
cjsTree = mergeTrees([cjsTree, extras, packageJsons]);
|
|
|
|
|
|
|
|
module.exports = stew.mv(cjsTree, 'js/cjs');
|