old_contents: var gulp = require('gulp');
  
  var requirejs = require('requirejs');
  var typescript = require('./typescript');
  var del = require('del');
  
  var merge = require('merge2');
  
  exports.optimize = function(packageName, source, target, done) {
  	var sourceStream = gulp.src([
  		'./typings/tsd.d.ts',
  		'./' + source + '/**/*.ts',
  	]);
  	
  	var result = typescript.compile(sourceStream, true);
  
  	var out = merge([
  		result.js.pipe(gulp.dest('bin')),
  		result.dts.pipe(gulp.dest('./' + target)),
  	]);
  	out.on('end', function() {
  		requirejs.optimize({
  		    baseUrl: 'bin',
  		    name: packageName,
  		    out: target + '/' + packageName + '.js',
  		}, function(buildResponse) {
  			console.log(buildResponse);
  		}, function(err) {
  			console.log(err);
  		});
  		
  		del('bin', done);
  	});
  	
  	return out;
  };
  
new_contents: var runSequence = require('run-sequence');
  
  var typescript = require('./typescript');
  var del = require('del');
  
  var merge = require('merge2');
  
  exports.config = function (gulp, packageName, source, target) {
  	gulp.task('compile.release.bin', function () {
  		var sourceStream = gulp.src([
  			'./typings/tsd.d.ts',
  			'./' + source + '/**/*.ts',
  		]);
  
  		var result = typescript.compile(sourceStream, true);
  
  		return merge([
  			result.js.pipe(gulp.dest('bin')),
  			result.dts.pipe(gulp.dest('./' + target)),
  		]);
  	});
  
  	gulp.task('compile.release.optimize', function (done) {
  		requirejs.optimize({
  			baseUrl: 'bin',
  			name: packageName,
  			out: target + '/' + packageName + '.js',
  		}, function (buildResponse) {
  			console.log(buildResponse);
  			done();
  		}, function (err) {
  			console.log(err);
  			done();
  		});
  	});
  
  	gulp.task('compile.release.clean', function (done) {
  		del('bin', done);
  	});
  }
subject: Modify requirejs module to configure subtasks instead of providing a function. This lets us run tasks in sequence to get ordering of steps.