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

Method constructor

lib/ContextModule.js:138–188  ·  view source on GitHub ↗

* @param {ResolveDependencies} resolveDependencies function to get dependencies in this context * @param {ContextModuleOptions} options options object

(resolveDependencies, options)

Source from the content-addressed store, hash-verified

136 * @param {ContextModuleOptions} options options object
137 */
138 constructor(resolveDependencies, options) {
139 if (!options || typeof options.resource === "string") {
140 const parsed = parseResource(
141 options ? /** @type {string} */ (options.resource) : ""
142 );
143 const resource = parsed.path;
144 const resourceQuery = (options && options.resourceQuery) || parsed.query;
145 const resourceFragment =
146 (options && options.resourceFragment) || parsed.fragment;
147 const layer = options && options.layer;
148
149 super(JAVASCRIPT_MODULE_TYPE_DYNAMIC, resource, layer);
150 /** @type {ContextModuleOptions} */
151 this.options = {
152 ...options,
153 resource,
154 resourceQuery,
155 resourceFragment
156 };
157 } else {
158 super(JAVASCRIPT_MODULE_TYPE_DYNAMIC, undefined, options.layer);
159 /** @type {ContextModuleOptions} */
160 this.options = {
161 ...options,
162 resource: options.resource,
163 resourceQuery: options.resourceQuery || "",
164 resourceFragment: options.resourceFragment || ""
165 };
166 }
167
168 // Redeclared with the context module specific shape
169 /** @type {ContextModuleBuildInfo | undefined} */
170 this.buildInfo = undefined;
171
172 // Info from Factory
173 /** @type {ResolveDependencies | undefined} */
174 this.resolveDependencies = resolveDependencies;
175 if (options && options.resolveOptions !== undefined) {
176 /** @type {ResolveOptions | undefined} */
177 this.resolveOptions = options.resolveOptions;
178 }
179
180 if (options && typeof options.mode !== "string") {
181 throw new Error("options.mode is a required option");
182 }
183
184 /** @type {string} */
185 this._identifier = this._createIdentifier();
186 /** @type {boolean} */
187 this._forceBuild = true;
188 }
189
190 /**
191 * Returns the source types this module can generate.

Callers

nothing calls this directly

Calls 1

_createIdentifierMethod · 0.95

Tested by

no test coverage detected