browserify / watchify

watch mode for browserify builds
Other
1.79k stars 181 forks source link

Watchify is breaking .require() calls with the expose option #74

Closed binarykitchen closed 9 years ago

binarykitchen commented 10 years ago

When the bundler is an instance of browserify, then this code works fine:

    var bundler = browserify({
            entries:        ['main.js],
            insertGlobals:  false,
            debug:          !settings.PRODUCTION // for source maps
        })

    bundler.require('/home/xxx/var/local/tmp/client_settings.json', {
        expose: 'client_settings.json'
    })

but when I wrap this with watchify like that:

    var bundler = watchify(browserify({
            entries:        ['main.js'],
            insertGlobals:  false,
            debug:          !settings.PRODUCTION // for source maps
        }), {
            watch: false
        })

    bundler.require('/home/xxx/var/local/tmp/client_settings.json', {
        expose: 'client_settings.json'
    })

then this error is thrown when bundling through a gulp task

TypeError: Cannot set property 'client_settings.json' of undefined
    at Browserify.<anonymous> (/home/xxx/node_modules/watchify/index.js:20:27)
    at Browserify.emit (events.js:95:17)
    at Transform._transform (/home/xxx/node_modules/browserify/index.js:475:14)
    at Transform._read (/home/xxx/node_modules/browserify/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:184:10)
...
neocoder commented 10 years ago

Hi @binarykitchen, not sure if it will help in your situation but you can try to apply the patch I made to solve my problem https://github.com/substack/watchify/issues/72#issuecomment-50747549

binarykitchen commented 10 years ago

thanks @neocoder - I prefer to wait until the patch is in on npm

Pita commented 10 years ago

I see this too!

Pita commented 10 years ago

This seems to be related to #72

nervo commented 9 years ago

Same kind of issue there

zertosh commented 9 years ago

I think this is related to https://github.com/substack/watchify/issues/72. I'm going to close this out and follow it there.