DependencyTemplate.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. /** @typedef {import("./Module")} Module */
  15. /** @typedef {import("./Module").RuntimeRequirements} RuntimeRequirements */
  16. /** @typedef {import("./ModuleGraph")} ModuleGraph */
  17. /** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
  18. /**
  19. * @template T
  20. * @typedef {import("./InitFragment")<T>} InitFragment
  21. */
  22. /**
  23. * @typedef {Object} DependencyTemplateContext
  24. * @property {RuntimeTemplate} runtimeTemplate the runtime template
  25. * @property {DependencyTemplates} dependencyTemplates the dependency templates
  26. * @property {ModuleGraph} moduleGraph the module graph
  27. * @property {ChunkGraph} chunkGraph the chunk graph
  28. * @property {RuntimeRequirements} runtimeRequirements the requirements for runtime
  29. * @property {Module} module current module
  30. * @property {RuntimeSpec} runtime current runtime, for which code is generated
  31. * @property {RuntimeSpec[]} [runtimes] current runtimes, for which code is generated
  32. * @property {InitFragment<GenerateContext>[]} initFragments mutable array of init fragments for the current module
  33. * @property {ConcatenationScope=} concatenationScope when in a concatenated module, information about other concatenated modules
  34. * @property {CodeGenerationResults} codeGenerationResults the code generation results
  35. * @property {InitFragment<GenerateContext>[]} chunkInitFragments chunkInitFragments
  36. */
  37. /**
  38. * @typedef {Object} CssDependencyTemplateContextExtras
  39. * @property {Map<string, string>} cssExports the css exports
  40. */
  41. /** @typedef {DependencyTemplateContext & CssDependencyTemplateContextExtras} CssDependencyTemplateContext */
  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. module.exports = DependencyTemplate;