MCPcopy
hub / github.com/webpack/webpack / convertToResolveOptions

Function convertToResolveOptions

lib/ResolverFactory.js:39–71  ·  view source on GitHub ↗
(resolveOptionsWithDepType)

Source from the content-addressed store, hash-verified

37 * @returns {ResolveOptions} merged options
38 */
39const convertToResolveOptions = (resolveOptionsWithDepType) => {
40 const { dependencyType, plugins, ...remaining } = resolveOptionsWithDepType;
41
42 // check type compat
43 /** @type {Partial<ResolveOptionsWithDependencyType>} */
44 const partialOptions = {
45 ...remaining,
46 plugins:
47 plugins &&
48 /** @type {ResolvePluginInstance[]} */ (
49 plugins.filter((item) => item !== "...")
50 )
51 };
52
53 if (!partialOptions.fileSystem) {
54 throw new Error(
55 "fileSystem is missing in resolveOptions, but it's required for enhanced-resolve"
56 );
57 }
58 // These weird types validate that we checked all non-optional properties
59 const options =
60 /** @type {Partial<ResolveOptionsWithDependencyType> & Pick<ResolveOptionsWithDependencyType, "fileSystem">} */ (
61 partialOptions
62 );
63
64 return /** @type {ResolveOptions} */ (
65 removeOperations(
66 resolveByProperty(options, "byDependency", dependencyType),
67 // Keep the `unsafeCache` because it can be a `Proxy`
68 ["unsafeCache"]
69 )
70 );
71};
72
73/**
74 * Represents the resolver factory runtime component.

Callers 1

_createMethod · 0.85

Calls 2

removeOperationsFunction · 0.85
resolveByPropertyFunction · 0.85

Tested by

no test coverage detected