browserify / watchify

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

fullPaths and duplicate react include #145

Closed dcousineau closed 9 years ago

dcousineau commented 9 years ago

I noticed some strange behavior recently and managed to shrink it down to involving pure babel, react, and watchify. Please excuse if this is a duplicate issue, I'm struggling to come up with good Google-fu so please redirect me if I'm missing something obvious.

When I have fullPaths turned on for that nice pretty watchify acceleration I get Uncaught RangeError: Maximum call stack size exceeded errors in my console. This would only happen on a reload event as opposed to an initial build. If you look at the following screenshots of some nice pretty diffs:

Above we see my only change: removing a comment.

If you notice the browserify/watchify adds a second definition for require('react'); which seemingly sends the browser into an infinite loop trying to require react by requiring react (hence the maximum call stack size exceeded).

Again this doesn't happen when I build by itself in a single pass without watchify and the problem goes away when I turn off fullPaths (but I lose the watch optimizations).

I have a gist here containing a minimalish reproduction case, just download the gist, uzip, and follow the README.

dcousineau commented 9 years ago

It looks like removing the .require() of react from the gulp file also resolves this problem. Curious as to why/how

derek-duncan commented 9 years ago

I'm having this same issue. Any ideas?

zertosh commented 9 years ago

As of 2.5.0 fullPaths is optional. But that change also reworked how the cache is fed. Can you try that version? (Tip: you're running both reactify and babelify. you don't need reactify since babel handles JSX)

dcousineau commented 9 years ago

@zertosh I have updated watchify in another project working without fullpaths and it's working flawlessly. I'm going to try the other project that originally spawned this issue when I can today and confirm it works.

zertosh commented 9 years ago

Glad it's working for you!

ajacksified commented 9 years ago

@zertosh - I'm seeing the same issues, on 3.1.0; it works with fullPaths: false, and does not work with fullPaths: true (and not having a cache kind of defeats the purpose of using watchify for me). Should I file another issue, or could you re-open this one?

zertosh commented 9 years ago

@ajacksified I'd be great if you could open a new issue with a test case I can reproduce :smile: