Reproducible builds
I'm building my web app + React, taken from npm (following advice from webpack docs). Everything works fine, except that builds are not reproducible.
Every time I run webpack for the same source, I get slightly different bundle.js, with changes like this:
- var DOMProperty = __webpack_require__(33);
+ var DOMProperty = __webpack_require__(30);
- var escapeTextForBrowser = __webpack_require__(34);
- var memoizeStringOnly = __webpack_require__(35);
- var warning = __webpack_require__(32);
+ var escapeTextForBrowser = __webpack_require__(31);
+ var memoizeStringOnly = __webpack_require__(32);
+ var warning = __webpack_require__(33);
…
Is there a way to make webpack build reproducible?
You could store the recordsPath which saves the module path with their IDs:
http://webpack.github.io/docs/configuration.html#recordspath-recordsinputpath-recordsoutputpath
However, until #295 is fixed, this will only work on the same machine recordsPath was created on.
recordsPath or OccurenceOrderPlugin. See #408
I use OccurenceOrderPlugin for that.
@shamrin Out of curiosity, why do you need builds to be reproducible? (I don't doubt you have a good reason. I want to inform myself).
If you use hashes in filenames for long-term browser caching, you want them to stay the same for unchanged files.
@gaearon Makes sense. Thanks!
For anyone seeing this in 2019: The OccurenceOrderPlugin is now included by default, so builds should by default be reproducible:
The plugin is no longer needed and occurrence order is on by default.
https://gist.github.com/sokra/27b24881210b56bbaff7#occurrence-order