* Dependency cache provide. * @template {Dependency} D * @template {EXPECTED_ANY[]} ARGS * @template R * @param {D} dependency dependency * @param {[...ARGS, (moduleGraph: ModuleGraph, dependency: D, ...args: ARGS) => R]} args arguments, last argument is a function called with moduleGraph,
(dependency, ...args)
| 1002 | * @returns {R} computed value or cached |
| 1003 | */ |
| 1004 | dependencyCacheProvide(dependency, ...args) { |
| 1005 | const fn = |
| 1006 | /** @type {(moduleGraph: ModuleGraph, dependency: D, ...args: EXPECTED_ANY[]) => R} */ |
| 1007 | (args.pop()); |
| 1008 | if (this._moduleMemCaches && this._cacheStage) { |
| 1009 | const memCache = this._moduleMemCaches.get( |
| 1010 | /** @type {Module} */ |
| 1011 | (this.getParentModule(dependency)) |
| 1012 | ); |
| 1013 | if (memCache !== undefined) { |
| 1014 | return memCache.provide(dependency, this._cacheStage, ...args, () => |
| 1015 | fn(this, dependency, ...args) |
| 1016 | ); |
| 1017 | } |
| 1018 | } |
| 1019 | if (this._cache === undefined) return fn(this, dependency, ...args); |
| 1020 | return this._cache.provide(dependency, ...args, () => |
| 1021 | fn(this, dependency, ...args) |
| 1022 | ); |
| 1023 | } |
| 1024 | |
| 1025 | // TODO remove in webpack 6 |
| 1026 | /** |