Skip to content

Commit efe59de

Browse files
gdbortonjoshwiens
authored andcommitted
fix(hash): inconsistent hashes for builds in different dirs. (#28)
This fixes an issue created by the loader when building projects in different files. The expose-loader was previously changing requests to modules to absolute paths, which caused equivalent builds to generate different hashes when run in different directories. The fix basically converts the new requests to relative paths, that are relative to the original request.
1 parent dba9a85 commit efe59de

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
Author Tobias Koppers @sokra
44
*/
55

6+
var path = require('path');
7+
68
function accesorString(value) {
79
var childProperties = value.split(".");
810
var length = childProperties.length;
@@ -21,8 +23,12 @@ function accesorString(value) {
2123

2224
module.exports = function() {};
2325
module.exports.pitch = function(remainingRequest) {
26+
// Change the request from an /abolute/path.js to a relative ./path.js
27+
// This prevents [chunkhash] values from changing when running webpack
28+
// builds in different directories.
29+
var newRequestPath = "." + path.sep + path.basename(remainingRequest);
2430
this.cacheable && this.cacheable();
2531
if(!this.query) throw new Error("query parameter is missing");
2632
return accesorString(this.query.substr(1)) + " = " +
27-
"require(" + JSON.stringify("-!" + remainingRequest) + ");";
33+
"require(" + JSON.stringify("-!" + newRequestPath) + ");";
2834
};

0 commit comments

Comments
 (0)