Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: option to use nodejs streams #23

Closed
matthewjh opened this issue Aug 29, 2015 · 3 comments
Closed

Feature: option to use nodejs streams #23

matthewjh opened this issue Aug 29, 2015 · 3 comments
Milestone

Comments

@matthewjh
Copy link

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:

gulp.src('build/index.d.ts')
.pipe(dts.bundle({
      name: 'cool-project',
      stream: true
  }))
.pipe(gulp.dest('dist/lib.d.ts'));

@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.

@matthewjh
Copy link
Author

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.

@heruan
Copy link

heruan commented Dec 21, 2015

Gulp/streams support would be awesome 👍

@tolemac
Copy link
Contributor

tolemac commented Jan 11, 2016

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.

@tolemac tolemac added this to the Backlog milestone Jan 13, 2016
@tolemac tolemac closed this as completed Jun 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants