Since version 0.21, my webpack.config.js doesn't compile anymore.
I've got this error :
Argument 2 to createSharedEntry() must be a single string file: not an array of files.
Here is my config :
.createSharedEntry('vendor', [
'./assets/node_modules/jquery/dist/jquery.min.js',
'./assets/node_modules/@fancyapps/fancybox/dist/jquery.fancybox.min.js',
'./assets/bundles/core/js/display_alert.js',
])
I didn't find any information about this change in the release notes and had to rollback webpack-encore to 0.20.1.
It's an undocumented breaking change in a minor release, which is never ideal, but all you have to do to resolve this is create a shared entry file that require()s every package in your old array.
@weaverryan was there a requirement to drop this feature in the new implementation of the shared entry, or was the array support only forgotten when doing it ?
Hey @Phoennix!
Ah, you're right! A few things:
A) This was a change that I missed in the CHANGELOG - you're right! I've just fixed that in sha: ba996469f04f253e6467a5924e043ccd670f067d
B) This was done on purpose. Due to changes in Webpack 4, it was no longer possible to allow an array to be passed to this.
As @rakelley, the fix is to only set this to one file, then require all the other modules from that file. For example:
- .createSharedEntry(['./foo', './bar']);
+ .createSharedEntry('vendor', './shared_entry');
// shared_entry.js
require('./foo');
require('./bar');
I hope that helps!
Thank you @rakelley and @weaverryan .
@weaverryan , I just had to create the shared entry this way to compile without error :
.createSharedEntry('vendor', './webpack.shared_entry.js')
Perfect - I had a typo in my code - fixed now!
This method still requires 2 arguments. Webpack throw an error if you just have 1 arg 馃槈
When I follow these instructions, I'm getting
Error: Invalid number of files for chunk vendor - got
Using
.createSharedEntry('vendor', './webpack.shared.js')
For simplicity, just one file
// webpack.shared.js
require('moment');
Most helpful comment
Hey @Phoennix!
Ah, you're right! A few things:
A) This was a change that I missed in the CHANGELOG - you're right! I've just fixed that in sha: ba996469f04f253e6467a5924e043ccd670f067d
B) This was done on purpose. Due to changes in Webpack 4, it was no longer possible to allow an array to be passed to this.
As @rakelley, the fix is to only set this to one file, then require all the other modules from that file. For example:
I hope that helps!