[Pkg-javascript-devel] Bug#941309: node-browserify-lite: unreproducible dependency map order
Rebecca N. Palmer
rebecca_palmer at zoho.com
Sun Sep 29 11:51:14 BST 2019
Control: forwarded -1 https://github.com/andrewrk/browserify-lite/pull/13
Upstream pointed out that this doesn't escape special characters in file
names; corrected version follows.
Subject: Ease reproducible build
author: Rebecca N. Palmer" <rebecca_palmer at zoho.com>
Sort module list and dependency lists in order to be reproducible
Forwarded: https://github.com/andrewrk/browserify-lite/issues/12
Index: node-browserify-lite/index.js
===================================================================
--- node-browserify-lite.orig/index.js
+++ node-browserify-lite/index.js
@@ -79,6 +79,8 @@ function renderBundle(options, cb) {
function render(entrySourcePath, cb) {
var modules = Object.keys(sources);
+ // for reproducibility
+ modules.sort();
var aliases = {};
modules.forEach(function(canonicalSourcePath, index) {
aliases[canonicalSourcePath] = index;
@@ -116,7 +118,17 @@ function renderBundle(options, cb) {
out += "module.exports = ";
}
out += sources[canonicalSourcePath];
- out += "\n}, " + JSON.stringify(depMap[canonicalSourcePath]) + "],";
+ out += "\n}, {";
+ // for reproducibility, as JSON.stringify(depMap[canonicalSourcePath]) does not guarantee order - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
+ var depMapKeys = Object.keys(depMap[canonicalSourcePath]);
+ depMapKeys.sort();
+ depMapKeys.forEach(function(depPath, index) {
+ if (index != 0) {
+ out += ","; // separate to not have a trailing comma
+ }
+ out += JSON.stringify(depPath) + ":" + depMap[canonicalSourcePath][depPath];
+ });
+ out += "}],";
});
out += "}, {}, " + aliases[entrySourcePath] + ");\n";
More information about the Pkg-javascript-devel
mailing list