WXL
3 天以前 9bce51f651aad297ef9eb6df832bfdaf1de05d84
node_modules/webpack/lib/container/FallbackModule.js
@@ -7,7 +7,10 @@
const { RawSource } = require("webpack-sources");
const Module = require("../Module");
const { JS_TYPES } = require("../ModuleSourceTypesConstants");
const {
   JAVASCRIPT_TYPE,
   JAVASCRIPT_TYPES
} = require("../ModuleSourceTypeConstants");
const { WEBPACK_MODULE_TYPE_FALLBACK } = require("../ModuleTypeConstants");
const RuntimeGlobals = require("../RuntimeGlobals");
const Template = require("../Template");
@@ -25,6 +28,7 @@
/** @typedef {import("../Module").NameForCondition} NameForCondition */
/** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */
/** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */
/** @typedef {import("../Module").Sources} Sources */
/** @typedef {import("../Module").SourceTypes} SourceTypes */
/** @typedef {import("../RequestShortener")} RequestShortener */
/** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
@@ -37,15 +41,19 @@
class FallbackModule extends Module {
   /**
    * Creates an instance of FallbackModule.
    * @param {ExternalRequests} requests list of requests to choose one
    */
   constructor(requests) {
      super(WEBPACK_MODULE_TYPE_FALLBACK);
      /** @type {ExternalRequests} */
      this.requests = requests;
      /** @type {string} */
      this._identifier = `fallback ${this.requests.join(" ")}`;
   }
   /**
    * Returns the unique identifier used to reference this module.
    * @returns {string} a unique identifier of the module
    */
   identifier() {
@@ -53,6 +61,7 @@
   }
   /**
    * Returns a human-readable identifier for this module.
    * @param {RequestShortener} requestShortener the request shortener
    * @returns {string} a user readable identifier of the module
    */
@@ -61,6 +70,7 @@
   }
   /**
    * Gets the library identifier.
    * @param {LibIdentOptions} options options
    * @returns {LibIdent | null} an identifier for library inclusion
    */
@@ -71,15 +81,17 @@
   }
   /**
    * Returns true if the module can be placed in the chunk.
    * @param {Chunk} chunk the chunk which condition should be checked
    * @param {Compilation} compilation the compilation
    * @returns {boolean} true, if the chunk is ok for the module
    * @returns {boolean} true if the module can be placed in the chunk
    */
   chunkCondition(chunk, { chunkGraph }) {
      return chunkGraph.getNumberOfEntryModules(chunk) > 0;
   }
   /**
    * Checks whether the module needs to be rebuilt for the current build state.
    * @param {NeedBuildContext} context context info
    * @param {NeedBuildCallback} callback callback function, returns true, if the module needs a rebuild
    * @returns {void}
@@ -89,6 +101,7 @@
   }
   /**
    * Builds the module using the provided compilation context.
    * @param {WebpackOptions} options webpack options
    * @param {Compilation} compilation the compilation
    * @param {ResolverWithOptions} resolver the resolver
@@ -111,6 +124,7 @@
   }
   /**
    * Returns the estimated size for the requested source type.
    * @param {string=} type the source type for which the size should be estimated
    * @returns {number} the estimated size of the module (must be non-zero)
    */
@@ -119,13 +133,15 @@
   }
   /**
    * Returns the source types this module can generate.
    * @returns {SourceTypes} types available (do not mutate)
    */
   getSourceTypes() {
      return JS_TYPES;
      return JAVASCRIPT_TYPES;
   }
   /**
    * Generates code and runtime requirements for this module.
    * @param {CodeGenerationContext} context context for code generation
    * @returns {CodeGenerationResult} result
    */
@@ -155,12 +171,14 @@
         ])};`,
         "module.exports = loop();"
      ]);
      /** @type {Sources} */
      const sources = new Map();
      sources.set("javascript", new RawSource(code));
      sources.set(JAVASCRIPT_TYPE, new RawSource(code));
      return { sources, runtimeRequirements: RUNTIME_REQUIREMENTS };
   }
   /**
    * Serializes this instance into the provided serializer context.
    * @param {ObjectSerializerContext} context context
    */
   serialize(context) {
@@ -170,6 +188,7 @@
   }
   /**
    * Restores this instance from the provided deserializer context.
    * @param {ObjectDeserializerContext} context context
    * @returns {FallbackModule} deserialized fallback module
    */