DependencyTemplate.js 2.8 KB

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