Webpack 4 with React Loadable does not split the vendor bundle based on chunking points

At the moment, I am utilizing webpack 4 along with react loadable to generate chunks. Interestingly, the chunks are dependent on the breakpoint. However, the size of the vendor remains constant. Could it be possible that React loadable does not yet support webpack 4 or have I overlooked some configuration?

The CSS appears to be split into chunks as well.

{
  output: {
    path: 'tothe path',
    publicPath: `/publicPath/`,
    filename: '[name] + '.js',
    chunkFilename: '[name]',
  },
  resolve: {
    extensions: ['.js', '.json', '.css'],
    alias: aliases
  },

  stats: {
    warnings: false,
    children: false,
  },

  optimization: {

    splitChunks: {
      chunks: "all",
      name: true,
      cacheGroups: {
        common: {
          name: "vendor" + ".js",
          test: /[\\/]node_modules[\\/]/,
          chunks: "all",
          enforce: true,
          reuseExistingChunk: false,
        },
      }
    }
  }
}

Answer №1

React-loadable may encounter some challenges with Webpack 4 at the moment, check out this pull request for more information.

You can also explore a fork of react-loadable created by the PR author, but keep in mind that it didn't resolve the loading issue I faced with certain components wrapped in Loadable.

Answer №2

@Bohdan Another issue that I encountered was related to the components not being able to load all imported styles. After removing the style, the component started functioning properly.

To solve this issue, I had to move all the styles to the entry file as a temporary workaround.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Crafting redirect rules in React that avoid redirecting to the same route

In my project, there is a file named AuthenticatedRoute.tsx, which serves as a template for all the protected/authenticated routes in my Router.tsx file. export default ({ component: C, authUser: A, path: P, exact: E }: { component, authUser, path, ex ...

The ultimate guide to storing and retrieving images in a MySQL database with the help of Spring REST and ReactJS

Looking for assistance in developing an application that utilizes React and Spring REST to save and retrieve images from a MySQL database ...

Incorporating a newline character into a React state string

I am currently developing a next JS application and utilizing react states within it. My goal is to incorporate a line break in a string value of the state. I have experimented with several methods like the ones below, but none seem to be effective: setS ...

The conversion to ObjectId encountered an error when trying to process the value within the model's path

Check out my Profile Schema: const mongoose = require('mongoose'); const ProfileSchema = new mongoose.Schema({ user: { // Special field type because // it will be associated to different user type: mongoose.Schema.Typ ...

The value in my Reactjs application seems to only update after I refresh the page, but not consistently

const availableFunc = (id) => { if (Active.length > 0) { let available = Active.filter((obj) => obj.type === id).map((obj) => obj.available !== undefined ? obj.available : "" ); return available[0]; } }; All the ...

Leveraging NextJS and React's Context API by incorporating a layout component wrapper

My current setup is as follows: I have a layout component where I include a navigation component and children. I enclose them within my Provider like this AppLayout.js <Layout> <Navigation/> <main> {children} </main> < ...

What methods can be used to stop events in a resource timeline from overlapping?

I am facing an issue with the calendar display when dealing with events that have weekly intervals. The problem occurs when the slot duration is also weekly and doesn't align perfectly, resulting in a "zig-zag" pattern in the calendar: https://i.stac ...

Tips for adding styles to MUI MenuList using styled components

I have a requirement to change the background-color of the MenuItem component when its selected prop is set to true. In addition, I want to add a style to the MenuItem component when it is hovered over. How can I achieve this? import * as React from " ...

A step-by-step guide on how to use code to verify a Material-UI check-box

Currently, I have integrated Material-UI's Checkbox component into my application along with a corresponding label. I am looking to make both the checkbox and the label clickable. However, I am unable to utilize their FormControlLabel component (feat ...

What is the best way to access a component generated using the .map() function from a separate component?

My objective is to create a grid of toggle buttons that store their selected values in an array. This array will then be used to display another row of buttons based on the selections. Once a button in the new row is chosen, it should deselect the corresp ...

How a Dynamic Icon Component in NextJS/React can disrupt Jest testing

Hello there! I'm a new member of this community, and usually I can find answers to my questions by searching. However, this time around, I need some help. My Current Setup I am using NextJS solely as a framework application without utilizing its API ...

Using hooks is restricted to the confines of a function component. An error will occur if they are called outside of this scope: "

How can I integrate a shopping cart feature into my app? I've created a separate file with the necessary functions, but I keep encountering an error related to invalid hook calls. export function CartProvider(props) { const [items, setItems] = u ...

Tips for obtaining cookies within Nextjs api routes

I'm currently working on developing a note-taking application using Next.Js and MongoDB. The login system I have set up allows users to register for an account and login to start creating notes. To handle authentication, JWT is being utilized. Once a ...

Invoke an ActionCreator within a different ActionCreator

Calling an ActionCreator from another file is proving to be a challenge... The products.ts file contains the ActionCreators and Reducers for Products... import { setStock } from './Store.ts'; //.... export const addProduct = (product: IProduct) ...

Tips for concealing validation errors in React Js when modifying the input field

I have recently started working with ReactJs, and I've implemented form validation using react-hook-form. After submitting the form, the errors are displayed correctly. However, the issue arises when I try to update the input fields as the error messa ...

Having trouble adding a package right after creating a project with create-react-app

Just started learning react (only a day ago). Used create-react-app command line to set up an app. Here's what I did: create-react-app my-app npm start App was running smoothly at this point. Then, I proceeded with: npm install youtube-api-search n ...

Addressing memory leaks in React server-side rendering and Node.js with setInterval

Currently in my all-encompassing react application, there's a react element that has setInterval within componentWillMount and clearInterval inside componentWillUnmount. Luckily, componentWillUnmount is not invoked on the server. componentWillMount( ...

The call in Cors TypeScript does not have any matching overload

I'm looking to develop an API using Express with TypeScript, however I'm encountering an error when trying to implement cors: No overload matches this call. The last overload gave the following error. Argument of type 'RequestHandler<any ...

Create a JavaScript button that redirects to a different page within a React application

I am creating a div element using a for-loop and I want to link each div to the "/campaign" page with its respective id. When a div is clicked, I want it to navigate to the "/campaign/id" page and pass the id to the Campaign component. class Home extends ...

Is there a way to limit MuiPhoneNumber to only accept one specific country code?

Is there a way to limit the selection to just one country code, preventing users from choosing other countries? <MuiPhoneNumber fullWidth label="Phone Number" data-cy="user-phone" defaultCountry={"us" ...