Skip to content

Commit

Permalink
fix: regression with unicode characters in locals
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Nov 3, 2021
1 parent 52715ee commit b7a8441
Show file tree
Hide file tree
Showing 4 changed files with 184 additions and 138 deletions.
12 changes: 9 additions & 3 deletions src/utils.js
Expand Up @@ -364,8 +364,13 @@ function defaultGetLocalIdent(
let localIdentHash = "";

for (let tier = 0; localIdentHash.length < hashDigestLength; tier++) {
// eslint-disable-next-line no-underscore-dangle
const hash = loaderContext._compiler.webpack.util.createHash(hashFunction);
// TODO remove this in the next major release
const hash =
loaderContext.utils &&
typeof loaderContext.utils.createHash === "function"
? loaderContext.utils.createHash(hashFunction)
: // eslint-disable-next-line no-underscore-dangle
loaderContext._compiler.webpack.util.createHash(hashFunction);

if (hashSalt) {
hash.update(hashSalt);
Expand All @@ -376,7 +381,8 @@ function defaultGetLocalIdent(
tierSalt.writeUInt32LE(tier);

hash.update(tierSalt);
hash.update(options.content);
// TODO: bug in webpack with unicode characters with strings
hash.update(Buffer.from(options.content, "utf8"));

localIdentHash = (localIdentHash + hash.digest(hashDigest))
// Remove all leading digits
Expand Down

0 comments on commit b7a8441

Please sign in to comment.