Issue 1:
Bug report

What is the current behavior?

Server should get start without any error with webpackPrefetch in dynamic import. But it is failed to start if the webpack version is >= 5.25.0 and it is working fine if webpack version <= 5.24.0.

Got below error while starting server

/Users/Documents/dev/product/build/server.js:21367
/******/ webpack_require.O(0, ["server"], () => (), 5);
^

SyntaxError: Unexpected token ')'
at wrapSafe (internal/modules/cjs/loader.js:1053:16)
at Module._compile (internal/modules/cjs/loader.js:1101:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47

If the current behavior is a bug, please provide the steps to reproduce.

Issue is because of adding webpackPrefetch in below import

import loadable from '@loadable/component';

const Component = loadable(
() =>
import(
/* webpackPrefetch: true */ /* webpackChunkName: "compChunk" */ '../component'
),
{ ssr: false }
);

What is the expected behavior?

Server should get start without any error with webpackPrefetch in dynamic import

Other relevant information:

webpack version: 5.38.0

Node.js version: 12.18.4

Operating System: Mac 10.14.6

Issue 2:
Do you want to request a feature or report a bug?

It's either a bug or the documentation is not clear.

What is the current behavior?

Trying to solve this stackoverflow question.

I use webpack.optimize.CommonsChunkPlugin twice, but only first minChunks function is applied.

If the current behavior is a bug, please provide the steps to reproduce.

Here is the example repo:

https://github.com/PavelPolyakov/webpack-react-bundles/tree/feature/advanced-CommonsChunkPlugin

What is the expected behavior?

With this code:

plugins: [
// put lodash and moment in one file
new webpack.optimize.CommonsChunkPlugin({
name: 'lodash+moment',
minChunks: function (module) {
let result = module.context && _.reduce(['lodash', 'moment'], (result, record) => result || _(module.context).includes(`node_modules/${record}`), false);
if (result) {
console.log('+++', module.context);
}
return result;
}
}),
// put everything else in the other file
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: function (module) {
let result = module.context && _(module.context).includes(`node_modules`) && !_.reduce(['lodash', 'moment'], (result, record) => result || _(module.context).includes(`node_modules/${record}`), false);
console.log('attempt', module.context);
if (result) {
console.log('---', module.context);
}
return result;
}
})
]

I want to filter lodash and moment to one file and the other node_modules to the other.

I also did another attempt, like the one from the documentation:

https://github.com/webpack/webpack/tree/master/examples/multiple-commons-chunks

Here is the attempt, it doesn't work:

https://github.com/PavelPolyakov/webpack-react-bundles/blob/feature/separate-entries/conf/webpack.production.config.js

I would appreciate any suggestion how to solve my issue. PR into the example repository is appreciated the most :)

Webpack version 2.2.1.

Regards,