I am using react-loadable
to split my code. I have opted to do this at route level to begin with. My routes.js
looks like this:
import React from 'react';
import { Route, Switch } from 'react-router-dom';
import Loadable from 'react-loadable';
const Loading = props => {
if (props.error) {
return <div>Error loading page!</div>;
} else {
return null;
}
};
const AsyncHomepage = Loadable({ loader: () => import('../Scenes/Homepage/Homepage' /* webpackChunkName: "homepage" */), loading: Loading });
const AsyncSearchPage = Loadable({ loader: () => import('../Scenes/Search/Search' /* webpackChunkName: "search" */), loading: Loading });
const AsyncAboutUsPage = Loadable({ loader: () => import('../Scenes/AboutUs/AboutUs' /* webpackChunkName: "aboutus" */), loading: Loading });
// omitted for brevity
export const Routes = () => {
return (
<Switch>
<Route exact path="/" component={AsyncHomepage} />
<Route exact path="/search" component={AsyncSearchPage} />
<Route exact path="/about-us" component={AsyncAboutUsPage} />
// omitted for brevity
</Switch>
);
};
This is the only place I'm using react-loadable
.
When I build the application, I get my named chunks as expected but I also get a bunch of random numbered chunks as well:
These other chunks seem to contain things like moment.js
, react-select
, there's another that contains react-dom
which surely would just be included in every page?
What I'd like to know is why is this happening and how can I name these chunks or merge them with the page chunks?