DependencyTemplate.js 2.4 KB

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