Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
augmentChunkHash plugin hook (#2921)
* test: augmentChunkHash plugin hook tests * feat: augmentChunkHash plugin hook Hook to extend chunk hashes callable from within plugins in order to take in to account implicit dependencies such as plugin options or version when creating the chunk hash * test: independent hashing in augmentChunkHash tests * feat: pass reduced chunk info to ugmentChunkHash hook and hash chunks independenly * augmentChunkHash remove redundant test * augmentChunkHash fix typings * move augmentChungHash to chunk * restore unchanged files * allow augmentChunk to return string or void * update augment-chunk-hash tests * update augment-chunk-hash tests
- Loading branch information
1 parent
04b7d52
commit d4f7736
Showing
8 changed files
with
163 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const augment1 = '/*foo*/'; | ||
const augment2 = '/*bar*/'; | ||
module.exports = { | ||
description: 'augmentChunkHash updates hashes across all modules when returning something', | ||
options1: { | ||
input: 'main', | ||
output: { | ||
format: 'esm', | ||
entryFileNames: '[name]-[hash].js', | ||
chunkFileNames: '[name]-[hash].js' | ||
}, | ||
plugins: [ | ||
{ | ||
augmentChunkHash(chunk) { | ||
if (chunk.name === 'main') { | ||
return augment1; | ||
} | ||
}, | ||
renderChunk(code, chunk) { | ||
if (chunk.name === 'main') { | ||
return augment1 + code; | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
options2: { | ||
input: 'main', | ||
output: { | ||
format: 'esm', | ||
entryFileNames: '[name]-[hash].js', | ||
chunkFileNames: '[name]-[hash].js' | ||
}, | ||
plugins: [ | ||
{ | ||
augmentChunkHash(chunk) { | ||
if (chunk.name === 'main') { | ||
return augment2; | ||
} | ||
}, | ||
renderChunk(code, chunk) { | ||
if (chunk.name === 'main') { | ||
return augment2 + code; | ||
} | ||
} | ||
} | ||
] | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('main'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters