It seems that with this plugin, the order of my files is not preserved as I specify them in filesToConcat. This used to work with the old webpack4 plugin. The files in the final bundle appear to be ordered alphabetically (backbone, bootstrap, clusterize, countUp, etc...).
This is a problem for me because I am building a bundle out of bootstrap and jquery. bootstrap has a top-level check for jQuery's existence, and blows up if it can't find it. Even though I have jQuery as the first file listed in filesToConcat, it is not the first module in the output file.
I traced the code a bit and tried to fix it. resolveConcatAndUglify
is losing the order of the files by merging them all into one object and then iterating over the keys of the object with Object.entries(allFiles).forEach(...)
while adding sources to the ConcatSource. I changed it to iterate over the original files to maintain the order:
resolveConcatAndUglify(compilation, files) {
const allFiles = files.reduce((acc, file) => Object.assign(acc, file), {});
this.finalFileName = this.getFileName(allFiles);
const concatSource = new ConcatSource();
for (const fileObj of files) {
const name = Object.keys(fileObj)[0];
const file = fileObj[name];
concatSource.add(new OriginalSource(file, name));
}
compilation.emitAsset(`${this.settings.outputPath}/${this.finalFileName}`, concatSource);
this.needCreateNewFile = false;
}
Unfortunately the final build is still not ordered correctly, so I'm not sure what else to do.