I'm getting a "cannot find main in stats" issue. I would like to have more info as to what this error is about. I follow the sever side rendering guide and my current code set up is this
const statsFile = path.resolve("./build/server/loadable-stats.json");
const extractor = new ChunkExtractor({ statsFile });
// Declare our React application.
const app = extractor.collectChunks(
<JssProvider registry={sheetsRegistry} jss={jss} generateClassName={generateClassName()}>
<MuiThemeProvider theme={theme} sheetsManager={new Map()}>
<Provider store={store}>
<StaticRouter location={request.url} context={reactRouterContext}>
<Application />
</StaticRouter>
</Provider>
</MuiThemeProvider>
</JssProvider>
);
const appString = renderToString(app);
const scriptTags = extractor.getScriptTags(); // or extractor.getScriptElements();
console.log(scriptTags);
This is the error screenshot

got it! it was const extractor = new ChunkExtractor({ statsFile, entrypoints: ["index"] });
I love happy ends 馃榿
But my suffering persists. What should these entrypoints render? Name of entry in webpack config? or what
Answering myself: yes, this is the name of your webpack entry e.g.: app like in:
entries: { app: path.resolve(__dirname, '..', 'src/index.tsx') }
Not sure if this is the right thread to ask my question, but gonna give it a try anyway:
It looks like my @loadable/webpack-plugin sometimes skips chunks. On the server side I need the ChunkExtractor({ entrypoints: ["server"] }. When I run a build the server.js chunk does not exist inside the loadable-stats.json.
That said, I tried a few things:
What I think might be wrong:
Any help is appreciated
@bramvdpluijm you should provide a complete repository example and open a new issue.
i'm a bit confused as well, is this the entry point for your server code, or the client code?
Most helpful comment
got it! it was
const extractor = new ChunkExtractor({ statsFile, entrypoints: ["index"] });