webpack icon indicating copy to clipboard operation
webpack copied to clipboard

Reproducible builds

Open shamrin opened this issue 11 years ago • 7 comments

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?

shamrin avatar Jan 29 '15 17:01 shamrin

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.

sirlancelot avatar Jan 29 '15 18:01 sirlancelot

recordsPath or OccurenceOrderPlugin. See #408

agundermann avatar Jan 29 '15 18:01 agundermann

I use OccurenceOrderPlugin for that.

gaearon avatar Jan 29 '15 21:01 gaearon

@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).

cowwoc avatar Feb 06 '15 01:02 cowwoc

If you use hashes in filenames for long-term browser caching, you want them to stay the same for unchanged files.

gaearon avatar Feb 06 '15 08:02 gaearon

@gaearon Makes sense. Thanks!

cowwoc avatar Feb 06 '15 19:02 cowwoc

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

rugk avatar Dec 23 '19 17:12 rugk