Skip to content

Commit

Permalink
feat(bundles): publish UMD bundles
Browse files Browse the repository at this point in the history
Closes #5223
  • Loading branch information
pkozlowski-opensource authored and vsavkin committed Nov 25, 2015
1 parent 5a27ffb commit fa725b4
Show file tree
Hide file tree
Showing 4 changed files with 882 additions and 3 deletions.
56 changes: 53 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ var sourcemaps = require('gulp-sourcemaps');
var tsc = require('gulp-typescript');
var util = require('./tools/build/util');
var bundler = require('./tools/build/bundle');
var rename = require('gulp-rename');
var replace = require('gulp-replace');
var insert = require('gulp-insert');
var buildRouter = require('./modules/angular1_router/build');
Expand Down Expand Up @@ -1010,6 +1011,55 @@ gulp.task('!bundle.js.sfx.dev', ['build.js.dev'], function() {
});
});

gulp.task('!bundles.js.umd', ['build.js.dev'], function() {
var webpack = q.denodeify(require('webpack'));

function resolveOptions(devOrProd) {
return {
root: __dirname + '/dist/js/' + devOrProd + '/es5',
packageAlias: '' // this option is added to ignore "broken" package.json in our dist folder
};
}

function outputOptions(outFileName, devOrProd) {
return {
filename:
'dist/js/bundle/' + outFileName + '.umd' + (devOrProd === 'dev' ? '.dev' : '') + '.js',
library: 'ng',
libraryTarget: 'umd'
};
}

function webPackConf(entryPoints, outFileName, devOrProd) {
return {
entry: entryPoints,
resolve: resolveOptions(devOrProd),
output: outputOptions(outFileName, devOrProd)
};
}

return q.all([
webpack(webPackConf(['angular2/angular2.js'], 'angular2', 'dev')),
webpack(webPackConf(['angular2/angular2.js'], 'angular2', 'prod')),
webpack(webPackConf(['angular2/angular2.js', 'angular2/http.js', 'angular2/router.js'],
'angular2_all', 'dev')),
webpack(webPackConf(['angular2/angular2.js', 'angular2/http.js', 'angular2/router.js'],
'angular2_all', 'prod'))
]);
});

gulp.task('bundles.js.umd.min', ['!bundles.js.umd', '!bundle.external.deps'], function() {
// minify production bundles
return gulp.src([
'dist/js/bundle/external-dependencies.js',
'dist/js/bundle/angular2.umd.js',
'dist/js/bundle/angular2_all.umd.js'
])
.pipe(uglify())
.pipe(rename({extname: '.min.js'}))
.pipe(gulp.dest('dist/js/bundle'));
});

gulp.task('!bundle.js.prod.deps', ['!bundle.js.prod'], function() {
return merge2(addDevDependencies('angular2.js'),
bundler.modify(['dist/build/http.js'], 'http.js'),
Expand All @@ -1025,9 +1075,8 @@ gulp.task('!bundle.js.min.deps', ['!bundle.js.min'], function() {
.pipe(gulp.dest('dist/js/bundle'));
});

gulp.task('!bundle.external.deps', ['clean'], function() {
return addDevDependencies('external-dependencies.js');
});
gulp.task('!bundle.external.deps', ['clean'],
function() { return addDevDependencies('external-dependencies.js'); });

var JS_DEV_DEPS = [
licenseWrap('node_modules/zone.js/LICENSE', true),
Expand Down Expand Up @@ -1091,6 +1140,7 @@ gulp.task('bundles.js',
'!bundle.js.min.deps',
'!bundle.web_worker.js.dev.deps',
'!bundle.js.sfx.dev.deps',
'bundles.js.umd.min',
'!bundle.testing',
'!bundle.external.deps'
],
Expand Down
Loading

0 comments on commit fa725b4

Please sign in to comment.