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) => {
74
74
} )
75
75
76
76
// keep chunk ids stable so async chunks have consistent hash (#1916)
77
+ const seen = new Set ( )
78
+ const nameLength = 4
77
79
webpackConfig
78
80
. plugin ( 'named-chunks' )
79
81
. use ( require ( 'webpack/lib/NamedChunksPlugin' ) , [ chunk => {
80
82
if ( chunk . name ) {
81
83
return chunk . name
82
84
}
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
+ }
86
95
} ] )
87
96
}
88
97
You can’t perform that action at this time.
0 commit comments