464 questions
210 votes
7 answers
78k views
How to dynamically load reducers for code splitting in a Redux application?
I'm going migrate to Redux. My application consists of a lot of parts (pages, components) so I want to create many reducers. Redux examples show that I should use combineReducers() to generate one ...
91 votes
8 answers
138k views
Webpack 4 - create vendor chunk
In a webpack 3 configuration I would use the code below to create separate vendor.js chunk: entry: { client: ['./client.js'], vendor: ['babel-polyfill', 'react', 'react-dom', 'redux'], }, ...
83 votes
13 answers
87k views
How to overcome loading chunk failed with Angular lazy loaded modules
If I make changes to my angular app the chunk names will change on build and the old version will be removed from the dist folder. Once deployed, if a user is currently on the site, and then navigates ...
43 votes
4 answers
37k views
Webpack code splitting: ChunkLoadError - Loading chunk X failed, but the chunk exists
I've integrated Sentry with my website a few days ago and I noticed that sometimes users receive this error in their console: ChunkLoadError: Loading chunk <CHUNK_NAME> failed. (error: <...
30 votes
2 answers
12k views
webpack 4 - split chunks plugin for multiple entries
Using split chunks plugin with the following config : { entry: { entry1: [entry1.js], entry2: [entry2.js], entry3: [entry3.js], ... } optimization: { ...
28 votes
4 answers
3k views
How to handle deploys with Webpack code splitting?
Here's an unexpected issue I've run into with Webpack code splitting in the wild: Imagine this scenario: The user loads a React app with Webpack code splitting and a few bundle chunks are loaded A ...
25 votes
2 answers
14k views
Handle "Loading chunk failed" errors with Lazy-loading/Code-splitting
We are developing a Vue.js application based on Vue CLI 3 with Vue Router and Webpack. The routes are lazy-loaded and the chunk file names contain a hash for cache busting. In general, everything is ...
20 votes
1 answer
12k views
Dynamic import named export using Webpack
Using webpack, if I want to code-split an entire module, I can change import Module from 'module' at the top of my file to import('module').then(Module => {... when I need to use the module (...
18 votes
1 answer
7k views
What is an async chunk in webpack?
This is probably a dummy question but after reading split-chunks-plugin documentation and this article about code splitting, i still can't understand what an async chunk refers to. The split-chunks-...
17 votes
2 answers
6k views
How to split media queries under webpack config?
since we can import style sheets like below : <link rel="stylesheet" media="screen and (min-width: 900px)" href="widescreen.css"> <link rel="stylesheet" media="screen and (max-width: 600px)"...
16 votes
2 answers
16k views
Wait for CSS to load before JS in React [FOUC]
We are building our new website entirely in React and utilizing code-splitting & scss. Whenever a new page is requested it loads the raw HTML in the browser first and then a split second or so ...
14 votes
4 answers
9k views
How to get loading progress in React.lazy and Suspense
I'm using lazy to split my routes and I wanna know if there is any way I can get the loading progress in lazy and suspense. Currently I'm using it like this. const Home = lazy(() => import("./...
13 votes
3 answers
11k views
How do I disable webpack 4 code splitting?
I'm using webpack 4.43.0. How do I prevent codesplitting from happening in webpack? All these files are created - 0.bundle.js up to 11.bundle.js (alongside the expected bundle.js), when I run webpack....
12 votes
1 answer
7k views
Do nested Suspense components cause a sequential or a parallel load?
I understand that Suspense components are the React-ian approach to code splitting, which makes webpages load faster. Now, say you have a component hierarchy like this: <App> <Suspense ...
11 votes
3 answers
13k views
React.lazy and prefetching components
I have a 2 step Application Flow that looks like this: const Step1 = React.lazy(() => import('./Step1')); const Step1 = React.lazy(() => import('./Step2')); <Suspense fallback={<Loading /...