* Applies the plugin by registering its hooks on the compiler. * @param {Compiler} compiler the compiler instance * @returns {void}
(compiler)
| 479 | * @returns {void} |
| 480 | */ |
| 481 | apply(compiler) { |
| 482 | compiler.hooks.validate.tap(PLUGIN_NAME, () => { |
| 483 | compiler.validate( |
| 484 | () => require("../../schemas/plugins/schemes/HttpUriPlugin.json"), |
| 485 | this.options, |
| 486 | { |
| 487 | name: "Http Uri Plugin", |
| 488 | baseDataPath: "options" |
| 489 | }, |
| 490 | (options) => |
| 491 | require("../../schemas/plugins/schemes/HttpUriPlugin.check")(options) |
| 492 | ); |
| 493 | }); |
| 494 | |
| 495 | const proxy = |
| 496 | this.options.proxy || process.env.http_proxy || process.env.HTTP_PROXY; |
| 497 | /** |
| 498 | * @type {{ scheme: "http" | "https", fetch: Fetch }[]} |
| 499 | */ |
| 500 | const schemes = [ |
| 501 | { |
| 502 | scheme: "http", |
| 503 | fetch: proxyFetch(getHttp(), proxy) |
| 504 | }, |
| 505 | { |
| 506 | scheme: "https", |
| 507 | fetch: proxyFetch(getHttps(), proxy) |
| 508 | } |
| 509 | ]; |
| 510 | /** @type {LockfileCache} */ |
| 511 | let lockfileCache; |
| 512 | compiler.hooks.compilation.tap( |
| 513 | PLUGIN_NAME, |
| 514 | (compilation, { normalModuleFactory }) => { |
| 515 | const intermediateFs = |
| 516 | /** @type {IntermediateFileSystem} */ |
| 517 | (compiler.intermediateFileSystem); |
| 518 | const fs = compilation.inputFileSystem; |
| 519 | const cache = compilation.getCache(`webpack.${PLUGIN_NAME}`); |
| 520 | const logger = compilation.getLogger(`webpack.${PLUGIN_NAME}`); |
| 521 | /** @type {string} */ |
| 522 | const lockfileLocation = |
| 523 | this.options.lockfileLocation || |
| 524 | join( |
| 525 | intermediateFs, |
| 526 | compiler.context, |
| 527 | compiler.name |
| 528 | ? `${toSafePath(compiler.name)}.webpack.lock` |
| 529 | : "webpack.lock" |
| 530 | ); |
| 531 | /** @type {string | false} */ |
| 532 | const cacheLocation = |
| 533 | this.options.cacheLocation !== undefined |
| 534 | ? this.options.cacheLocation |
| 535 | : `${lockfileLocation}.data`; |
| 536 | const upgrade = this.options.upgrade || false; |
| 537 | const frozen = this.options.frozen || false; |
| 538 | const hashFunction = "sha512"; |
nothing calls this directly
no test coverage detected