faceyspacey / react-universal-component

🚀 The final answer to a React Universal Component: simultaneous SSR + Code Splitting
MIT License
1.7k stars 80 forks source link

empty arrays from flushChunkNames/flushModuleIds #163

Closed wmertens closed 5 years ago

wmertens commented 5 years ago

I'm trying to make chunk flushing working and I'm failing at the 'gathering chunknames' stage.

As far as I understand it, the babel plugin adds information about the required chunk to every import() call. Then, when React adds the universal components to the tree, their chunknames are added to a Set. Finally, after the render you ask for the added chunknames and translate them to webpack files with webpack-flush-chunks.

I added log statements to requireUniversalModule and it seems like getConfig can't get the path etc.

I wrap RUC so it always uses my Loading component etc. Would that cause it? Here's an example of what the Babel plugin creates:

const Field = Object(react["b" /* makeSplitPoint */])(() => universalImport_default()({
  id: "redux-form/es/Field",
  load: () => Promise.all([__webpack_require__.e(/* import() | redux-form-es-Field */ 41).then(__webpack_require__.bind(null, 650))]).then(proms => proms[0]),
  path: () => external_path_default.a.join(__dirname, 'redux-form/es/Field'),
  resolve: () => /*require.resolve*/(650),
  chunkName: () => "redux-form-es-Field"
}));

makeSplitPoint is the name of my wrapper.

ScriptedAlchemy commented 5 years ago

Make sure you run flush chunks after rendering the app on the server. Also try turning off or on the ignore Babel rename option.

Check the docs again about it