source: imaps-frontend/node_modules/webpack/lib/DllModule.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 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 { RawSource } = require("webpack-sources");
9const Module = require("./Module");
10const { JS_TYPES } = require("./ModuleSourceTypesConstants");
11const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("./ModuleTypeConstants");
12const RuntimeGlobals = require("./RuntimeGlobals");
13const makeSerializable = require("./util/makeSerializable");
14
15/** @typedef {import("webpack-sources").Source} Source */
16/** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
17/** @typedef {import("./ChunkGraph")} ChunkGraph */
18/** @typedef {import("./Compilation")} Compilation */
19/** @typedef {import("./Dependency")} Dependency */
20/** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
21/** @typedef {import("./DependencyTemplates")} DependencyTemplates */
22/** @typedef {import("./Generator").SourceTypes} SourceTypes */
23/** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */
24/** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
25/** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
26/** @typedef {import("./Module").SourceContext} SourceContext */
27/** @typedef {import("./RequestShortener")} RequestShortener */
28/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
29/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
30/** @typedef {import("./WebpackError")} WebpackError */
31/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
32/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
33/** @typedef {import("./util/Hash")} Hash */
34/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
35
36const RUNTIME_REQUIREMENTS = new Set([
37 RuntimeGlobals.require,
38 RuntimeGlobals.module
39]);
40
41class DllModule extends Module {
42 /**
43 * @param {string} context context path
44 * @param {Dependency[]} dependencies dependencies
45 * @param {string} name name
46 */
47 constructor(context, dependencies, name) {
48 super(JAVASCRIPT_MODULE_TYPE_DYNAMIC, context);
49
50 // Info from Factory
51 /** @type {Dependency[]} */
52 this.dependencies = dependencies;
53 this.name = name;
54 }
55
56 /**
57 * @returns {SourceTypes} types available (do not mutate)
58 */
59 getSourceTypes() {
60 return JS_TYPES;
61 }
62
63 /**
64 * @returns {string} a unique identifier of the module
65 */
66 identifier() {
67 return `dll ${this.name}`;
68 }
69
70 /**
71 * @param {RequestShortener} requestShortener the request shortener
72 * @returns {string} a user readable identifier of the module
73 */
74 readableIdentifier(requestShortener) {
75 return `dll ${this.name}`;
76 }
77
78 /**
79 * @param {WebpackOptions} options webpack options
80 * @param {Compilation} compilation the compilation
81 * @param {ResolverWithOptions} resolver the resolver
82 * @param {InputFileSystem} fs the file system
83 * @param {function(WebpackError=): void} callback callback function
84 * @returns {void}
85 */
86 build(options, compilation, resolver, fs, callback) {
87 this.buildMeta = {};
88 this.buildInfo = {};
89 return callback();
90 }
91
92 /**
93 * @param {CodeGenerationContext} context context for code generation
94 * @returns {CodeGenerationResult} result
95 */
96 codeGeneration(context) {
97 const sources = new Map();
98 sources.set(
99 "javascript",
100 new RawSource(`module.exports = ${RuntimeGlobals.require};`)
101 );
102 return {
103 sources,
104 runtimeRequirements: RUNTIME_REQUIREMENTS
105 };
106 }
107
108 /**
109 * @param {NeedBuildContext} context context info
110 * @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
111 * @returns {void}
112 */
113 needBuild(context, callback) {
114 return callback(null, !this.buildMeta);
115 }
116
117 /**
118 * @param {string=} type the source type for which the size should be estimated
119 * @returns {number} the estimated size of the module (must be non-zero)
120 */
121 size(type) {
122 return 12;
123 }
124
125 /**
126 * @param {Hash} hash the hash used to track dependencies
127 * @param {UpdateHashContext} context context
128 * @returns {void}
129 */
130 updateHash(hash, context) {
131 hash.update(`dll module${this.name || ""}`);
132 super.updateHash(hash, context);
133 }
134
135 /**
136 * @param {ObjectSerializerContext} context context
137 */
138 serialize(context) {
139 context.write(this.name);
140 super.serialize(context);
141 }
142
143 /**
144 * @param {ObjectDeserializerContext} context context
145 */
146 deserialize(context) {
147 this.name = context.read();
148 super.deserialize(context);
149 }
150
151 /**
152 * Assuming this module is in the cache. Update the (cached) module with
153 * the fresh module from the factory. Usually updates internal references
154 * and properties.
155 * @param {Module} module fresh module
156 * @returns {void}
157 */
158 updateCacheModule(module) {
159 super.updateCacheModule(module);
160 this.dependencies = module.dependencies;
161 }
162
163 /**
164 * Assuming this module is in the cache. Remove internal references to allow freeing some memory.
165 */
166 cleanupForCache() {
167 super.cleanupForCache();
168 this.dependencies = /** @type {EXPECTED_ANY} */ (undefined);
169 }
170}
171
172makeSerializable(DllModule, "webpack/lib/DllModule");
173
174module.exports = DllModule;
Note: See TracBrowser for help on using the repository browser.