File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
packages/@vue/cli-service/lib/config Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -74,15 +74,24 @@ module.exports = (api, options) => {
7474 } )
7575
7676 // keep chunk ids stable so async chunks have consistent hash (#1916)
77+ const seen = new Set ( )
78+ const nameLength = 4
7779 webpackConfig
7880 . plugin ( 'named-chunks' )
7981 . use ( require ( 'webpack/lib/NamedChunksPlugin' ) , [ chunk => {
8082 if ( chunk . name ) {
8183 return chunk . name
8284 }
83- return `chunk-` + Array . from ( chunk . modulesIterable , m => {
84- return m . id
85- } ) . join ( '_' )
85+ const modules = Array . from ( chunk . modulesIterable )
86+ if ( modules . length > 1 ) {
87+ const hash = require ( 'hash-sum' )
88+ const joinedHash = hash ( modules . map ( m => m . id ) . join ( '_' ) )
89+ let len = nameLength
90+ while ( seen . has ( joinedHash . substr ( 0 , len ) ) ) len ++
91+ return `chunk-${ joinedHash . substr ( 0 , len ) } `
92+ } else {
93+ return modules [ 0 ] . id
94+ }
8695 } ] )
8796 }
8897
You can’t perform that action at this time.
0 commit comments