-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
watchify loses expose binding on update #72
Comments
Here's a temporary patch for the browserify index.js in case somebody experienced the same issue.
|
@neocoder I came across this problem as well and have found a workaround which is to add the file to the bundle with the expose option as well as requiring it. e.g. var b = watchify(bundle(watchify.args));
b.add('./foo.js', { expose: 'foo' });
b.require('./foo.js', { expose: 'foo' }); If you don't have any transforms on your code then just using the require method should suffice. That is another bug in browserify (browserify/browserify#953) |
Watchify doesn't currently play nice with these options, so for the meantime, we'll just ignore them during development. Running `gulp browserify` directly will properly require and externalize. Related watchify bugs: browserify/watchify#122 browserify/watchify#72
This is definitely happening with our builds as well. The first build will expose the bundle, and subsequent builds will not. Tested with browserify |
For now, I'm working around it by ignoring if(devMode) {
// Add watchify args and debug (sourcemaps) option
_.extend(bundleConfig, watchify.args, { debug: true })
// A watchify require/external bug that prevents proper recompiling,
// so (for now) we'll ignore these options during development
bundleConfig = _.omit(bundleConfig, ['external', 'require'])
} For reference: I tried @jkimbo's workaround, but couldn't get it working. |
@jakemhiller Is this still a problem with browseify 9.0.3 and watchify 2.6.0? More specifically with watchify 2.5.0 - FYI, after that version |
I have the same issue. I'm using npm as a build tool with:
browserify |
That's a shame I've been seeing this issue for a few months. Upgraded to browserify 9 and the issue remains. It only occurs on modules specified with via require method with an expose opt. |
@pbouzakis Can you help me out with some way to reproduce it? Like a test or repo? something? |
Yes I love to. Unfortunately I can easily repro it in my private large git repo. Tomorrow I'll try to recreate in a simple public repo I can share. Thanks @zertosh ! |
@pbouzakis If you want to ping me directly instead of publishing a public repo, my email is my user at gmail. |
@zertosh Really appreciate that. Just sent you an email. |
Can anyone who's previously run into this bug confirm if it's been fixed or still there? |
Still an issue |
Hi, I'm trying to use watchify with karma but watchify doesn't expose require after the update. After the first bundle() call everything is ok, require is exposed to the global scope, but after update - it's gone.
Here's one of watchify modified tests
The text was updated successfully, but these errors were encountered: