insin / react-heatpack

A 'heatpack' command for quick React development with webpack hot reloading
MIT License
347 stars 17 forks source link

Vote against including React with react-heatpack #5

Closed KyleAMathews closed 8 years ago

KyleAMathews commented 9 years ago

It breaks hot loading if you have React also in your src node_modules directory which I'd guess would be the case for people more times than not.

I think this might stop being a problem with React 0.14.

insin commented 9 years ago

I haven't seen that - how does it break?

The configuration isn't working quite as intended, in any case. resolve.fallback is pointing at heatpack's node_modules with the intention that it would always hit the user's node_modules first for React, but it's not working like that.

Seems like that's because the loaders are hitting React first from heatpack's node_modules because resolveLoader.modulesDirectories is set to heatpack's node_modules.

If I move that config to resolveLoader.fallback instead, then it hits the user's React dep first as intended, but then using heatpack to load a component module rather than a React.render()-calling module resolves React from heatpack's node_modules AND the user's own version somehow also gets bundled!

Sorry, think I just rubber ducked you - please see the first line of this spiel :smile:

insin commented 8 years ago

Webpack's resolve.root doesn't work as I'd expect it to based on how it's documented, as require('react') from within the heatpack directory was still hitting heatpack's own node_modules even iwhen resolve.root was set to another directory with a node_modules containing React in its scope.

This should be fixed as of 3.0.0 - the webpack config now resolves the full path to a local version of React/ReactDOM and creates aliases for heatpack's entry module to use.