DependencyTemplate.js (2493B)
1 /* 2 MIT License http://www.opensource.org/licenses/mit-license.php 3 Author Tobias Koppers @sokra 4 */ 5 6 "use strict"; 7 8 /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */ 9 /** @typedef {import("./ChunkGraph")} ChunkGraph */ 10 /** @typedef {import("./CodeGenerationResults")} CodeGenerationResults */ 11 /** @typedef {import("./ConcatenationScope")} ConcatenationScope */ 12 /** @typedef {import("./Dependency")} Dependency */ 13 /** @typedef {import("./Dependency").RuntimeSpec} RuntimeSpec */ 14 /** @typedef {import("./DependencyTemplates")} DependencyTemplates */ 15 /** @typedef {import("./Generator").GenerateContext} GenerateContext */ 16 /** @template T @typedef {import("./InitFragment")<T>} InitFragment */ 17 /** @typedef {import("./Module")} Module */ 18 /** @typedef {import("./ModuleGraph")} ModuleGraph */ 19 /** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */ 20 21 /** 22 * @typedef {Object} DependencyTemplateContext 23 * @property {RuntimeTemplate} runtimeTemplate the runtime template 24 * @property {DependencyTemplates} dependencyTemplates the dependency templates 25 * @property {ModuleGraph} moduleGraph the module graph 26 * @property {ChunkGraph} chunkGraph the chunk graph 27 * @property {Set<string>} runtimeRequirements the requirements for runtime 28 * @property {Module} module current module 29 * @property {RuntimeSpec} runtime current runtimes, for which code is generated 30 * @property {InitFragment<GenerateContext>[]} initFragments mutable array of init fragments for the current module 31 * @property {ConcatenationScope=} concatenationScope when in a concatenated module, information about other concatenated modules 32 * @property {CodeGenerationResults} codeGenerationResults the code generation results 33 */ 34 35 /** 36 * @typedef {Object} CssDependencyTemplateContextExtras 37 * @property {Map<string, string>} cssExports the css exports 38 */ 39 40 /** @typedef {DependencyTemplateContext & CssDependencyTemplateContextExtras} CssDependencyTemplateContext */ 41 42 class DependencyTemplate { 43 /* istanbul ignore next */ 44 /** 45 * @abstract 46 * @param {Dependency} dependency the dependency for which the template should be applied 47 * @param {ReplaceSource} source the current replace source which can be modified 48 * @param {DependencyTemplateContext} templateContext the context object 49 * @returns {void} 50 */ 51 apply(dependency, source, templateContext) { 52 const AbstractMethodError = require("./AbstractMethodError"); 53 throw new AbstractMethodError(); 54 } 55 } 56 57 module.exports = DependencyTemplate;