In Gulp, I am trying to compile TypeScript, combine it, and then run through Browserify to handle require (then uglify after, if in run mode).
This code example is the closest I found to what I am trying to do, however it uses a mediation file. I would rather keep things in a stream to avoid the overhead of the intermediate file, if at all possible.
Since Browserify is outputting the stream, it seems like it should know how to receive it.
Relevant Code:
var gulp = require('gulp'); var browserify = requ var concat = require('gulp-concat'); var sourcemaps = require('gulp-sourcemaps'); var transform = require('vinyl-transform'); var typeScript = require('gulp-typescript'); gulp.task('scripts', function () { return gulp.src([mySrcDir,'typings/**/*.d.ts']) .pipe(sourcemaps.init()) .pipe(typeScript(typeScriptProject)) .pipe(concat('main.js')) .pipe(transform(function (filename) { return browserify(filename).bundle(); })) .pipe(sourcemaps.write()) .pipe(gulp.dest(ns.outDir))
Result:
Error: Cannot find module 'C:\path\to\project\root\src\main.js' in 'C:\path\to\project\root'
When I omit the concatenation, the result is the same, with the exception of foobar.js instead of main.js , where foobar.ts is one of the input files.
Second attempt
gulp.task('scripts', function () { var stream = gulp.src([mySrcDir,'typings/**/*.d.ts']) .pipe(sourcemaps.init()) .pipe(typeScript(typeScriptProject)) .pipe(concat('main.js')); var bundleStream = ns.browserify(stream).bundle().on('error', errorHandler);
New mistake
C:\path\to\project\root\_stream_0.js:1 [object Object] ^ ParseError: Unexpected token
javascript typescript gulp browserify
M-pixel
source share