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

src/utils.js

Lines changed: 9 additions & 3 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy