question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Chunk disappears on hot module reload

See original GitHub issue

The universal-component works fine initially, loading the chunk on route change, but whenever I update the lazy-loaded component (“Home.js”), it just disappears. universal-component doesn’t report any errors, and Webpack just tells me App and Home has been updated and everything is fine. Am I missing something in my config, or do you have any suggestions as to why it’s happening?

.babelrc

{
	"presets": [["env", { "modules": false }], "react", "stage-2"],
	"plugins": ["react-hot-loader/babel"]
}

index.js

import React from "react";
import { render } from "react-dom";
import { BrowserRouter } from "react-router-dom";
import { AppContainer } from "react-hot-loader";

import "./styles/App.scss";
import App from "./components/App";

const renderApp = Component => {
  render(
    <AppContainer>
      <BrowserRouter>
        <Component />
      </BrowserRouter>
    </AppContainer>,
    document.getElementById("root")
  );
};

renderApp(App);

if (module.hot) {
  module.hot.accept(["./components/App"], () => {
    renderApp(App);
  });
}

App.js

import React, { Component } from "react";
import { Route } from "react-router-dom";
import universal from "react-universal-component";

// Sync components
import TopBar from "./shared/TopBar";

// Async components
const Home = universal(props =>
  import(/* webpackChunkName: 'home' */ "./Home.js"), {
    chunkName: "home"
  }
);

class App extends Component {
  render() {
    return (
      <div id="App">
       <TopBar />
        <main>
          <Route path="/test" component={Home} />
        </main>
      </div>
    );
  }
}

export default App;

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
olslashcommented, Nov 15, 2017

this happened to me until i added babel-plugin-universal-import to my build. kind of hidden in the middle of the readme, if you ask me 😛

0reactions
faceyspaceycommented, Sep 22, 2017

Doin a little cleanup. I’m going to close this. Feel free to re-open or continue the conversation if you discover any more relevant info.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to solve ChunkLoadError: Loading hot update chunk ...
js . It doesn't hot reload, I've to manually reload to get changes. I've set up a webpack-dev-server. Error ...
Read more >
Webpack's Hot Module Replacement Feature Explained
After all, reloading means losing whatever process you're making on the UI: Any modal or dialog box you're working on will be gone....
Read more >
Module Federation, Hot Prod Reloading, SSR & Next.js, for ...
First, I need to intercept the loadable manifest since next/dynamic uses it to look up an async chunk reference. If it is a...
Read more >
Webpack 4 Tutorial 15: Webpack hot reloading - YouTube
Let us learn about webpack's hot reloadingSpecial discount for subscribers: Purchase full course at $9.99 - http://bit.ly/webpack4 ...
Read more >
Hot Module Replacement - webpack
js', // Dev server client for web socket transport, hot and live reload logic 'webpack-dev-server/client/index.js?hot=true&live-reload=true', // Your entry './ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found