source: trip-planner-front/node_modules/webpack/lib/ModuleTemplate.js@ ceaed42

Last change on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 3.9 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("webpack-sources").Source} Source */
12/** @typedef {import("./Chunk")} Chunk */
13/** @typedef {import("./ChunkGraph")} ChunkGraph */
14/** @typedef {import("./Compilation")} Compilation */
15/** @typedef {import("./DependencyTemplates")} DependencyTemplates */
16/** @typedef {import("./Module")} Module */
17/** @typedef {import("./ModuleGraph")} ModuleGraph */
18/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
19/** @typedef {import("./util/Hash")} Hash */
20
21const getJavascriptModulesPlugin = memoize(() =>
22 require("./javascript/JavascriptModulesPlugin")
23);
24
25// TODO webpack 6: remove this class
26class ModuleTemplate {
27 /**
28 * @param {RuntimeTemplate} runtimeTemplate the runtime template
29 * @param {Compilation} compilation the compilation
30 */
31 constructor(runtimeTemplate, compilation) {
32 this._runtimeTemplate = runtimeTemplate;
33 this.type = "javascript";
34 this.hooks = Object.freeze({
35 content: {
36 tap: util.deprecate(
37 (options, fn) => {
38 getJavascriptModulesPlugin()
39 .getCompilationHooks(compilation)
40 .renderModuleContent.tap(
41 options,
42 (source, module, renderContext) =>
43 fn(
44 source,
45 module,
46 renderContext,
47 renderContext.dependencyTemplates
48 )
49 );
50 },
51 "ModuleTemplate.hooks.content is deprecated (use JavascriptModulesPlugin.getCompilationHooks().renderModuleContent instead)",
52 "DEP_MODULE_TEMPLATE_CONTENT"
53 )
54 },
55 module: {
56 tap: util.deprecate(
57 (options, fn) => {
58 getJavascriptModulesPlugin()
59 .getCompilationHooks(compilation)
60 .renderModuleContent.tap(
61 options,
62 (source, module, renderContext) =>
63 fn(
64 source,
65 module,
66 renderContext,
67 renderContext.dependencyTemplates
68 )
69 );
70 },
71 "ModuleTemplate.hooks.module is deprecated (use JavascriptModulesPlugin.getCompilationHooks().renderModuleContent instead)",
72 "DEP_MODULE_TEMPLATE_MODULE"
73 )
74 },
75 render: {
76 tap: util.deprecate(
77 (options, fn) => {
78 getJavascriptModulesPlugin()
79 .getCompilationHooks(compilation)
80 .renderModuleContainer.tap(
81 options,
82 (source, module, renderContext) =>
83 fn(
84 source,
85 module,
86 renderContext,
87 renderContext.dependencyTemplates
88 )
89 );
90 },
91 "ModuleTemplate.hooks.render is deprecated (use JavascriptModulesPlugin.getCompilationHooks().renderModuleContainer instead)",
92 "DEP_MODULE_TEMPLATE_RENDER"
93 )
94 },
95 package: {
96 tap: util.deprecate(
97 (options, fn) => {
98 getJavascriptModulesPlugin()
99 .getCompilationHooks(compilation)
100 .renderModulePackage.tap(
101 options,
102 (source, module, renderContext) =>
103 fn(
104 source,
105 module,
106 renderContext,
107 renderContext.dependencyTemplates
108 )
109 );
110 },
111 "ModuleTemplate.hooks.package is deprecated (use JavascriptModulesPlugin.getCompilationHooks().renderModulePackage instead)",
112 "DEP_MODULE_TEMPLATE_PACKAGE"
113 )
114 },
115 hash: {
116 tap: util.deprecate(
117 (options, fn) => {
118 compilation.hooks.fullHash.tap(options, fn);
119 },
120 "ModuleTemplate.hooks.hash is deprecated (use Compilation.hooks.fullHash instead)",
121 "DEP_MODULE_TEMPLATE_HASH"
122 )
123 }
124 });
125 }
126}
127
128Object.defineProperty(ModuleTemplate.prototype, "runtimeTemplate", {
129 get: util.deprecate(
130 /**
131 * @this {ModuleTemplate}
132 * @returns {TODO} output options
133 */
134 function () {
135 return this._runtimeTemplate;
136 },
137 "ModuleTemplate.runtimeTemplate is deprecated (use Compilation.runtimeTemplate instead)",
138 "DEP_WEBPACK_CHUNK_TEMPLATE_OUTPUT_OPTIONS"
139 )
140});
141
142module.exports = ModuleTemplate;
Note: See TracBrowser for help on using the repository browser.