webpack: Non-deterministic output breaking long-term caching

While using webpack for a project using react-bootstrap, I noticed my distribution hashes kept changing. I’ve narrowed this down to a simple test case, in my situation both react-bootstrap and react-bootstrap-daterangepicker are affected. This is mainly an issue for long-term caching as the hashes for files keep changing.

What happens is that whenever I execute webpack, the output will be different. Looking at diffs between runs it seems that the indexes passed into requires keep changing. Probably some async operations returning in variable order somewhere? Example diff chunk:

141c141
<       !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(5), __webpack_require__(4), exports], __WEBPACK_AMD_DEFINE_RESULT__ = function(momentjs, $, exports) {

---
>       !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(6), __webpack_require__(4), exports], __WEBPACK_AMD_DEFINE_RESULT__ = function(momentjs, $, exports) {

Repro case exists out of a package.json to install the requirements and a webpack config:

package.json:

{
    "name": "webpack-repro",
    "version": "0.0.0",
    "dependencies": {
        "react-bootstrap": "0.20.1",
        "react-bootstrap-daterangepicker": "0.2.4"
    },
    "devDependencies": {
        "webpack": "1.7.3"
    },
    "private": true
}

webpack.config.js:

'use strict';

var path = require("path");
var webpack = require("webpack");

module.exports = {
  entry: {
    vendor: [
      "react-bootstrap",
      // "react-bootstrap-daterangepicker",
    ],
  },
  output: {
    path: path.join(__dirname, "js"),
    filename: "[name].js",
  }
};

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 1
  • Comments: 19 (3 by maintainers)

Most upvoted comments

Why is this closed? None of the linked issued seem to address the problem. I have a “vendor” bundle whose contents seem to get “randomized” every time I build it. Exact same modules, different order. I have tried the “occurrence order plugin” – it made no difference. The benefit of splitting bundles is completely lost if the “vendor” bundle gets re-ordered every time, for no reason. There must be a simple, deterministic order that depends only on the set of modules being included! I am now looking for alternatives to webpack because this is essentially a deal-breaker. Hopefully I am missing something…is there a solution to this?

With the next major version occurence order is on by default.

The OccurenceOrderPlugin doesn’t seem to solve the problem of keeping the vendor chunk unchanged very well. It looks like that code modifications could result in module reordering even without adding new external dependencies.