From b5107cdaf1cf228dbcb8160542a87b61a78fc866 Mon Sep 17 00:00:00 2001 From: Josh Thomas Date: Wed, 8 Jun 2016 20:56:18 -0500 Subject: [PATCH] chore(build): create es2015 modules when publishing --- gulpfile.js | 22 +++++++++++++++++++--- package.json | 7 +++++-- scripts/npm/package.json | 2 ++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index a8ffe254f9..6175061654 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -57,7 +57,8 @@ var tscReporter = { // See: https://github.com/Microsoft/TypeScript/issues/4801 // and https://github.com/ivogabe/gulp-typescript/issues/211 var babelOptions = { - modules: 'system', + presets: ['es2015'], + plugins: ['transform-es2015-modules-systemjs'], moduleIds: true, getModuleId: function(name) { return 'ionic-angular/' + name; @@ -258,6 +259,21 @@ function tsCompile(options, cacheName){ .pipe(tsc(options, undefined, tscReporter)); } +gulp.task('bundle.es6', function() { + var babel = require('gulp-babel'); + + gulp.src([ + 'src/components/slides/swiper-widget.js' + ]) + .pipe(gulp.dest('dist/esm/components/slides')); + + return tsCompile(getTscOptions('es6'), 'bundle.es6') + .pipe(babel({ + presets: ['es2015-native-modules'] + })) + .pipe(gulp.dest('dist/esm')); +}); + /** * Compiles Ionic Sass sources to stylesheets and outputs them to dist/bundles. */ @@ -720,7 +736,7 @@ gulp.task('karma', ['tests'], function(done) { gulp.task('karma-watch', ['watch.tests', 'bundle.system'], function() { watchTask('bundle.system'); var karma = require('karma').server; - return karma.start({ configFile: __dirname + '/scripts/karma/karma-watch.conf.js' }) + return karma.start({ configFile: __dirname + '/scripts/karma/karma-watch.conf.js'}) }); @@ -938,7 +954,7 @@ gulp.task('build.release', function(done){ runSequence( 'clean', 'copy.libs', - ['bundle', 'sass', 'fonts', 'copy.scss'], + ['bundle', 'bundle.es6', 'sass', 'fonts', 'copy.scss'], done ); }); diff --git a/package.json b/package.json index 7cedaffb70..8aac04698f 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,9 @@ "zone.js": "^0.6.12" }, "devDependencies": { + "babel-plugin-transform-es2015-modules-systemjs": "^6.9.0", + "babel-preset-es2015": "^6.9.0", + "babel-preset-es2015-native-modules": "^6.6.0", "canonical-path": "0.0.2", "connect": "^3.3.4", "conventional-changelog": "^0.5.3", @@ -45,7 +48,7 @@ "glob": "^5.0.14", "gulp": "~3.8.10", "gulp-autoprefixer": "^2.3.0", - "gulp-babel": "^5.3.0", + "gulp-babel": "^6.1.2", "gulp-cached": "^1.1.0", "gulp-concat": "~2.5.0", "gulp-connect": "^2.2.0", @@ -99,4 +102,4 @@ "path": "node_modules/ionic-cz-conventional-changelog" } } -} \ No newline at end of file +} diff --git a/scripts/npm/package.json b/scripts/npm/package.json index 057ad8a5f6..ec05793165 100644 --- a/scripts/npm/package.json +++ b/scripts/npm/package.json @@ -4,6 +4,8 @@ "description": "An advanced HTML5 mobile app framework built on Angular2", "license": "MIT", "keywords": ["ionic", "framework", "mobile", "app", "hybrid", "webapp", "cordova"], + "main": "index.js", + "jsnext:main": "esm/index.js", "repository": { "type": "git", "url": "https://github.com/driftyco/ionic.git#2.0`"