From 9bce51f651aad297ef9eb6df832bfdaf1de05d84 Mon Sep 17 00:00:00 2001
From: WXL <wl_5969728@163.com>
Date: 星期三, 22 四月 2026 14:27:54 +0800
Subject: [PATCH] 青岛推送
---
node_modules/webpack/lib/css/CssLoadingRuntimeModule.js | 22 ++++++++++++++--------
1 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/node_modules/webpack/lib/css/CssLoadingRuntimeModule.js b/node_modules/webpack/lib/css/CssLoadingRuntimeModule.js
index 278d143..4a1da53 100644
--- a/node_modules/webpack/lib/css/CssLoadingRuntimeModule.js
+++ b/node_modules/webpack/lib/css/CssLoadingRuntimeModule.js
@@ -7,6 +7,7 @@
const { SyncWaterfallHook } = require("tapable");
const Compilation = require("../Compilation");
+const { CSS_TYPE } = require("../ModuleSourceTypeConstants");
const RuntimeGlobals = require("../RuntimeGlobals");
const RuntimeModule = require("../RuntimeModule");
const Template = require("../Template");
@@ -61,6 +62,7 @@
}
/**
+ * Generates runtime code for this runtime module.
* @returns {string | null} runtime code
*/
generate() {
@@ -86,7 +88,7 @@
* @returns {boolean} true, if the chunk has css
*/
(chunk, chunkGraph) =>
- Boolean(chunkGraph.getChunkModulesIterableBySourceType(chunk, "css"))
+ Boolean(chunkGraph.getChunkModulesIterableBySourceType(chunk, CSS_TYPE))
);
const hasCssMatcher = compileBooleanMatcher(conditionMap);
@@ -120,15 +122,12 @@
(environment.document || isNeutralPlatform) &&
chunk.hasChildByOrder(chunkGraph, "preload", true, chunkHasCss);
- const { linkPreload, linkPrefetch } =
+ const { linkPreload, linkPrefetch, createStylesheet } =
CssLoadingRuntimeModule.getCompilationHooks(compilation);
const withFetchPriority = _runtimeRequirements.has(
RuntimeGlobals.hasFetchPriority
);
-
- const { createStylesheet } =
- CssLoadingRuntimeModule.getCompilationHooks(compilation);
const stateExpression = withHmr
? `${RuntimeGlobals.hmrRuntimeStatePrefix}_css`
@@ -429,7 +428,7 @@
"while(oldTags.length) {",
Template.indent([
"var oldTag = oldTags.pop();",
- "if(oldTag.parentNode) oldTag.parentNode.removeChild(oldTag);"
+ "if(oldTag && oldTag.parentNode) oldTag.parentNode.removeChild(oldTag);"
]),
"}"
])}, apply: ${runtimeTemplate.basicFunction("", [
@@ -451,17 +450,24 @@
`${
RuntimeGlobals.hmrDownloadUpdateHandlers
}.css = ${runtimeTemplate.basicFunction(
- "chunkIds, removedChunks, removedModules, promises, applyHandlers, updatedModulesList",
+ "chunkIds, removedChunks, removedModules, promises, applyHandlers, updatedModulesList, css",
[
isNeutralPlatform
? "if (typeof document === 'undefined') return;"
: "",
"applyHandlers.push(applyHandler);",
+ "// Read CSS removed chunks from update manifest",
+ "var cssRemovedChunks = css && css.r;",
`chunkIds.forEach(${runtimeTemplate.basicFunction("chunkId", [
`var filename = ${RuntimeGlobals.getChunkCssFilename}(chunkId);`,
`var url = ${RuntimeGlobals.publicPath} + filename;`,
"var oldTag = loadStylesheet(chunkId, url);",
- "if(!oldTag) return;",
+ `if(!oldTag && !${withHmr} ) return;`,
+ "// Skip if CSS was removed",
+ "if(cssRemovedChunks && cssRemovedChunks.indexOf(chunkId) >= 0) {",
+ Template.indent(["oldTags.push(oldTag);", "return;"]),
+ "}",
+ "",
"// create error before stack unwound to get useful stacktrace later",
"var error = new Error();",
`promises.push(new Promise(${runtimeTemplate.basicFunction(
--
Gitblit v1.9.3