source: imaps-frontend/node_modules/webpack/lib/ModuleTemplate.js

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 5.2 KB
Line 
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5
6"use strict";
7
8const util = require("util");
9const memoize = require("./util/memoize");
10
11/** @typedef {import("tapable").Tap} Tap */
12/** @typedef {import("webpack-sources").Source} Source */
13/** @typedef {import("./Chunk")} Chunk */
14/** @typedef {import("./ChunkGraph")} ChunkGraph */
15/** @typedef {import("./Compilation")} Compilation */
16/** @typedef {import("./DependencyTemplates")} DependencyTemplates */
17/** @typedef {import("./Module")} Module */
18/** @typedef {import("./ModuleGraph")} ModuleGraph */
19/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
20/** @typedef {import("./javascript/JavascriptModulesPlugin").ChunkRenderContext} ChunkRenderContext */
21/** @typedef {import("./util/Hash")} Hash */
22
23/**
24 * @template T
25 * @typedef {import("tapable").IfSet<T>} IfSet
26 */
27
28const getJavascriptModulesPlugin = memoize(() =>
29 require("./javascript/JavascriptModulesPlugin")
30);
31
32// TODO webpack 6: remove this class
33class ModuleTemplate {
34 /**
35 * @param {RuntimeTemplate} runtimeTemplate the runtime template
36 * @param {Compilation} compilation the compilation
37 */
38 constructor(runtimeTemplate, compilation) {
39 this._runtimeTemplate = runtimeTemplate;
40 this.type = "javascript";
41 this.hooks = Object.freeze({
42 content: {
43 tap: util.deprecate(
44 /**
45 * @template AdditionalOptions
46 * @param {string | Tap & IfSet<AdditionalOptions>} options options
47 * @param {function(Source, Module, ChunkRenderContext, DependencyTemplates): Source} fn fn
48 */
49 (options, fn) => {
50 getJavascriptModulesPlugin()
51 .getCompilationHooks(compilation)
52 .renderModuleContent.tap(
53 options,
54 (source, module, renderContext) =>
55 fn(
56 source,
57 module,
58 renderContext,
59 renderContext.dependencyTemplates
60 )
61 );
62 },
63 "ModuleTemplate.hooks.content is deprecated (use JavascriptModulesPlugin.getCompilationHooks().renderModuleContent instead)",
64 "DEP_MODULE_TEMPLATE_CONTENT"
65 )
66 },
67 module: {
68 tap: util.deprecate(
69 /**
70 * @template AdditionalOptions
71 * @param {string | Tap & IfSet<AdditionalOptions>} options options
72 * @param {function(Source, Module, ChunkRenderContext, DependencyTemplates): Source} fn fn
73 */
74 (options, fn) => {
75 getJavascriptModulesPlugin()
76 .getCompilationHooks(compilation)
77 .renderModuleContent.tap(
78 options,
79 (source, module, renderContext) =>
80 fn(
81 source,
82 module,
83 renderContext,
84 renderContext.dependencyTemplates
85 )
86 );
87 },
88 "ModuleTemplate.hooks.module is deprecated (use JavascriptModulesPlugin.getCompilationHooks().renderModuleContent instead)",
89 "DEP_MODULE_TEMPLATE_MODULE"
90 )
91 },
92 render: {
93 tap: util.deprecate(
94 /**
95 * @template AdditionalOptions
96 * @param {string | Tap & IfSet<AdditionalOptions>} options options
97 * @param {function(Source, Module, ChunkRenderContext, DependencyTemplates): Source} fn fn
98 */
99 (options, fn) => {
100 getJavascriptModulesPlugin()
101 .getCompilationHooks(compilation)
102 .renderModuleContainer.tap(
103 options,
104 (source, module, renderContext) =>
105 fn(
106 source,
107 module,
108 renderContext,
109 renderContext.dependencyTemplates
110 )
111 );
112 },
113 "ModuleTemplate.hooks.render is deprecated (use JavascriptModulesPlugin.getCompilationHooks().renderModuleContainer instead)",
114 "DEP_MODULE_TEMPLATE_RENDER"
115 )
116 },
117 package: {
118 tap: util.deprecate(
119 /**
120 * @template AdditionalOptions
121 * @param {string | Tap & IfSet<AdditionalOptions>} options options
122 * @param {function(Source, Module, ChunkRenderContext, DependencyTemplates): Source} fn fn
123 */
124 (options, fn) => {
125 getJavascriptModulesPlugin()
126 .getCompilationHooks(compilation)
127 .renderModulePackage.tap(
128 options,
129 (source, module, renderContext) =>
130 fn(
131 source,
132 module,
133 renderContext,
134 renderContext.dependencyTemplates
135 )
136 );
137 },
138 "ModuleTemplate.hooks.package is deprecated (use JavascriptModulesPlugin.getCompilationHooks().renderModulePackage instead)",
139 "DEP_MODULE_TEMPLATE_PACKAGE"
140 )
141 },
142 hash: {
143 tap: util.deprecate(
144 /**
145 * @template AdditionalOptions
146 * @param {string | Tap & IfSet<AdditionalOptions>} options options
147 * @param {function(Hash): void} fn fn
148 */
149 (options, fn) => {
150 compilation.hooks.fullHash.tap(options, fn);
151 },
152 "ModuleTemplate.hooks.hash is deprecated (use Compilation.hooks.fullHash instead)",
153 "DEP_MODULE_TEMPLATE_HASH"
154 )
155 }
156 });
157 }
158}
159
160Object.defineProperty(ModuleTemplate.prototype, "runtimeTemplate", {
161 get: util.deprecate(
162 /**
163 * @this {ModuleTemplate}
164 * @returns {RuntimeTemplate} output options
165 */
166 function () {
167 return this._runtimeTemplate;
168 },
169 "ModuleTemplate.runtimeTemplate is deprecated (use Compilation.runtimeTemplate instead)",
170 "DEP_WEBPACK_CHUNK_TEMPLATE_OUTPUT_OPTIONS"
171 )
172});
173
174module.exports = ModuleTemplate;
Note: See TracBrowser for help on using the repository browser.