| | |
| | | |
| | | 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"); |
| | |
| | | /** @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 */ |
| | |
| | | |
| | | 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() { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns a human-readable identifier for this module. |
| | | * @param {RequestShortener} requestShortener the request shortener |
| | | * @returns {string} a user readable identifier of the module |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets the library identifier. |
| | | * @param {LibIdentOptions} options options |
| | | * @returns {LibIdent | null} an identifier for library inclusion |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * 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} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Builds the module using the provided compilation context. |
| | | * @param {WebpackOptions} options webpack options |
| | | * @param {Compilation} compilation the compilation |
| | | * @param {ResolverWithOptions} resolver the resolver |
| | |
| | | } |
| | | |
| | | /** |
| | | * 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) |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * 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 |
| | | */ |
| | |
| | | ])};`, |
| | | "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) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Restores this instance from the provided deserializer context. |
| | | * @param {ObjectDeserializerContext} context context |
| | | * @returns {FallbackModule} deserialized fallback module |
| | | */ |