File tree Expand file tree Collapse file tree 5 files changed +66
-0
lines changed
test/configCases/contenthash/include-chunk-id Expand file tree Collapse file tree 5 files changed +66
-0
lines changed Original file line number Diff line number Diff line change @@ -135,6 +135,8 @@ class JavascriptModulesPlugin {
135
135
const template = chunk . hasRuntime ( )
136
136
? compilation . mainTemplate
137
137
: compilation . chunkTemplate ;
138
+ hash . update ( `${ chunk . id } ` ) ;
139
+ hash . update ( chunk . ids ? chunk . ids . join ( "," ) : "" ) ;
138
140
template . updateHashForChunk ( hash , chunk ) ;
139
141
for ( const m of chunk . modulesIterable ) {
140
142
if ( typeof m . source === "function" ) {
Original file line number Diff line number Diff line change
1
+ module . exports = "chunk" ;
Original file line number Diff line number Diff line change
1
+ it ( "should compile and run the test" , function ( ) { } ) ;
2
+
3
+ if ( Math . random ( ) < - 1 ) {
4
+ import ( /* webpackChunkName: "chunk" */ "./chunk" ) ;
5
+ }
Original file line number Diff line number Diff line change
1
+ var fs = require ( "fs" ) ;
2
+
3
+ var findFile = function ( files , regex ) {
4
+ return files . find ( function ( file ) {
5
+ if ( regex . test ( file ) ) {
6
+ return true ;
7
+ }
8
+ } ) ;
9
+ } ;
10
+
11
+ const allFilenameHashes = new Set ( ) ;
12
+ const allChunkHashes = new Set ( ) ;
13
+
14
+ module . exports = {
15
+ findBundle : function ( i , options ) {
16
+ var files = fs . readdirSync ( options . output . path ) ;
17
+
18
+ const filename = findFile ( files , new RegExp ( `^bundle${ i } ` ) ) ;
19
+ const filenameHash = / \. ( [ a - f 0 - 9 ] + ) \. j s $ / . exec ( filename ) [ 1 ] ;
20
+ allFilenameHashes . add ( filenameHash ) ;
21
+
22
+ const chunk = findFile ( files , new RegExp ( `^chunk${ i } ` ) ) ;
23
+ const chunkHash = / \. ( [ a - f 0 - 9 ] + ) \. j s $ / . exec ( chunk ) [ 1 ] ;
24
+ allChunkHashes . add ( chunkHash ) ;
25
+
26
+ return "./" + filename ;
27
+ } ,
28
+ afterExecute : ( ) => {
29
+ expect ( allFilenameHashes . size ) . toBe ( 2 ) ;
30
+ expect ( allChunkHashes . size ) . toBe ( 2 ) ;
31
+ }
32
+ } ;
Original file line number Diff line number Diff line change
1
+ module . exports = [
2
+ {
3
+ mode : "production" ,
4
+ name : "normal-ids" ,
5
+ output : {
6
+ filename : "bundle0.[contenthash:6].js" ,
7
+ chunkFilename : "chunk0.[contenthash:6].js"
8
+ } ,
9
+ optimization : {
10
+ chunkIds : "size" ,
11
+ moduleIds : "named"
12
+ }
13
+ } ,
14
+ {
15
+ mode : "production" ,
16
+ name : "normal-ids" ,
17
+ output : {
18
+ filename : "bundle1.[contenthash:6].js" ,
19
+ chunkFilename : "chunk1.[contenthash:6].js"
20
+ } ,
21
+ optimization : {
22
+ chunkIds : "named" ,
23
+ moduleIds : "named"
24
+ }
25
+ }
26
+ ] ;
You can’t perform that action at this time.
0 commit comments