gaearon / react-transform-boilerplate

A new Webpack boilerplate with hot reloading React components, and error handling on module and component level.
Creative Commons Zero v1.0 Universal
3.36k stars 430 forks source link

Certain Imports Breaks Reloading? #95

Closed jupl closed 8 years ago

jupl commented 8 years ago

I was messing around with an app using this boilerplate and at times reload no longer works. The simplest example to reproduce is that if I clone this repo and run the app with a modified index.js:

import React from 'react';
import { render } from 'react-dom';
import { App } from './App';
import { NICE } from './colors';

render(<App />, document.getElementById('root'));
console.log(NICE);

Without this change when I change colors hot reload works, but with this change the following appears in terminal:

[HMR] The following modules couldn't be hot updated: (Full reload needed)
[HMR]  - ./src/colors.js
gaearon commented 8 years ago

Please see https://github.com/gaearon/react-transform-boilerplate/issues/120#issuecomment-192716194 for an explanation for why this happens. If import chain doesn’t end in a component, hot update will fail unless you explicitly use module.hot.accept API.