Skip to content

Commit b7a8441

Browse files
fix: regression with unicode characters in locals
1 parent 52715ee commit b7a8441

File tree

4 files changed

+184
-138
lines changed

4 files changed

+184
-138
lines changed

Diff for: src/utils.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,13 @@ function defaultGetLocalIdent(
364364
let localIdentHash = "";
365365

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

370375
if (hashSalt) {
371376
hash.update(hashSalt);
@@ -376,7 +381,8 @@ function defaultGetLocalIdent(
376381
tierSalt.writeUInt32LE(tier);
377382

378383
hash.update(tierSalt);
379-
hash.update(options.content);
384+
// TODO: bug in webpack with unicode characters with strings
385+
hash.update(Buffer.from(options.content, "utf8"));
380386

381387
localIdentHash = (localIdentHash + hash.digest(hashDigest))
382388
// Remove all leading digits

0 commit comments

Comments
 (0)