MCPcopy
hub / github.com/webpack/webpack / dependencyCacheProvide

Method dependencyCacheProvide

lib/ModuleGraph.js:1004–1023  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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 /**

Callers 1

getModeMethod · 0.80

Calls 5

getParentModuleMethod · 0.95
popMethod · 0.80
fnFunction · 0.50
getMethod · 0.45
provideMethod · 0.45

Tested by

no test coverage detected