* @private * @template T * @param {ResolverWithOptions} resolver a resolver * @param {WebpackOptions} options webpack options * @param {Compilation} compilation the compilation * @param {InputFileSystem} fs file system from reading * @param {NormalModuleCompilationHooks} hooks the hooks
(resolver, options, compilation, fs, hooks)
| 1137 | * @returns {import(class="st">"../declarations/LoaderContext").LoaderContext<T>} loader context |
| 1138 | */ |
| 1139 | _createLoaderContext(resolver, options, compilation, fs, hooks) { |
| 1140 | const { requestShortener } = compilation.runtimeTemplate; |
| 1141 | const getCurrentLoaderName = () => { |
| 1142 | const currentLoader = this.getCurrentLoader( |
| 1143 | /** @type {AnyLoaderContext} */ |
| 1144 | (loaderContext) |
| 1145 | ); |
| 1146 | if (!currentLoader) return class="st">"(not in loader scope)"; |
| 1147 | return requestShortener.shorten(currentLoader.loader); |
| 1148 | }; |
| 1149 | /** |
| 1150 | * @returns {ResolveContext} resolve context |
| 1151 | */ |
| 1152 | const getResolveContext = () => ({ |
| 1153 | fileDependencies: { |
| 1154 | add: (d) => |
| 1155 | /** @type {AnyLoaderContext} */ |
| 1156 | (loaderContext).addDependency(d) |
| 1157 | }, |
| 1158 | contextDependencies: { |
| 1159 | add: (d) => |
| 1160 | /** @type {AnyLoaderContext} */ |
| 1161 | (loaderContext).addContextDependency(d) |
| 1162 | }, |
| 1163 | missingDependencies: { |
| 1164 | add: (d) => |
| 1165 | /** @type {AnyLoaderContext} */ |
| 1166 | (loaderContext).addMissingDependency(d) |
| 1167 | } |
| 1168 | }); |
| 1169 | const getAbsolutify = memoize(() => |
| 1170 | absolutify.bindCache(compilation.compiler.root) |
| 1171 | ); |
| 1172 | const getAbsolutifyInContext = memoize(() => |
| 1173 | absolutify.bindContextCache( |
| 1174 | /** @type {string} */ |
| 1175 | (this.context), |
| 1176 | compilation.compiler.root |
| 1177 | ) |
| 1178 | ); |
| 1179 | const getContextify = memoize(() => |
| 1180 | contextify.bindCache(compilation.compiler.root) |
| 1181 | ); |
| 1182 | const getContextifyInContext = memoize(() => |
| 1183 | contextify.bindContextCache( |
| 1184 | /** @type {string} */ |
| 1185 | (this.context), |
| 1186 | compilation.compiler.root |
| 1187 | ) |
| 1188 | ); |
| 1189 | const utils = { |
| 1190 | /** |
| 1191 | * @param {string} context context |
| 1192 | * @param {string} request request |
| 1193 | * @returns {string} result |
| 1194 | */ |
| 1195 | absolutify: (context, request) => |
| 1196 | context === this.context |
no test coverage detected