@@ -103,7 +103,7 @@ class CssLoadingRuntimeModule extends RuntimeModule {
103103 const code = Template . asString ( [
104104 "link = document.createElement('link');" ,
105105 uniqueName
106- ? 'link.setAttribute("data-webpack", dataWebpackPrefix + key);'
106+ ? 'link.setAttribute("data-webpack", uniqueName + ":" + key);'
107107 : "" ,
108108 "link.setAttribute(loadingAttribute, 1);" ,
109109 'link.rel = "stylesheet";' ,
@@ -133,10 +133,24 @@ class CssLoadingRuntimeModule extends RuntimeModule {
133133 id => `${ JSON . stringify ( id ) } :0`
134134 ) . join ( "," ) } };`,
135135 "" ,
136+ uniqueName
137+ ? `var uniqueName = ${ JSON . stringify (
138+ runtimeTemplate . outputOptions . uniqueName
139+ ) } ;`
140+ : "// data-webpack is not used as build has no uniqueName" ,
136141 `var loadCssChunkData = ${ runtimeTemplate . basicFunction ( "chunkId, link" , [
137142 'var data, token = "", token2, exports = {}, exportsWithId = [], i = 0, cc = 1;' ,
138143 "try { if(!link) link = loadStylesheet(chunkId); data = link.sheet.cssRules; data = data[data.length - 1].style; } catch(e) { data = getComputedStyle(document.head); }" ,
139- 'data = data.getPropertyValue("--webpack-" + chunkId);' ,
144+ `data = data.getPropertyValue(${
145+ uniqueName
146+ ? runtimeTemplate . concatenation (
147+ "--webpack-" ,
148+ { expr : "uniqueName" } ,
149+ "-" ,
150+ { expr : "chunkId" }
151+ )
152+ : runtimeTemplate . concatenation ( "--webpack-" , { expr : "chunkId" } )
153+ } );`,
140154 "if(!data) return;" ,
141155 "for(; cc; i++) {" ,
142156 Template . indent ( [
@@ -147,11 +161,23 @@ class CssLoadingRuntimeModule extends RuntimeModule {
147161 ) } ) { exports[token2.replace(/^_/, "")] = token.replace(/^_/, ""); token = ""; }`,
148162 `else if(cc == ${ cc (
149163 "/"
150- ) } ) { token = token.replace(/^_/, ""); exports[token] = token + "_" ; exportsWithId.push(token); token = ""; }`,
164+ ) } ) { token = token.replace(/^_/, ""); exports[token] = token; exportsWithId.push(token); token = ""; }`,
151165 `else if(!cc || cc == ${ cc (
152166 ","
153167 ) } ) { token = token.replace(/^_/, ""); exportsWithId.forEach(${ runtimeTemplate . expressionFunction (
154- "exports[x] += token" ,
168+ `exports[x] = ${
169+ uniqueName
170+ ? runtimeTemplate . concatenation (
171+ { expr : "uniqueName" } ,
172+ "-" ,
173+ { expr : "token" } ,
174+ "-" ,
175+ { expr : "exports[x]" }
176+ )
177+ : runtimeTemplate . concatenation ( { expr : "token" } , "-" , {
178+ expr : "exports[x]"
179+ } )
180+ } `,
155181 "x"
156182 ) } ); ${ RuntimeGlobals . makeNamespaceObject } (exports); ${
157183 RuntimeGlobals . moduleFactories
@@ -166,9 +192,6 @@ class CssLoadingRuntimeModule extends RuntimeModule {
166192 "installedChunks[chunkId] = 0;"
167193 ] ) } `,
168194 'var loadingAttribute = "data-webpack-loading";' ,
169- uniqueName
170- ? `var dataWebpackPrefix = ${ JSON . stringify ( uniqueName + ":" ) } ;`
171- : "// data-webpack is not used as build has no uniqueName" ,
172195 `var loadStylesheet = ${ runtimeTemplate . basicFunction (
173196 "chunkId, url, done" + ( withHmr ? ", hmr" : "" ) ,
174197 [
@@ -180,7 +203,7 @@ class CssLoadingRuntimeModule extends RuntimeModule {
180203 "var l = links[i];" ,
181204 `if(l.getAttribute("href") == url${
182205 uniqueName
183- ? ' || l.getAttribute("data-webpack") == dataWebpackPrefix + key'
206+ ? ' || l.getAttribute("data-webpack") == uniqueName + ":" + key'
184207 : ""
185208 } ) { link = l; break; }`
186209 ] ) ,
0 commit comments