Skip to content

Commit

Permalink
feat: do not hash localName if the localName is inlined
Browse files Browse the repository at this point in the history
  • Loading branch information
subzey committed Jan 26, 2022
1 parent cbe3898 commit f7f3072
Show file tree
Hide file tree
Showing 2 changed files with 838 additions and 829 deletions.
13 changes: 11 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,17 @@ function defaultGetLocalIdent(
path.relative(context, resourcePath)
);

// eslint-disable-next-line no-param-reassign
options.content = `${relativeResourcePath}\x00${localName}`;
if (/\[local\]/.test(localIdentName)) {
// We don't have to include the localName in the string to be hashed if it
// would be present in the generated identifier anyway.
// All identifiers from the same module gets the same hash - good for GZIP!

// eslint-disable-next-line no-param-reassign
options.content = relativeResourcePath;
} else {
// eslint-disable-next-line no-param-reassign
options.content = `${relativeResourcePath}\x00${localName}`;
}

let { hashFunction, hashDigest, hashDigestLength } = options;
const matches = localIdentName.match(
Expand Down

0 comments on commit f7f3072

Please sign in to comment.