| | |
| | | const { RawSource, ReplaceSource } = require("webpack-sources"); |
| | | const Generator = require("../Generator"); |
| | | const InitFragment = require("../InitFragment"); |
| | | const { JS_TYPES } = require("../ModuleSourceTypesConstants"); |
| | | const { JAVASCRIPT_TYPES } = require("../ModuleSourceTypeConstants"); |
| | | const HarmonyCompatibilityDependency = require("../dependencies/HarmonyCompatibilityDependency"); |
| | | |
| | | /** @typedef {import("webpack-sources").Source} Source */ |
| | |
| | | /** @typedef {import("../Generator").GenerateContext} GenerateContext */ |
| | | /** @typedef {import("../Module")} Module */ |
| | | /** @typedef {import("../Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */ |
| | | /** @typedef {import("../Module").SourceType} SourceType */ |
| | | /** @typedef {import("../Module").SourceTypes} SourceTypes */ |
| | | /** @typedef {import("../NormalModule")} NormalModule */ |
| | | |
| | |
| | | return new RawSource("throw new Error('No source available');"); |
| | | }, |
| | | /** |
| | | * Returns the estimated size for the requested source type. |
| | | * @returns {number} size of the DEFAULT_SOURCE.source() |
| | | */ |
| | | size() { |
| | |
| | | |
| | | const deprecatedGetInitFragments = util.deprecate( |
| | | /** |
| | | * Handles the callback logic for this hook. |
| | | * @param {DependencyTemplate} template template |
| | | * @param {Dependency} dependency dependency |
| | | * @param {DependencyTemplateContext} templateContext template context |
| | |
| | | |
| | | class JavascriptGenerator extends Generator { |
| | | /** |
| | | * Returns the source types available for this module. |
| | | * @param {NormalModule} module fresh module |
| | | * @returns {SourceTypes} available types (do not mutate) |
| | | */ |
| | | getTypes(module) { |
| | | return JS_TYPES; |
| | | return JAVASCRIPT_TYPES; |
| | | } |
| | | |
| | | /** |
| | | * Returns the estimated size for the requested source type. |
| | | * @param {NormalModule} module the module |
| | | * @param {string=} type source type |
| | | * @param {SourceType=} type source type |
| | | * @returns {number} estimate size of the module |
| | | */ |
| | | getSize(module, type) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the reason this module cannot be concatenated, when one exists. |
| | | * @param {NormalModule} module module for which the bailout reason should be determined |
| | | * @param {ConcatenationBailoutReasonContext} context context |
| | | * @returns {string | undefined} reason why this module can't be concatenated, undefined when it can be concatenated |
| | |
| | | } |
| | | |
| | | /** |
| | | * Processes the provided module. |
| | | * @param {Module} module the current module |
| | | * @param {Dependency} dependency the dependency to generate |
| | | * @param {InitFragment<GenerateContext>[]} initFragments mutable list of init fragments |
| | |
| | | } |
| | | |
| | | /** |
| | | * Processes the provided module. |
| | | * @param {Module} module the module to generate |
| | | * @param {DependenciesBlock} block the dependencies block which will be processed |
| | | * @param {InitFragment<GenerateContext>[]} initFragments mutable list of init fragments |
| | |
| | | } |
| | | |
| | | /** |
| | | * Processes the provided module. |
| | | * @param {Module} module the module to generate |
| | | * @param {InitFragment<GenerateContext>[]} initFragments mutable list of init fragments |
| | | * @param {ReplaceSource} source the current replace source which can be modified |
| | |
| | | } |
| | | |
| | | /** |
| | | * Generates generated code for this runtime module. |
| | | * @param {NormalModule} module module for which the code should be generated |
| | | * @param {GenerateContext} generateContext context for generate |
| | | * @returns {Source | null} generated code |
| | |
| | | } |
| | | |
| | | /** |
| | | * Generates fallback output for the provided error condition. |
| | | * @param {Error} error the error |
| | | * @param {NormalModule} module module for which the code should be generated |
| | | * @param {GenerateContext} generateContext context for generate |