catamphetamine / universal-webpack

Isomorphic Webpack: both on client and server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using dynamic imports causes the output filename to be the first encounted chunk name when generating server bundle

kungfutse opened this issue · comments

This happens at least in the following scenario:
Using custom renderer with react-loadable, the generated output filename is picked from one the splitted chunks when webpack encounters first dynamic import from loadable component defined in react-router.

Fix for this is to use the defined output filename (output_file_name + 'js') instead of relying on the [name] here:

configuration.output.filename = '[name].js'

and here:
configuration.output.chunkFilename = '[name].js'

@kungfutse Thanks.
Actually I didn't understand anything from your comment because I haven't worked with react-loadable and "dynamic imports" using this library yet.
I am planning to practice that by adding something like react-loadable and "dynamic imports" to the example project in some future.
Until then I'm leaving this issue open so that others could know about it.

Just to echo that I am also experiencing this same issue, and have had to do a slightly hacky override of the generated config to fix.

@KITSMalinnaLeach
Seems that @kungfutse replaced [name] with ${output_file_name} in two places.
And what was your approach?

Before releasing a fix it would have to be tested.
I currently don't have a simple project with "dynamic" imports for testing so I haven't released any fix so far.