Issue 1:
Bug report

(This is a continuation of #7381, which solved part but not all of the issue. I think this is a bug. It's possible it's a feature I don't yet understand. Apologies in advance for the verbose bug report...)

What is the current behavior?

When using the split chunks plugin, the resulting compilation chunks sometimes have duplicate ids. For example, I added this debugging hook to my webpack config:

compiler.hooks.afterEmit.tap("log-dupe-chunks", function(compilation) {
let chunks = compilation.chunks;
let chunkIds = chunks.map(c => c.id);
let dupeChunks = chunks
.filter(c => chunkIds.filter(i => i === c.id).length > 1)
.map(c =>
pick(c, ["id", "ids", "debugId", "name", "entryModule", "files", "rendered", "hash", "contentHash", "renderedHash", "chunkReason", "extraAsync"])
);
if (dupeChunks.length) {
console.log(dupeChunks);
}
});

Resulting in this output:

[ { id: 11,
ids: [ 11 ],
debugId: 1021,
name: 'highcharts',
entryModule: undefined,
files:
[ 'split.672955a005ca955ca723.js',
'split.672955a005ca955ca723.js.map' ],
rendered: true,
hash: '672955a005ca955ca7232db2b80f1b7f',
contentHash: { javascript: '0a19d1f296fc806aaf2e' },
renderedHash: '672955a005ca955ca723',
chunkReason: undefined,
extraAsync: false },
{ id: 11,
ids: [ 11 ],
debugId: 1015,
name: 'channel_dashboard',
entryModule: undefined,
files:
[ 'split.ad76a221da40a498edfb.js',
'split.ad76a221da40a498edfb.js.map' ],
rendered: true,
hash: 'ad76a221da40a498edfb84f74889fc48',
contentHash: { javascript: 'eb2bbec49673375a4d25' },
renderedHash: 'ad76a221da40a498edfb',
chunkReason: undefined,
extraAsync: false } ]

I've only seen this happen when using recordsPath. If I delete my webpack records & re-build, all the chunk ids are unique.

The most recent time I've seen this, my webpack records started like this:

"chunks": {
"byName": {
"vendors~polyfills": 1,
"polyfills": 2,
"vendors~backend~highcharts": 5,
"vendors~markdownediting~uploader": 19,
"vendors~t_store": 20,
"vendors~uploader": 21,
"v4player": 10,
"highcharts": 11,
"channel_dashboard": 16,
"motherchannel": 17,
"embedediting": 18,
"markdownediting": 19,
"t_store": 20,
"uploader": 21,
"backend": 22,
"qrcodes": 23,
"recommended-follows": 24,
"auth-modal": 25,
"preload": 26,
"vendors~application~embed_player~embed_player_square_ad": 27,
"vendors~application~embed_player_square_ad": 28,
"embed_player_square_ad": 29,
"embed_player": 30,
"application": 31,
"vendors~embed_player_square_ad~v4player": 10,
"channel_dashboard~highcharts": 11
},

and ended like this:

"byName": {
"vendors~polyfills": 1,
"polyfills": 2,
"vendors~backend~highcharts": 5,
"vendors~markdownediting~uploader": 8,
"vendors~teepublic_store": 9,
"vendors~uploader": 13,
"v4player": 10,
"highcharts": 11,
"channel_dashboard": 11,
"motherchannel": 15,
"embedediting": 18,
"markdownediting": 19,
"teepublic_store": 20,
"uploader": 21,
"backend": 14,
"qrcodes": 23,
"recommended-follows": 24,
"auth-modal": 25,
"preload": 26,
"vendors~application~embed_player~embed_player_square_ad": 27,
"vendors~application~embed_player_square_ad": 28,
"embed_player_square_ad": 29,
"embed_player": 30,
"application": 31,
"vendors~embed_player_square_ad~v4player": 10,
"channel_dashboard~highcharts": 11
},

Note the multiple chunks with an id of 11.

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

Sorry, I'm really struggling to narrow this down. It seems to come and go at the whim of whatever heuristics drive SplitChunksPlugin. If someone can confirm this is a bug and it's not immediately obvious why it happens, I'll try harder.

What is the expected behavior?

Presumably all compilation chunks should have unique ids?

Other relevant information:

webpack version: 4.11.0

Node.js version: 8.11.1

Operating System: Docker with node:8.11-alpine

I'm using https://github.com/GProst/webpack-clean-obsolete-chunks, which expects chunks to have unique ids, and ends up accidentally deleting files when they don't. If it turns out that chunks are allowed to have duplicate ids, I'll submit a fix to that.

Issue 2:
webpack 2.1.0-beta.21

Sorry if it is a duplicate bug report but at least I failed to find one in so many opened issues.

ExtractTextPlugin is not enabled, CommonsChunkPlugin is not enabled, happypack is not enabled.. it just broke, sometimes.

Config: https://github.com/vijos/vj4/blob/6c06305e9481c0f13c8c3faa3198c58b2f686505/webpack.config.babel.js

Command line: webpack --progress --color --display-error-details --env.watch -d --watch.

Although extractTextPlugin, commonsChunkPlugin and happypack is mentioned in the configuration, they are not enabled because we passed env.watch.

We only generate one entry vj4.js in watch mode. And after changing some file (for example, vj4/ui/misc/sad_twd2.svg), vj4.js becomes:

webpackJsonp([15],[
/* 0 */,
/* 1 */
/***/ function(module, exports, __webpack_require__) {

"use strict";
'use strict';

It fails because webpackJsonp is undefined.

Reproduce

watch

git clone https://github.com/vijos/vj4.git
cd vj4
git checkout 6c06305e9481c0f13c8c3faa3198c58b2f686505
node scripts/fix_abroad_shrinkwrap.js # we use a China mirror which is slow for you so that you need this line
npm install
npm run watch

verify correctness

check vj4/.uibuild/vj4.js to see a correct build:

head -n 5 vj4/.uibuild/vj4.js

/******/ (function(modules) { // webpackBootstrap
/******/ // install a JSONP callback for chunk loading
/******/ var parentJsonpFunction = window["webpackJsonp"];
/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {
/******/ // add "moreModules" to the modules object,

change some file

echo "<!-- foo -->" >> vj4/ui/misc/sad_twd2.svg

let's change again!

echo "<!-- foo -->" >> vj4/ui/misc/sad_twd2.svg

bang!

check vj4/.uibuild/vj4.js to see a corrupted build:

head -n 5 vj4/.uibuild/vj4.js

webpackJsonp([15],[
/* 0 */,
/* 1 */
/***/ function(module, exports, __webpack_require__) {