(resolveOptionsWithDepType)
| 37 | * @returns {ResolveOptions} merged options |
| 38 | */ |
| 39 | const 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. |
no test coverage detected