browserify / watchify

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

Problem with resolving dependencies #128

Closed erykpiast closed 9 years ago

erykpiast commented 9 years ago

I found quite interesting problem specific for watchify (browserify works OK) when I directly use some NPM package used by some other package as a dependency. For example if dependency graph looks like

app --- A
 |    /
 |   /
 |  /
  B

(sorry for lack of arrows, but I'm not ASCII art master; it's not circular dependency)

every build after initial one causes returning undefined from module A. You can check it in my repo, where I found the issue - https://github.com/erykpiast/online-css-autoprefixer/tree/f1cb86544dd1401453456e620e2687e8fecfc681. Clone it, checkout to revision f1cb865 and run npm instal && gulp after that. When you change something and trigger rebuild, you will see that module caniuse-db/data returns undefined.

dcousens commented 9 years ago

ACK this. It seems to be very prominent when mixing browserify 8.x.y and browserify 7.x.y. watchify is using browserify 7.x.y.

erykpiast commented 9 years ago

Interesting! I missed that I use not compatible versions. Shouldn't be Browserify a peerDependency of Watchify? To raise alarm in case like that etc.?

dcousens commented 9 years ago

@erykpiast I would think so. Alas, in the mean time, I just removed browserify from my ./node_modules/watchify/node_modules/ directory and moved on.

erykpiast commented 9 years ago

It's not used anyway when you call watchify function from node, as far as I understand the code. So, how removing files can help? I'm just wondering.

dcousens commented 9 years ago

I use ./node_modules/.bin/watchify/ with a few transforms.

erykpiast commented 9 years ago

Ok, it makes sense!

2015-01-30 17:01 GMT+01:00 Daniel Cousens notifications@github.com:

I use ./node_modules/.bin/watchify/ with a few transforms.

— Reply to this email directly or view it on GitHub https://github.com/substack/watchify/issues/128#issuecomment-72223330.

zertosh commented 9 years ago

You shouldn't mix versions like that. Although watchify lists browserify as a dependency (not peer dependency), watchify is usually updated shortly after browserify to reflect major version updates. If you have both watchify and browserify listed as dependencies with overlapping semver versions, then npm will dedupe browserify out of watchify.