Skip to content

Instantly share code, notes, and snippets.

@spikebrehm
Created January 14, 2014 20:00
Show Gist options
  • Save spikebrehm/8424636 to your computer and use it in GitHub Desktop.
Save spikebrehm/8424636 to your computer and use it in GitHub Desktop.
Why is hbsfy not working? Where the heck does this error come from?
var gulp = require('gulp')
, browserify = require('gulp-browserify')
;
gulp.task('scripts', function() {
return gulp.src('./js/sample.js')
.pipe(browserify({
debug: true,
transform: ['hbsfy'],
}))
.pipe(gulp.dest('./build/'));
});
gulp.task('default', function() {
gulp.run('scripts');
gulp.watch('./js/**/*.js', function() {
gulp.run('scripts');
});
});
$ gulp
[gulp] Using file /Users/spike/code/onechrome/gulpfile.js
[gulp] Working directory changed to /Users/spike/code/onechrome
[gulp] Running 'default'...
[gulp] Running 'scripts'...
[gulp] Finished 'default' in 10 ms
/Users/spike/code/onechrome/js/sample.js
stream.js:94
throw er; // Unhandled stream error in pipe.
^
SyntaxError: Unexpected identifier
var templates = {};
templates.offices = require('./templates/offices.hbs');
console.log(templates);
@alanpeabody
Copy link

I believe the path may be relative to the current file, or maybe to the entry point of browserify.

Does ../templates/offices.hbs work?

@alanpeabody
Copy link

Also, extra comma in the browserify call, but maybe that is copy paste to gist glitch.

@spikebrehm
Copy link
Author

@alanpeabody thanks for the suggestions. If I make the require relative to the entry point, I actually get a useful stacktrace:

stream.js:94
      throw er; // Unhandled stream error in pipe.
            ^
Error: module "../templates/offices.hbs" not found from "/Users/spike/code/onechrome/js/fake_f7a86baa.js"
    at /Users/spike/code/onechrome/node_modules/gulp-browserify/node_modules/browserify/index.js:570:23
    at /Users/spike/code/onechrome/node_modules/gulp-browserify/node_modules/browserify/node_modules/browser-resolve/index.js:183:24
    at /Users/spike/code/onechrome/node_modules/gulp-browserify/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:36:22

I wish Gulp didn't swallow the error and provided a better backtrace!

@alanpeabody
Copy link

Yeah, I am sure as it matures error handling will improve.

Here is an early snapshot that I had working: https://gist.github.com/alanpeabody/7021d903961a3c9eab6e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment