UNPKG

1.99 kBJavaScriptView Raw
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("./ConcatenationScope")} ConcatenationScope */
11/** @typedef {import("./Dependency")} Dependency */
12/** @typedef {import("./Dependency").RuntimeSpec} RuntimeSpec */
13/** @typedef {import("./DependencyTemplates")} DependencyTemplates */
14/** @typedef {import("./InitFragment")} InitFragment */
15/** @typedef {import("./Module")} Module */
16/** @typedef {import("./ModuleGraph")} ModuleGraph */
17/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
18
19/**
20 * @typedef {Object} DependencyTemplateContext
21 * @property {RuntimeTemplate} runtimeTemplate the runtime template
22 * @property {DependencyTemplates} dependencyTemplates the dependency templates
23 * @property {ModuleGraph} moduleGraph the module graph
24 * @property {ChunkGraph} chunkGraph the chunk graph
25 * @property {Set<string>} runtimeRequirements the requirements for runtime
26 * @property {Module} module current module
27 * @property {RuntimeSpec} runtime current runtimes, for which code is generated
28 * @property {InitFragment[]} 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 */
31
32class DependencyTemplate {
33 /* istanbul ignore next */
34 /**
35 * @abstract
36 * @param {Dependency} dependency the dependency for which the template should be applied
37 * @param {ReplaceSource} source the current replace source which can be modified
38 * @param {DependencyTemplateContext} templateContext the context object
39 * @returns {void}
40 */
41 apply(dependency, source, templateContext) {
42 const AbstractMethodError = require("./AbstractMethodError");
43 throw new AbstractMethodError();
44 }
45}
46
47module.exports = DependencyTemplate;