@@ -29,6 +29,23 @@ class JsonpMainTemplatePlugin {
2929 const chunkMaps = chunk . getChunkMaps ( ) ;
3030 const crossOriginLoading = this . outputOptions . crossOriginLoading ;
3131 const chunkLoadTimeout = this . outputOptions . chunkLoadTimeout || 120000 ;
32+ const scriptSrcPath = this . applyPluginsWaterfall ( "asset-path" , JSON . stringify ( chunkFilename ) , {
33+ hash : `" + ${ this . renderCurrentHashCode ( hash ) } + "` ,
34+ hashWithLength : length => `" + ${ this . renderCurrentHashCode ( hash , length ) } + "` ,
35+ chunk : {
36+ id : "\" + chunkId + \"" ,
37+ hash : `" + ${ JSON . stringify ( chunkMaps . hash ) } [chunkId] + "` ,
38+ hashWithLength ( length ) {
39+ const shortChunkHashMap = Object . create ( null ) ;
40+ Object . keys ( chunkMaps . hash ) . forEach ( chunkId => {
41+ if ( typeof chunkMaps . hash [ chunkId ] === "string" )
42+ shortChunkHashMap [ chunkId ] = chunkMaps . hash [ chunkId ] . substr ( 0 , length ) ;
43+ } ) ;
44+ return `" + ${ JSON . stringify ( shortChunkHashMap ) } [chunkId] + "` ;
45+ } ,
46+ name : `" + (${ JSON . stringify ( chunkMaps . name ) } [chunkId]||chunkId) + "`
47+ }
48+ } ) ;
3249 return this . asString ( [
3350 "var script = document.createElement('script');" ,
3451 "script.type = 'text/javascript';" ,
@@ -39,23 +56,7 @@ class JsonpMainTemplatePlugin {
3956 `if (${ this . requireFn } .nc) {` ,
4057 this . indent ( `script.setAttribute("nonce", ${ this . requireFn } .nc);` ) ,
4158 "}" ,
42- `script.src = ${ this . requireFn } .p + ${ this . applyPluginsWaterfall ( "asset-path" , JSON . stringify ( chunkFilename ) , {
43- hash : `" + ${ this . renderCurrentHashCode ( hash ) } + "` ,
44- hashWithLength : length => `" + ${ this . renderCurrentHashCode ( hash , length ) } + "` ,
45- chunk : {
46- id : "\" + chunkId + \"" ,
47- hash : `" + ${ JSON . stringify ( chunkMaps . hash ) } [chunkId] + "` ,
48- hashWithLength ( length ) {
49- const shortChunkHashMap = Object . create ( null ) ;
50- Object . keys ( chunkMaps . hash ) . forEach ( chunkId => {
51- if ( typeof chunkMaps . hash [ chunkId ] === "string" )
52- shortChunkHashMap [ chunkId ] = chunkMaps . hash [ chunkId ] . substr ( 0 , length ) ;
53- } ) ;
54- return `" + ${ JSON . stringify ( shortChunkHashMap ) } [chunkId] + "` ;
55- } ,
56- name : `" + (${ JSON . stringify ( chunkMaps . name ) } [chunkId]||chunkId) + "`
57- }
58- } ) } ;`,
59+ `script.src = ${ this . requireFn } .p + ${ scriptSrcPath } ;` ,
5960 `var timeout = setTimeout(onScriptComplete, ${ chunkLoadTimeout } );` ,
6061 "script.onerror = script.onload = onScriptComplete;" ,
6162 "function onScriptComplete() {" ,
0 commit comments