MCPcopy
hub / github.com/webpack/webpack / constructor

Method constructor

lib/ModuleTemplate.js:39–165  ·  view source on GitHub ↗

* Creates an instance of ModuleTemplate. * @param {RuntimeTemplate} runtimeTemplate the runtime template * @param {Compilation} compilation the compilation

(runtimeTemplate, compilation)

Source from the content-addressed store, hash-verified

37 * @param {Compilation} compilation the compilation
38 */
39 constructor(runtimeTemplate, compilation) {
40 /** @type {RuntimeTemplate} */
41 this._runtimeTemplate = runtimeTemplate;
42 /** @type {string} */
43 this.type = "javascript";
44 this.hooks = Object.freeze({
45 content: {
46 tap: util.deprecate(
47 /**
48 * Handles the callback logic for this hook.
49 * @template AdditionalOptions
50 * @param {string | Tap & IfSet<AdditionalOptions>} options options
51 * @param {(source: Source, module: Module, moduleRenderContext: ModuleRenderContext, dependencyTemplates: DependencyTemplates) => Source} fn fn
52 */
53 (options, fn) => {
54 getJavascriptModulesPlugin()
55 .getCompilationHooks(compilation)
56 .renderModuleContent.tap(
57 options,
58 (source, module, renderContext) =>
59 fn(
60 source,
61 module,
62 renderContext,
63 renderContext.dependencyTemplates
64 )
65 );
66 },
67 "ModuleTemplate.hooks.content is deprecated (use JavascriptModulesPlugin.getCompilationHooks().renderModuleContent instead)",
68 "DEP_MODULE_TEMPLATE_CONTENT"
69 )
70 },
71 module: {
72 tap: util.deprecate(
73 /**
74 * Handles the callback logic for this hook.
75 * @template AdditionalOptions
76 * @param {string | Tap & IfSet<AdditionalOptions>} options options
77 * @param {(source: Source, module: Module, moduleRenderContext: ModuleRenderContext, dependencyTemplates: DependencyTemplates) => Source} fn fn
78 */
79 (options, fn) => {
80 getJavascriptModulesPlugin()
81 .getCompilationHooks(compilation)
82 .renderModuleContent.tap(
83 options,
84 (source, module, renderContext) =>
85 fn(
86 source,
87 module,
88 renderContext,
89 renderContext.dependencyTemplates
90 )
91 );
92 },
93 "ModuleTemplate.hooks.module is deprecated (use JavascriptModulesPlugin.getCompilationHooks().renderModuleContent instead)",
94 "DEP_MODULE_TEMPLATE_MODULE"
95 )
96 },

Callers

nothing calls this directly

Calls 4

freezeMethod · 0.80
tapMethod · 0.80
fnFunction · 0.50
getCompilationHooksMethod · 0.45

Tested by

no test coverage detected