mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-01-26 17:19:08 -06:00
fix: revert named-chunks nameResolver algorithm (#2324)
* Revert "fix: avoid hash collisions (#1959)" This reverts commit4b5a63441b. * Revert "refactor: improve chunk name aesthetics" This reverts commit625d541715.
This commit is contained in:
@@ -119,25 +119,15 @@ module.exports = (api, options) => {
|
||||
})
|
||||
|
||||
// keep chunk ids stable so async chunks have consistent hash (#1916)
|
||||
const seen = new Set()
|
||||
const nameLength = 4
|
||||
webpackConfig
|
||||
.plugin('named-chunks')
|
||||
.use(require('webpack/lib/NamedChunksPlugin'), [chunk => {
|
||||
if (chunk.name) {
|
||||
return chunk.name
|
||||
}
|
||||
const modules = Array.from(chunk.modulesIterable)
|
||||
if (modules.length > 1) {
|
||||
const hash = require('hash-sum')
|
||||
const joinedHash = hash(modules.map(m => m.id).join('_'))
|
||||
let len = nameLength
|
||||
while (seen.has(joinedHash.substr(0, len))) len++
|
||||
seen.add(joinedHash.substr(0, len))
|
||||
return `chunk-${joinedHash.substr(0, len)}`
|
||||
} else {
|
||||
return modules[0].id
|
||||
}
|
||||
return `chunk-` + Array.from(chunk.modulesIterable, m => {
|
||||
return m.id
|
||||
}).join('_')
|
||||
}])
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user