MCPcopy
hub / github.com/webpack/webpack / _create

Method _create

lib/ResolverFactory.js:133–160  ·  view source on GitHub ↗

* Returns the resolver. * @param {string} type type of resolver * @param {ResolveOptionsWithDependencyType} resolveOptionsWithDepType options * @returns {ResolverWithOptions} the resolver

(type, resolveOptionsWithDepType)

Source from the content-addressed store, hash-verified

131 * @returns {ResolverWithOptions} the resolver
132 */
133 _create(type, resolveOptionsWithDepType) {
134 /** @type {ResolveOptionsWithDependencyType} */
135 const originalResolveOptions = { ...resolveOptionsWithDepType };
136
137 const resolveOptions = convertToResolveOptions(
138 this.hooks.resolveOptions.for(type).call(resolveOptionsWithDepType)
139 );
140 const resolver = /** @type {ResolverWithOptions} */ (
141 Factory.createResolver(resolveOptions)
142 );
143 if (!resolver) {
144 throw new Error("No resolver created");
145 }
146 /** @type {WeakMap<Partial<ResolveOptionsWithDependencyType>, ResolverWithOptions>} */
147 const childCache = new WeakMap();
148 resolver.withOptions = (options) => {
149 const cacheEntry = childCache.get(options);
150 if (cacheEntry !== undefined) return cacheEntry;
151 const mergedOptions = cachedCleverMerge(originalResolveOptions, options);
152 const resolver = this.get(type, mergedOptions);
153 childCache.set(options, resolver);
154 return resolver;
155 };
156 this.hooks.resolver
157 .for(type)
158 .call(resolver, resolveOptions, originalResolveOptions);
159 return resolver;
160 }
161};

Callers 1

getMethod · 0.95

Calls 5

getMethod · 0.95
convertToResolveOptionsFunction · 0.85
cachedCleverMergeFunction · 0.85
callMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected