| | |
| | | const Dependency = require("../Dependency"); |
| | | const Module = require("../Module"); |
| | | const ModuleFactory = require("../ModuleFactory"); |
| | | const { JS_TYPES } = require("../ModuleSourceTypesConstants"); |
| | | const { JAVASCRIPT_TYPES } = require("../ModuleSourceTypeConstants"); |
| | | const { JAVASCRIPT_TYPE } = require("../ModuleSourceTypeConstants"); |
| | | const { |
| | | WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY |
| | | } = require("../ModuleTypeConstants"); |
| | |
| | | /** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */ |
| | | /** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */ |
| | | /** @typedef {import("../Module").SourceTypes} SourceTypes */ |
| | | /** @typedef {import("../Module").Sources} Sources */ |
| | | /** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */ |
| | | /** @typedef {import("../ModuleFactory").ModuleFactoryCallback} ModuleFactoryCallback */ |
| | | /** @typedef {import("../ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */ |
| | | /** @typedef {import("../RequestShortener")} RequestShortener */ |
| | |
| | | /** @typedef {{ client: string, data: string, active: boolean }} ModuleResult */ |
| | | |
| | | /** |
| | | * Defines the backend api type used by this module. |
| | | * @typedef {object} BackendApi |
| | | * @property {(callback: (err?: (Error | null)) => void) => void} dispose |
| | | * @property {(module: Module) => ModuleResult} module |
| | |
| | | ]); |
| | | |
| | | /** |
| | | * Checks true, if the module should be selected. |
| | | * @param {Options["test"]} test test option |
| | | * @param {Module} module the module |
| | | * @returns {boolean | null | string} true, if the module should be selected |
| | |
| | | |
| | | class LazyCompilationDependency extends Dependency { |
| | | /** |
| | | * Creates an instance of LazyCompilationDependency. |
| | | * @param {LazyCompilationProxyModule} proxyModule proxy module |
| | | */ |
| | | constructor(proxyModule) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns an identifier to merge equal requests. |
| | | * @returns {string | null} an identifier to merge equal requests |
| | | */ |
| | | getResourceIdentifier() { |
| | |
| | | |
| | | class LazyCompilationProxyModule extends Module { |
| | | /** |
| | | * Creates an instance of LazyCompilationProxyModule. |
| | | * @param {string} context context |
| | | * @param {Module} originalModule an original module |
| | | * @param {string} request request |
| | |
| | | } |
| | | |
| | | /** |
| | | * 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 |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * 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 source types this module can generate. |
| | | * @returns {SourceTypes} types available (do not mutate) |
| | | */ |
| | | getSourceTypes() { |
| | | return JS_TYPES; |
| | | return JAVASCRIPT_TYPES; |
| | | } |
| | | |
| | | /** |
| | | * 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) |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Generates code and runtime requirements for this module. |
| | | * @param {CodeGenerationContext} context context for code generation |
| | | * @returns {CodeGenerationResult} result |
| | | */ |
| | | codeGeneration({ runtimeTemplate, chunkGraph, moduleGraph }) { |
| | | /** @type {Sources} */ |
| | | const sources = new Map(); |
| | | /** @type {RuntimeRequirements} */ |
| | | const runtimeRequirements = new Set(); |
| | | runtimeRequirements.add(RuntimeGlobals.module); |
| | | const clientDep = /** @type {CommonJsRequireDependency} */ ( |
| | |
| | | Boolean(block) |
| | | )}, module: module, onError: onError });` |
| | | ]); |
| | | /** @type {string} */ |
| | | let source; |
| | | if (block) { |
| | | const dep = block.dependencies[0]; |
| | |
| | | keepActive |
| | | ]); |
| | | } |
| | | sources.set("javascript", new RawSource(source)); |
| | | sources.set(JAVASCRIPT_TYPE, new RawSource(source)); |
| | | return { |
| | | sources, |
| | | runtimeRequirements |
| | |
| | | } |
| | | |
| | | /** |
| | | * Updates the hash with the data contributed by this instance. |
| | | * @param {Hash} hash the hash used to track dependencies |
| | | * @param {UpdateHashContext} context context |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Processes the provided data. |
| | | * @param {ModuleFactoryCreateData} data data object |
| | | * @param {ModuleFactoryCallback} callback callback |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Defines the backend handler callback. |
| | | * @callback BackendHandler |
| | | * @param {Compiler} compiler compiler |
| | | * @param {(err: Error | null, backendApi?: BackendApi) => void} callback callback |
| | |
| | | */ |
| | | |
| | | /** |
| | | * Defines the promise backend handler callback. |
| | | * @callback PromiseBackendHandler |
| | | * @param {Compiler} compiler compiler |
| | | * @returns {Promise<BackendApi>} backend |
| | |
| | | /** @typedef {(module: Module) => boolean} TestFn */ |
| | | |
| | | /** |
| | | * Defines the options type used by this module. |
| | | * @typedef {object} Options options |
| | | * @property {BackEnd} backend the backend |
| | | * @property {boolean=} entries |
| | |
| | | |
| | | class LazyCompilationPlugin { |
| | | /** |
| | | * Creates an instance of LazyCompilationPlugin. |
| | | * @param {Options} options options |
| | | */ |
| | | constructor({ backend, entries, imports, test }) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Apply the plugin |
| | | * Applies the plugin by registering its hooks on the compiler. |
| | | * @param {Compiler} compiler the compiler instance |
| | | * @returns {void} |
| | | */ |