Closed matthewjh closed 8 years ago
If it turns out that implementing streams is going to be too much work, IMO it would still be very useful to be able to pass a callback to the bundle
function.
Gulp/streams support would be awesome :+1:
I think this enhancement is a "nice to have" but not necessary. Gulp plugins are nice when you have to do something with a set of files that they are piped by one and another processes. In this case, dts-bundle take a file as origin and one destination file, I don't see others uses where works with streams are needed. Let me know if you find cases where it's necessary.
I'm using dts-bundle
with gulp this way:
var gulp = require('gulp');
var ts = require('gulp-typescript');
var merge = require('merge2');
var concat = require('gulp-concat');
var sourcemaps = require('gulp-sourcemaps');
var runSequence = require('run-sequence');
var del = require('del');
var dtsBundle = require('dts-bundle');
var tsProject = ts.createProject('tsconfig.json');
gulp.task('compile', function() {
var tsResult = tsProject.src() // instead of gulp.src(...)
.pipe(ts(tsProject));
return merge([
tsResult.dts.pipe(gulp.dest('dist/dts')),
tsResult.js.pipe(gulp.dest('dist/js'))
]);
});
gulp.task('bundle', function() {
var es5 = gulp.src('dist/js/src/**/*.js')
.pipe(sourcemaps.init())
.pipe(concat('Ng2Emulation-es5.js'))
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist/release'));
return es5;
});
gulp.task('clean', function(){
del([
'./dist'
]);
});
gulp.task('definition-bundle', function(){
dtsBundle.bundle({
name: 'Ng2Emulation',
main: 'dist/dts/src/Ng2Emulation.d.ts',
out: "dist/release/Ng2Emulation.d.ts",
exclude: /.*typings.*/,
verbose: true
});
});
gulp.task('build', function(done) {
runSequence('clean', 'compile', 'bundle', 'definition-bundle', done);
});
I have definition-bundle
task as isolate task, not integrate with the compile process. This way I don't need to use streams. I only need that dts-bundle
works with others processes.
Any way, I think this will be a "nice to have" enhacement, of course, but not necessary.
Thanks for developing this. Finding it extremely useful in a project for untangling the madness that is the process of bundling a TypeScript lib for node with generated d.ts files.
One thing that would make things easier for integrating dts-bundle into build scripts is an option to use node streams:
@Bartvds Is this a good idea? Would it be a pain to implement (I haven't taken a look at how dts-bundle is implemented)? I'm happy to take a stab at it.