WXL
3 天以前 3bd962a6d7f61239c020e2dbbeb7341e5b842dd1
node_modules/webpack/lib/dependencies/CssUrlDependency.js
@@ -13,9 +13,10 @@
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
/** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
/** @typedef {import("../Dependency")} Dependency */
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
/** @typedef {import("../DependencyTemplate").CssDependencyTemplateContext} DependencyTemplateContext */
/** @typedef {import("../Module")} Module */
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
/** @typedef {import("../Module").CodeGenerationResultData} CodeGenerationResultData */
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
@@ -27,6 +28,7 @@
class CssUrlDependency extends ModuleDependency {
   /**
    * Creates an instance of CssUrlDependency.
    * @param {string} request request
    * @param {Range} range range of the argument
    * @param {"string" | "url" | "src"} urlType dependency type e.g. url() or string
@@ -46,6 +48,7 @@
   }
   /**
    * Creates an ignored module.
    * @param {string} context context directory
    * @returns {Module} ignored module
    */
@@ -54,6 +57,7 @@
   }
   /**
    * Serializes this instance into the provided serializer context.
    * @param {ObjectSerializerContext} context context
    */
   serialize(context) {
@@ -63,6 +67,7 @@
   }
   /**
    * Restores this instance from the provided deserializer context.
    * @param {ObjectDeserializerContext} context context
    */
   deserialize(context) {
@@ -73,6 +78,7 @@
}
/**
 * Returns string in quotes if needed.
 * @param {string} str string
 * @returns {string} string in quotes if needed
 */
@@ -110,6 +116,7 @@
   ModuleDependency.Template
) {
   /**
    * Applies the plugin by registering its hooks on the compiler.
    * @param {Dependency} dependency the dependency for which the template should be applied
    * @param {ReplaceSource} source the current replace source which can be modified
    * @param {DependencyTemplateContext} templateContext the context object
@@ -118,8 +125,9 @@
   apply(
      dependency,
      source,
      { moduleGraph, runtimeTemplate, codeGenerationResults }
      { type, moduleGraph, runtimeTemplate, codeGenerationResults }
   ) {
      if (type === "javascript") return;
      const dep = /** @type {CssUrlDependency} */ (dependency);
      const module = /** @type {Module} */ (moduleGraph.getModule(dep));
@@ -161,6 +169,7 @@
   }
   /**
    * Returns the url of the asset.
    * @param {object} options options object
    * @param {Module} options.module the module
    * @param {RuntimeSpec=} options.runtime runtime
@@ -172,9 +181,7 @@
         return "data:,";
      }
      const codeGen = codeGenerationResults.get(module, runtime);
      const data =
         /** @type {NonNullable<CodeGenerationResult["data"]>} */
         (codeGen.data);
      const data = codeGen.data;
      if (!data) return "data:,";
      const url = data.get("url");
      if (!url || !url["css-url"]) return "data:,";