feat: refactoring project

This commit is contained in:
Carlos
2024-11-23 14:56:07 -05:00
parent f0c2a50c18
commit 1c6db5818d
2351 changed files with 39323 additions and 60326 deletions

View File

@@ -61,9 +61,7 @@ const mapAndDeduplicateBuffers = (input, fn) => {
* @param {string} str String to quote
* @returns {string} Escaped string
*/
const quoteMeta = str => {
return str.replace(/[-[\]\\/{}()*+?.^$|]/g, "\\$&");
};
const quoteMeta = str => str.replace(/[-[\]\\/{}()*+?.^$|]/g, "\\$&");
const cachedSourceMap = new WeakMap();
@@ -103,7 +101,7 @@ const toCachedSource = source => {
/**
* @typedef {object} CompilationHooks
* @property {SyncBailHook<[Buffer[], string], string>} updateHash
* @property {SyncBailHook<[Buffer[], string], string | void>} updateHash
*/
/** @type {WeakMap<Compilation, CompilationHooks>} */
@@ -215,7 +213,7 @@ class RealContentHashPlugin {
[asset.referencedHashes, asset.ownHashes] =
await cacheAnalyse.providePromise(name, etag, () => {
const referencedHashes = new Set();
let ownHashes = new Set();
const ownHashes = new Set();
const inContent = content.match(hashRegExp);
if (inContent) {
for (const hash of inContent) {
@@ -256,7 +254,7 @@ ${referencingAssets
})
.join("\n")}`);
compilation.errors.push(err);
return undefined;
return;
}
const hashes = new Set();
for (const { referencedHashes, ownHashes } of assets) {
@@ -369,7 +367,7 @@ ${referencingAssets
(asset.referencedHashes)
).some(hash => hashToNewHash.get(hash) !== hash)
) {
const identifier = asset.name + "|without-own";
const identifier = `${asset.name}|without-own`;
const etag = getEtag(asset);
asset.newSourceWithoutOwn = await cacheGenerate.providePromise(
identifier,
@@ -410,11 +408,10 @@ ${referencingAssets
return asset.newSourceWithoutOwn
? asset.newSourceWithoutOwn.buffer()
: asset.source.buffer();
} else {
return asset.newSource
? asset.newSource.buffer()
: asset.source.buffer();
}
return asset.newSource
? asset.newSource.buffer()
: asset.source.buffer();
});
let newHash = hooks.updateHash.call(assetsContent, oldHash);
if (!newHash) {