diff --git a/build/babel-options.js b/build/babel-options.js index 60a148b..470fb3d 100644 --- a/build/babel-options.js +++ b/build/babel-options.js @@ -1,35 +1,53 @@ var path = require('path'); var paths = require('./paths'); -module.exports = { - filename: '', - filenameRelative: '', - modules: '', - sourceMap: true, - sourceMapName: '', - sourceRoot: '', - moduleRoot: path.resolve('src').replace(/\\/g, '/'), - moduleIds: false, - experimental: false, - comments: false, - compact: false, - code:true, - stage:2, - loose: "all", - optional: [ - "es7.decorators", - "es7.classProperties" - ], - plugins: [ - "babel-dts-generator" - ], - extra: { - dts: { - packageName: paths.packageName, - typings: '', - suppressModulePath: true, - suppressComments: false, - memberOutputFilter: /^_.*/ - } - } +exports.base = function() { + return { + filename: '', + filenameRelative: '', + sourceMap: true, + sourceRoot: '', + moduleRoot: path.resolve('src').replace(/\\/g, '/'), + moduleIds: false, + comments: false, + compact: false, + code:true, + presets: [ 'es2015-loose', 'stage-1'], + plugins: [ + 'syntax-flow', + 'transform-decorators-legacy', + ['babel-dts-generator', { + packageName: paths.packageName, + typings: '', + suppressModulePath: true, + suppressComments: false, + memberOutputFilter: /^_.*/ + }], + 'transform-flow-strip-types' + ] + }; +} + +exports.commonjs = function() { + var options = exports.base(); + options.plugins.push('transform-es2015-modules-commonjs'); + return options; +}; + +exports.amd = function() { + var options = exports.base(); + options.plugins.push('transform-es2015-modules-amd'); + return options; +}; + +exports.system = function() { + var options = exports.base(); + options.plugins.push('transform-es2015-modules-systemjs'); + return options; +}; + +exports.es2015 = function() { + var options = exports.base(); + options.presets = ['stage-1'] + return options; }; diff --git a/build/tasks/build.js b/build/tasks/build.js index 3a510e5..dbef213 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -14,33 +14,34 @@ gulp.task('build-index', function(){ .pipe(gulp.dest(paths.output)); }); -gulp.task('build-es6', function () { +gulp.task('build-es2015', function () { return gulp.src(paths.output + jsName) - .pipe(gulp.dest(paths.output + 'es6')); + .pipe(to5(assign({}, compilerOptions.es2015()))) + .pipe(gulp.dest(paths.output + 'es2015')); }); gulp.task('build-commonjs', function () { return gulp.src(paths.output + jsName) - .pipe(to5(assign({}, compilerOptions, {modules:'common'}))) + .pipe(to5(assign({}, compilerOptions.commonjs()))) .pipe(gulp.dest(paths.output + 'commonjs')); }); gulp.task('build-amd', function () { return gulp.src(paths.output + jsName) - .pipe(to5(assign({}, compilerOptions, {modules:'amd'}))) + .pipe(to5(assign({}, compilerOptions.amd()))) .pipe(gulp.dest(paths.output + 'amd')); }); gulp.task('build-system', function () { return gulp.src(paths.output + jsName) - .pipe(to5(assign({}, compilerOptions, {modules:'system'}))) + .pipe(to5(assign({}, compilerOptions.system()))) .pipe(gulp.dest(paths.output + 'system')); }); gulp.task('build-dts', function(){ return gulp.src(paths.output + paths.packageName + '.d.ts') .pipe(rename(paths.packageName + '.d.ts')) - .pipe(gulp.dest(paths.output + 'es6')) + .pipe(gulp.dest(paths.output + 'es2015')) .pipe(gulp.dest(paths.output + 'commonjs')) .pipe(gulp.dest(paths.output + 'amd')) .pipe(gulp.dest(paths.output + 'system')); @@ -50,7 +51,7 @@ gulp.task('build', function(callback) { return runSequence( 'clean', 'build-index', - ['build-es6', 'build-commonjs', 'build-amd', 'build-system'], + ['build-es2015', 'build-commonjs', 'build-amd', 'build-system'], 'build-dts', callback ); diff --git a/karma.conf.js b/karma.conf.js index 6627feb..ad02a93 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -36,11 +36,11 @@ module.exports = function(config) { 'babelPreprocessor': { options: { sourceMap: 'inline', - modules: 'system', - moduleIds: false, - loose: "all", - optional: [ - "es7.decorators" + presets: [ 'es2015-loose', 'stage-1'], + plugins: [ + 'syntax-flow', + 'transform-decorators-legacy', + 'transform-flow-strip-types' ] } }, diff --git a/package.json b/package.json index d8fe73c..92fcc9b 100644 --- a/package.json +++ b/package.json @@ -44,12 +44,21 @@ }, "devDependencies": { "aurelia-tools": "^0.1.12", - "babel-dts-generator": "^0.2.17", + "babel-dts-generator": "^0.4.7", "babel-eslint": "^4.1.1", + "babel-plugin-syntax-flow": "^6.5.0", + "babel-plugin-transform-decorators-legacy": "^1.3.4", + "babel-plugin-transform-es2015-modules-amd": "^6.6.5", + "babel-plugin-transform-es2015-modules-commonjs": "^6.7.0", + "babel-plugin-transform-es2015-modules-systemjs": "^6.6.5", + "babel-plugin-transform-flow-strip-types": "^6.7.0", + "babel-preset-es2015": "^6.6.0", + "babel-preset-es2015-loose": "^7.0.0", + "babel-preset-stage-1": "^6.5.0", "conventional-changelog": "0.0.11", "del": "^1.1.0", "gulp": "^3.8.10", - "gulp-babel": "^5.2.1", + "gulp-babel": "^6.1.2", "gulp-bump": "^0.3.1", "gulp-eslint": "^1.0.0", "gulp-rename": "^1.2.2", @@ -57,7 +66,7 @@ "gulp-typedoc-extractor": "^0.0.8", "jasmine-core": "^2.1.3", "karma": "^0.13.15", - "karma-babel-preprocessor": "^5.2.2", + "karma-babel-preprocessor": "^6.0.1", "karma-chrome-launcher": "^0.1.7", "karma-coverage": "^0.3.1", "karma-jasmine": "^0.3.5",