Skip to content

Commit

Permalink
fix: revert named-chunks nameResolver algorithm (#2324)
Browse files Browse the repository at this point in the history
* Revert "fix: avoid hash collisions (#1959)"

This reverts commit 4b5a634.

* Revert "refactor: improve chunk name aesthetics"

This reverts commit 625d541.
  • Loading branch information
haoqunjiang authored Sep 4, 2018
1 parent f9652a1 commit 3933187
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions packages/@vue/cli-service/lib/config/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('_')
}])
}

Expand Down

0 comments on commit 3933187

Please sign in to comment.