Upgrading to Webpack 4 can be a bit tricky if you have a legacy project. I had trouble with modules being evaluated twice. Some of these modules being stateful caused the application to only work partially. Different parts of the application got a different instance of the module. This was due to the way vendor bundle was implemented (as an entry) in this project with Webpack 3.
As there was some “assembly required” with the way the vendor bundle was set up, I still needed an entry point for the vendor bundle. This would not work out-of-the-box with Webpack 4.
Below are example webpack.config.js for Webpack 3 and Webpack 4.
“runtimeChunk: ‘single'” is what makes this work. It will make Webpack to emit a single runtime bundle (runtime.bundle.js) that must be included in each page. Another change is that the bundles will be chunks afterwards, e.g. pageA.bundle.js will be pageA.chunk.js from now on.
Even with the vendor bundle, the libraries will end up in the commons chunk (note that I renamed the commons chunk from shared to commons in the configuration). This does not matter in my use case as the need for the vendor bundle is mainly to get custom setup done.