Created
January 14, 2014 20:00
-
-
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?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var templates = {}; | |
templates.offices = require('./templates/offices.hbs'); | |
console.log(templates); |
Also, extra comma in the browserify call, but maybe that is copy paste to gist glitch.
@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!
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
I believe the path may be relative to the current file, or maybe to the entry point of browserify.
Does
../templates/offices.hbs
work?