DependencyTemplate.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 runtime, for which code is generated
  27. * @property {RuntimeSpec[]} [runtimes] current runtimes, for which code is generated
  28. * @property {InitFragment<GenerateContext>[]} initFragments mutable array of init fragments for the current module
  29. * @property {ConcatenationScope=} concatenationScope when in a concatenated module, information about other concatenated modules
  30. * @property {CodeGenerationResults} codeGenerationResults the code generation results
  31. * @property {InitFragment<GenerateContext>[]} chunkInitFragments chunkInitFragments
  32. */
  33. /**
  34. * @typedef {Object} CssDependencyTemplateContextExtras
  35. * @property {Map<string, string>} cssExports the css exports
  36. */
  37. /** @typedef {DependencyTemplateContext & CssDependencyTemplateContextExtras} CssDependencyTemplateContext */
  38. class DependencyTemplate {
  39. /* istanbul ignore next */
  40. /**
  41. * @abstract
  42. * @param {Dependency} dependency the dependency for which the template should be applied
  43. * @param {ReplaceSource} source the current replace source which can be modified
  44. * @param {DependencyTemplateContext} templateContext the context object
  45. * @returns {void}
  46. */
  47. apply(dependency, source, templateContext) {
  48. const AbstractMethodError = require("./AbstractMethodError");
  49. throw new AbstractMethodError();
  50. }
  51. }
  52. module.exports = DependencyTemplate;