@@ -274,78 +274,71 @@ class CssLoadingRuntimeModule extends RuntimeModule {
274274 "" ,
275275 withLoading
276276 ? Template . asString ( [
277- `${ fn } .css = ${ runtimeTemplate . basicFunction (
278- "chunkId, promises" ,
279- hasCssMatcher !== false
280- ? [
281- "// css chunk loading" ,
282- `var installedChunkData = ${ RuntimeGlobals . hasOwnProperty } (installedChunks, chunkId) ? installedChunks[chunkId] : undefined;` ,
283- 'if(installedChunkData !== 0) { // 0 means "already installed".' ,
284- Template . indent ( [
285- "" ,
286- '// a Promise means "currently loading".' ,
287- "if(installedChunkData) {" ,
288- Template . indent ( [
289- "promises.push(installedChunkData[2]);"
290- ] ) ,
291- "} else {" ,
292- Template . indent ( [
293- hasCssMatcher === true
294- ? "if(true) { // all chunks have CSS"
295- : `if(${ hasCssMatcher ( "chunkId" ) } ) {` ,
277+ `${ fn } .css = ${ runtimeTemplate . basicFunction ( "chunkId, promises" , [
278+ "// css chunk loading" ,
279+ `var installedChunkData = ${ RuntimeGlobals . hasOwnProperty } (installedChunks, chunkId) ? installedChunks[chunkId] : undefined;` ,
280+ 'if(installedChunkData !== 0) { // 0 means "already installed".' ,
281+ Template . indent ( [
282+ "" ,
283+ '// a Promise means "currently loading".' ,
284+ "if(installedChunkData) {" ,
285+ Template . indent ( [ "promises.push(installedChunkData[2]);" ] ) ,
286+ "} else {" ,
287+ Template . indent ( [
288+ hasCssMatcher === true
289+ ? "if(true) { // all chunks have CSS"
290+ : `if(${ hasCssMatcher ( "chunkId" ) } ) {` ,
291+ Template . indent ( [
292+ "// setup Promise in chunk cache" ,
293+ `var promise = new Promise(${ runtimeTemplate . expressionFunction (
294+ `installedChunkData = installedChunks[chunkId] = [resolve, reject]` ,
295+ "resolve, reject"
296+ ) } );`,
297+ "promises.push(installedChunkData[2] = promise);" ,
298+ "" ,
299+ "// start chunk loading" ,
300+ `var url = ${ RuntimeGlobals . publicPath } + ${ RuntimeGlobals . getChunkCssFilename } (chunkId);` ,
301+ "// create error before stack unwound to get useful stacktrace later" ,
302+ "var error = new Error();" ,
303+ `var loadingEnded = ${ runtimeTemplate . basicFunction (
304+ "event" ,
305+ [
306+ `if(${ RuntimeGlobals . hasOwnProperty } (installedChunks, chunkId)) {` ,
296307 Template . indent ( [
297- "// setup Promise in chunk cache" ,
298- `var promise = new Promise(${ runtimeTemplate . expressionFunction (
299- `installedChunkData = installedChunks[chunkId] = [resolve, reject]` ,
300- "resolve, reject"
301- ) } );`,
302- "promises.push(installedChunkData[2] = promise);" ,
303- "" ,
304- "// start chunk loading" ,
305- `var url = ${ RuntimeGlobals . publicPath } + ${ RuntimeGlobals . getChunkCssFilename } (chunkId);` ,
306- "// create error before stack unwound to get useful stacktrace later" ,
307- "var error = new Error();" ,
308- `var loadingEnded = ${ runtimeTemplate . basicFunction (
309- "event" ,
310- [
311- `if(${ RuntimeGlobals . hasOwnProperty } (installedChunks, chunkId)) {` ,
312- Template . indent ( [
313- "installedChunkData = installedChunks[chunkId];" ,
314- "if(installedChunkData !== 0) installedChunks[chunkId] = undefined;" ,
315- "if(installedChunkData) {" ,
316- Template . indent ( [
317- 'if(event.type !== "load") {' ,
318- Template . indent ( [
319- "var errorType = event && event.type;" ,
320- "var realSrc = event && event.target && event.target.src;" ,
321- "error.message = 'Loading css chunk ' + chunkId + ' failed.\\n(' + errorType + ': ' + realSrc + ')';" ,
322- "error.name = 'ChunkLoadError';" ,
323- "error.type = errorType;" ,
324- "error.request = realSrc;" ,
325- "installedChunkData[1](error);"
326- ] ) ,
327- "} else {" ,
328- Template . indent ( [
329- `loadCssChunkData(${ RuntimeGlobals . moduleFactories } , link, chunkId);` ,
330- "installedChunkData[0]();"
331- ] ) ,
332- "}"
333- ] ) ,
334- "}"
335- ] ) ,
336- "}"
337- ]
338- ) } ;`,
339- "var link = loadStylesheet(chunkId, url, loadingEnded);"
308+ "installedChunkData = installedChunks[chunkId];" ,
309+ "if(installedChunkData !== 0) installedChunks[chunkId] = undefined;" ,
310+ "if(installedChunkData) {" ,
311+ Template . indent ( [
312+ 'if(event.type !== "load") {' ,
313+ Template . indent ( [
314+ "var errorType = event && event.type;" ,
315+ "var realSrc = event && event.target && event.target.src;" ,
316+ "error.message = 'Loading css chunk ' + chunkId + ' failed.\\n(' + errorType + ': ' + realSrc + ')';" ,
317+ "error.name = 'ChunkLoadError';" ,
318+ "error.type = errorType;" ,
319+ "error.request = realSrc;" ,
320+ "installedChunkData[1](error);"
321+ ] ) ,
322+ "} else {" ,
323+ Template . indent ( [
324+ `loadCssChunkData(${ RuntimeGlobals . moduleFactories } , link, chunkId);` ,
325+ "installedChunkData[0]();"
326+ ] ) ,
327+ "}"
328+ ] ) ,
329+ "}"
340330 ] ) ,
341- "} else installedChunks[chunkId] = 0;"
342- ] ) ,
343- "}"
344- ] ) ,
345- "}"
346- ]
347- : "installedChunks[chunkId] = 0;"
348- ) } ;`
331+ "}"
332+ ]
333+ ) } ;`,
334+ "var link = loadStylesheet(chunkId, url, loadingEnded);"
335+ ] ) ,
336+ "} else installedChunks[chunkId] = 0;"
337+ ] ) ,
338+ "}"
339+ ] ) ,
340+ "}"
341+ ] ) } ;`
349342 ] )
350343 : "// no chunk loading" ,
351344 "" ,
0 commit comments