Using watch option forces --full-path on browserify
berniegp opened this issue · comments
When using the watch option, grunt-browserify forces the --full-path
option on browserify. This causes unwanted absolute system paths in the resulting build. Also, see #245.
This used to be required but isn't anymore since version 2.5.0 (browserify/watchify#78)
Offending code (runner.js) :
// Watchify requires specific arguments
if(options.watch) {
bOpts = _.extend({ cache: {}, packageCache: {}, fullPaths: true }, bOpts);
}
From the watchify doc:
var w = watchify(b, opts)
Wrap a browserify bundle b with watchify, returning the wrapped bundle instance as w.
When creating the browserify instance b you MUST set these properties in the constructor:
var b = browserify({ cache: {}, packageCache: {} });
var w = watchify(b);
It seems safe to remove fullPaths: true
now.
Sure thing! This was my first pull request on github so I have a question you might be able to answer: do people usually create both an issue and a pull request when they have the fix or just a pull request?
It depends...
You can always create a PR without any links to any issue, if you discovered something and have the knowledge of changing/resolving it.
People creates issues to discuss about potential bugs or needs, but also sometimes to confirm bugs before working on them
Thanks for clearing that up!
Breaks watching for me on OS X running node 12.7 and on OS X node 4. Reinstating fullPaths works. Running watchify@3.4.0
The worst thing is it breaks silently.
Might be an issue with watchify upstream then? Because fullPaths is now optional.
Yes @tleunen @berniegp It could be a problem with watchify or even my particular use case. I reverted to 4.0.0 and it resolved the issue for me i.e it has fullpaths: true.
dev:
files: 'app/tmp/app.js': ['src/bootstrap.coffee']
options:
transform: ['coffeeify' ]
watch: true
browserifyOptions:
extensions: ['.coffee']
debug: true
I don't have time to investigate it at the moment. I just commented on this ticket for anyone that has the same problem whereby watching mysteriously stops working after npm install. cause its bumped a minor version.
I would say when browserify emits the non-fullpaths to watchify and watchify passes those to chokidar it can't find the file to watch because it doesnt have the full path. It might have something to do with the fact that I use a single entry point i.e bootstrap.coffee and let browserify follow the requires.
When I have time I will investigate fully and report back.
Again reverting to 4.0.0 resolves this problem.
I also use a single entry point in my working setup. However, I don't use coffee so maybe there's something there?