* @param {string} filename filename * @param {string} currentDirectory current directory * @param {LoadFileOptions} options options * @param {Environment} environment environment * @returns {Promise } loaded file
(filename, currentDirectory, options, environment)
| 225 | * @returns {Promise<LoadFileResult>} loaded file |
| 226 | */ |
| 227 | async loadFile(filename, currentDirectory, options, environment) { |
| 228 | let result; |
| 229 | |
| 230 | try { |
| 231 | if ( |
| 232 | IS_SPECIAL_MODULE_IMPORT.test(filename) || |
| 233 | lessOptions.webpackImporter === "only" |
| 234 | ) { |
| 235 | const error = /** @type {LessError} */ (new Error("Next")); |
| 236 | |
| 237 | error.type = "Next"; |
| 238 | |
| 239 | throw error; |
| 240 | } |
| 241 | |
| 242 | result = await super.loadFile( |
| 243 | filename, |
| 244 | currentDirectory, |
| 245 | options, |
| 246 | environment, |
| 247 | ); |
| 248 | } catch (error) { |
| 249 | const lessError = /** @type {LessError} */ (error); |
| 250 | |
| 251 | if (lessError.type !== "File" && lessError.type !== "Next") { |
| 252 | throw error; |
| 253 | } |
| 254 | |
| 255 | try { |
| 256 | result = await this.resolveFilename(filename, currentDirectory); |
| 257 | } catch (err) { |
| 258 | lessError.message = |
| 259 | `Less resolver error:\n${lessError.message}\n\n` + |
| 260 | `Webpack resolver error details:\n${/** @type {{ details: string }} */ (err).details}\n\n` + |
| 261 | `Webpack resolver error missing:\n${/** @type {{ missing: string }} */ (err).missing}\n\n`; |
| 262 | |
| 263 | throw error; |
| 264 | } |
| 265 | |
| 266 | loaderContext.addDependency(result); |
| 267 | |
| 268 | return super.loadFile(result, currentDirectory, options, environment); |
| 269 | } |
| 270 | |
| 271 | const absoluteFilename = path.isAbsolute(result.filename) |
| 272 | ? result.filename |
| 273 | : path.resolve(".", result.filename); |
| 274 | |
| 275 | loaderContext.addDependency(path.normalize(absoluteFilename)); |
| 276 | |
| 277 | return result; |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | return { |
no test coverage detected