It would help to see a bit more code than this snippet, since the problem is most likely in one of the 2 scripts you try to load with loadable(), and based on the message an education guess would be that you have an array or object called stats and use a key x which isnāt set properly.
As far as I can see you do everything correct, however Iām not an expert
And I tried to run it locally, but obviously failed without access to your (local) api.
However I did notice the same error on Google, which is related to the chunkNames created by Webpack. As far as I could understand it the problem was caused by having additional - in file or directory names which can mess up Webpack (although I didnāt notice any direct problems when building your project).
In my own project I have something like this, which is basically identical to what you have, and it works without any problems.
// theme/index.js
import { connect, Head, loadable } from "frontity";
import Switch from "@frontity/components/switch";
const Loading = loadable(() => import('./loading'));
const PageError = loadable(() => import('./page-error'));
// more components, both direct and through loadable
const Theme = ({ state }) => {
// Get information about the current URL.
const data = state.source.get(state.router.link);
return (
<>
{/* ... */}
<Switch>
{/* ... */}
<Loading when={data.isFetching} />
<PageError when={data.isError} />
</Switch>
{/* ... */}
</>
);
};
export default connect(Theme);
Detailing the info suggested here when having issues will help the community to provide the best possible help as quickly and as efficiently as possible.
Your Github repository should work directly in codeSandbox using this link: https://codesandbox.io/s/github/Sani-admin/test
Can you specify the errors youāre getting and prepare the repository to throw just the error reported in this thread?
In the meantime, here you have the documentation for Code Splitting with Frontity
In this case Frontity is just centralizing the use of the Loadable Components library
so have a look at their docs to learn more about how to use this library in specific use cases
It seems this issue has already been reported in their repository: