feat: refactoring project
This commit is contained in:
33
node_modules/webpack/lib/css/CssLoadingRuntimeModule.js
generated
vendored
33
node_modules/webpack/lib/css/CssLoadingRuntimeModule.js
generated
vendored
@@ -86,19 +86,13 @@ class CssLoadingRuntimeModule extends RuntimeModule {
|
||||
* @returns {boolean} true, if the chunk has css
|
||||
*/
|
||||
(chunk, chunkGraph) =>
|
||||
!!chunkGraph.getChunkModulesIterableBySourceType(chunk, "css")
|
||||
Boolean(chunkGraph.getChunkModulesIterableBySourceType(chunk, "css"))
|
||||
);
|
||||
const hasCssMatcher = compileBooleanMatcher(conditionMap);
|
||||
|
||||
const withLoading =
|
||||
_runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers) &&
|
||||
hasCssMatcher !== false;
|
||||
const withPrefetch = this._runtimeRequirements.has(
|
||||
RuntimeGlobals.prefetchChunkHandlers
|
||||
);
|
||||
const withPreload = this._runtimeRequirements.has(
|
||||
RuntimeGlobals.preloadChunkHandlers
|
||||
);
|
||||
/** @type {boolean} */
|
||||
const withHmr = _runtimeRequirements.has(
|
||||
RuntimeGlobals.hmrDownloadUpdateHandlers
|
||||
@@ -118,6 +112,13 @@ class CssLoadingRuntimeModule extends RuntimeModule {
|
||||
return null;
|
||||
}
|
||||
|
||||
const withPrefetch =
|
||||
this._runtimeRequirements.has(RuntimeGlobals.prefetchChunkHandlers) &&
|
||||
chunk.hasChildByOrder(chunkGraph, "prefetch", true, chunkHasCss);
|
||||
const withPreload =
|
||||
this._runtimeRequirements.has(RuntimeGlobals.preloadChunkHandlers) &&
|
||||
chunk.hasChildByOrder(chunkGraph, "preload", true, chunkHasCss);
|
||||
|
||||
const { linkPreload, linkPrefetch } =
|
||||
CssLoadingRuntimeModule.getCompilationHooks(compilation);
|
||||
|
||||
@@ -210,7 +211,7 @@ class CssLoadingRuntimeModule extends RuntimeModule {
|
||||
Template.indent([
|
||||
"var style = cssRules[j--].style;",
|
||||
"if(!style) continue;",
|
||||
`data = style.getPropertyValue(name);`
|
||||
"data = style.getPropertyValue(name);"
|
||||
]),
|
||||
"}"
|
||||
]),
|
||||
@@ -224,7 +225,7 @@ class CssLoadingRuntimeModule extends RuntimeModule {
|
||||
withCompression
|
||||
? Template.asString([
|
||||
// LZW decode
|
||||
`var map = {}, char = data[0], oldPhrase = char, decoded = char, code = 256, maxCode = ${"\uffff".charCodeAt(
|
||||
`var map = {}, char = data[0], oldPhrase = char, decoded = char, code = 256, maxCode = ${"\uFFFF".charCodeAt(
|
||||
0
|
||||
)}, phrase;`,
|
||||
"for (i = 1; i < data.length; i++) {",
|
||||
@@ -255,12 +256,12 @@ class CssLoadingRuntimeModule extends RuntimeModule {
|
||||
","
|
||||
)}) { token = token.replace(/^_/, ""); target[token] = (${runtimeTemplate.basicFunction(
|
||||
"exports, module",
|
||||
`module.exports = exports;`
|
||||
"module.exports = exports;"
|
||||
)}).bind(null, exports); ${
|
||||
withHmr ? "moduleIds.push(token); " : ""
|
||||
}token = ""; token2 = ""; exports = {}; }`,
|
||||
`else if(cc == ${cc("\\")}) { token += data[++i] }`,
|
||||
`else { token += data[i]; }`
|
||||
"else { token += data[i]; }"
|
||||
]),
|
||||
"}",
|
||||
`${
|
||||
@@ -271,9 +272,9 @@ class CssLoadingRuntimeModule extends RuntimeModule {
|
||||
)}`,
|
||||
'var loadingAttribute = "data-webpack-loading";',
|
||||
`var loadStylesheet = ${runtimeTemplate.basicFunction(
|
||||
"chunkId, url, done" +
|
||||
(withHmr ? ", hmr" : "") +
|
||||
(withFetchPriority ? ", fetchPriority" : ""),
|
||||
`chunkId, url, done${withHmr ? ", hmr" : ""}${
|
||||
withFetchPriority ? ", fetchPriority" : ""
|
||||
}`,
|
||||
[
|
||||
'var link, needAttach, key = "chunk-" + chunkId;',
|
||||
withHmr ? "if(!hmr) {" : "",
|
||||
@@ -360,7 +361,7 @@ class CssLoadingRuntimeModule extends RuntimeModule {
|
||||
Template.indent([
|
||||
"// setup Promise in chunk cache",
|
||||
`var promise = new Promise(${runtimeTemplate.expressionFunction(
|
||||
`installedChunkData = installedChunks[chunkId] = [resolve, reject]`,
|
||||
"installedChunkData = installedChunks[chunkId] = [resolve, reject]",
|
||||
"resolve, reject"
|
||||
)});`,
|
||||
"promises.push(installedChunkData[2] = promise);",
|
||||
@@ -516,7 +517,7 @@ class CssLoadingRuntimeModule extends RuntimeModule {
|
||||
"}",
|
||||
"while(newTags.length) {",
|
||||
Template.indent([
|
||||
`var info = newTags.pop();`,
|
||||
"var info = newTags.pop();",
|
||||
`var chunkModuleIds = loadCssChunkData(${RuntimeGlobals.moduleFactories}, info[1], info[0]);`,
|
||||
`chunkModuleIds.forEach(${runtimeTemplate.expressionFunction(
|
||||
"moduleIds.push(id)",
|
||||
|
||||
Reference in New Issue
Block a user