File tree Expand file tree Collapse file tree 5 files changed +109
-1
lines changed
test/configCases/issues/issue-7563 Expand file tree Collapse file tree 5 files changed +109
-1
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,20 @@ class WebWorkerMainTemplatePlugin {
5454 ) } + "`,
5555 chunk : {
5656 id : '" + chunkId + "' ,
57+ hash : `" + ${ JSON . stringify ( chunkMaps . hash ) } [chunkId] + "` ,
58+ hashWithLength ( length ) {
59+ const shortChunkHashMap = Object . create ( null ) ;
60+ for ( const chunkId of Object . keys ( chunkMaps . hash ) ) {
61+ if ( typeof chunkMaps . hash [ chunkId ] === "string" ) {
62+ shortChunkHashMap [ chunkId ] = chunkMaps . hash [
63+ chunkId
64+ ] . substr ( 0 , length ) ;
65+ }
66+ }
67+ return `" + ${ JSON . stringify (
68+ shortChunkHashMap
69+ ) } [chunkId] + "`;
70+ } ,
5771 contentHash : {
5872 javascript : `" + ${ JSON . stringify (
5973 chunkMaps . contentHash . javascript
@@ -74,7 +88,10 @@ class WebWorkerMainTemplatePlugin {
7488 shortContentHashMap
7589 ) } [chunkId] + "`;
7690 }
77- }
91+ } ,
92+ name : `" + (${ JSON . stringify (
93+ chunkMaps . name
94+ ) } [chunkId]||chunkId) + "`
7895 } ,
7996 contentHashType : "javascript"
8097 } ) +
Original file line number Diff line number Diff line change 1+ it ( "should compile without error" , function ( ) {
2+ return import ( /* webpackChunkName: "one" */ "./one" ) ;
3+ } ) ;
Original file line number Diff line number Diff line change 1+ module . exports = 1 ;
Original file line number Diff line number Diff line change 1+ var fs = require ( 'fs' ) ;
2+
3+ module . exports = {
4+ noTests : true ,
5+ findBundle : function ( i , options ) {
6+ var regex = new RegExp ( "^bundle\." + options . name , "i" ) ;
7+ var files = fs . readdirSync ( options . output . path ) ;
8+ var bundle = files . find ( function ( file ) {
9+ return regex . test ( file ) ;
10+ } ) ;
11+
12+ if ( ! bundle ) {
13+ throw new Error (
14+ `No file found with correct name (regex: ${
15+ regex . source
16+ } , files: ${ files . join ( ", " ) } )`
17+ ) ;
18+ }
19+
20+ return "./" + bundle ;
21+ }
22+ } ;
Original file line number Diff line number Diff line change 1+ "use strict" ;
2+
3+ // Have to test [hash] and [chunkhash] separately to avoid
4+ // "Cannot use [chunkhash] or [contenthash] for chunk in 'bundle1.[hash].[hash:16].[chunkhash].[chunkhash:16].[name].[id].[query].js' (use [hash] instead)"
5+ var testAllButHash = "[chunkhash].[chunkhash:16].[name].[id].[query]" ;
6+ var testHash = "[hash].[hash:16]" ;
7+
8+ module . exports = [
9+ {
10+ name : "webworker-all" ,
11+ target : "webworker" ,
12+ output : {
13+ filename : "bundle.webworker-all." + testAllButHash + ".js"
14+ }
15+ } ,
16+ {
17+ name : "webworker-hash" ,
18+ target : "webworker" ,
19+ output : {
20+ filename : "bundle.webworker-hash." + testHash + ".js"
21+ }
22+ } ,
23+ {
24+ name : "node-all" ,
25+ target : "node" ,
26+ output : {
27+ filename : "bundle.node-all." + testAllButHash + ".js"
28+ }
29+ } ,
30+ {
31+ name : "node" ,
32+ target : "node" ,
33+ output : {
34+ filename : "bundle.node-hash." + testHash + ".js"
35+ }
36+ } ,
37+ {
38+ name : "async-node-all" ,
39+ target : "async-node" ,
40+ output : {
41+ filename : "bundle.async-node-all." + testAllButHash + ".js"
42+ }
43+ } ,
44+ {
45+ name : "async-node-hash" ,
46+ target : "async-node" ,
47+ output : {
48+ filename : "bundle.async-node-hash." + testHash + ".js"
49+ }
50+ } ,
51+ {
52+ name : "web-all" ,
53+ target : "web" ,
54+ output : {
55+ filename : "bundle.web-all." + testAllButHash + ".js"
56+ }
57+ } ,
58+ {
59+ name : "web-hash" ,
60+ target : "web" ,
61+ output : {
62+ filename : "bundle.web-hash." + testHash + ".js"
63+ }
64+ }
65+ ] ;
You can’t perform that action at this time.
0 commit comments