React: `lazy` function usage changes duration of HMR

Created on 7 Nov 2018  ·  4Comments  ·  Source: facebook/react

Do you want to request a feature or report a bug?
Bug.

What is the current behavior?
When using lazy from react HMR on one component change takes longer than without.

I'm using standard case:

import React, { Suspense, lazy } from 'react';

const Home = lazy(() => import('./routes/Home'));

const App = () => (
  <Router>
    <Suspense fallback={<div>Loading...</div>}>
      <Switch>
        <Route exact path="/" component={Home}/>
        <Route path="/about" component={About}/>
      </Switch>
    </Suspense>
  </Router>
);

What is the expected behavior?
To take the same time. I have many routes. With lazy it takes about 30 seconds when changing one component - no matter which. Without lazy about 3 seconds.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
Version 16.6.1, no matter what kind of a browser and environment.

Most helpful comment

When you say “HMR” which implementation do you mean? If you mean react-hot-loader please report the issue to that project. (It does some hacks that can break React.) We plan to look into an officially supported HMR implementation soon.

All 4 comments

When you say “HMR” which implementation do you mean? If you mean react-hot-loader please report the issue to that project. (It does some hacks that can break React.) We plan to look into an officially supported HMR implementation soon.

In any case a reproducing example is needed to help.

Closing since there's no additional info.

Was this page helpful?
0 / 5 - 0 ratings