Adding {stripTypes: true} flag to the transform causes an error with type.js
Closed this issue · 1 comments
vincentriemer commented
Context
OS: OS X 10.9.5
gulpfile.js
var gulp = require('gulp'),
del = require('del'),
autoprefixer = require('gulp-autoprefixer'),
rename = require('gulp-rename'),
minifycss = require('gulp-minify-css'),
concat = require('gulp-concat'),
browserify = require('browserify'),
uglify = require('gulp-uglify'),
sass = require('gulp-ruby-sass'),
bower = require('gulp-bower'),
express = require('express'),
tinylr = require('tiny-lr')(),
connectlr = require('connect-livereload')
reactify = require('reactify');
gulp.task('scripts', function() {
var bundler = browserify();
return bundler
.add('./src/scripts/main.js')
.transform(reactify, {stripTypes: true})
.bundle()
.pipe(gulp.dest('dist/assets/js'))
// Minification
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest('dist/assets/js'));
});
package.json (dev-dependancies)
"devDependencies": {
"bower": "^1.3.12",
"browserify": "^6.3.2",
"connect-livereload": "^0.5.0",
"del": "^0.1.3",
"express": "^4.10.1",
"gulp": "^3.8.10",
"gulp-autoprefixer": "^1.0.1",
"gulp-bower": "0.0.7",
"gulp-concat": "^2.4.1",
"gulp-flowtype": "^0.3.0",
"gulp-minify-css": "^0.3.11",
"gulp-rename": "^1.2.0",
"gulp-ruby-sass": "^0.7.1",
"gulp-uglify": "^1.0.1",
"path": "^0.4.9",
"reactify": "^0.17.1",
"tiny-lr": "^0.1.4"
}
Resulting Error
[13:32:48] Using gulpfile ~/WebstormProjects/vinnyr-animation/gulpfile.js
[13:32:48] Starting 'scripts'...
path.js:313
throw new TypeError('Arguments to path.resolve must be strings');
^
TypeError: Arguments to path.resolve must be strings
at Object.exports.resolve (path.js:313:15)
at DestroyableTransform.saveFile [as _transform] (/Users/vincentriemer/WebstormProjects/vinnyr-animation/node_modules/gulp/node_modules/vinyl-fs/lib/dest/index.js:36:26)
at DestroyableTransform.Transform._read (/Users/vincentriemer/WebstormProjects/vinnyr-animation/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:184:10)
at DestroyableTransform.Transform._write (/Users/vincentriemer/WebstormProjects/vinnyr-animation/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:172:12)
at doWrite (/Users/vincentriemer/WebstormProjects/vinnyr-animation/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:237:10)
at writeOrBuffer (/Users/vincentriemer/WebstormProjects/vinnyr-animation/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:227:5)
at DestroyableTransform.Writable.write (/Users/vincentriemer/WebstormProjects/vinnyr-animation/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:194:11)
at Labeled.ondata (/Users/vincentriemer/WebstormProjects/vinnyr-animation/node_modules/browserify/node_modules/labeled-stream-splicer/node_modules/stream-splicer/node_modules/readable-stream/lib/_stream_readable.js:572:20)
at Labeled.emit (events.js:95:17)
at readableAddChunk (/Users/vincentriemer/WebstormProjects/vinnyr-animation/node_modules/browserify/node_modules/labeled-stream-splicer/node_modules/stream-splicer/node_modules/readable-stream/lib/_stream_readable.js:195:16)
Additional Comments
If I remove the {stripTypes: true}
from the transform statement it seems like the gulp task runs fine (except I get a different error because I have type annotations which confuses Browserify)
vincentriemer commented
Whoops, this was just my lack of gulp knowledge:
For reference here's my new gulp file which works:
gulp.task('scripts', function() {
var bundler = browserify({
entries: ['./src/scripts/main.js'],
debug: true,
});
return bundler
.bundle()
.pipe(source('main.js'))
.pipe(buffer())
.pipe(gulp.dest('dist/assets/js'))
// Minification
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest('dist/assets/js'));
});
I also defined the transform in the package.json file.