index.js
function(compilation, assetName) {
    if (!compilation || !compilation.cache || typeof compilation.cache !== 'object') {
      return null;
    }

    const cacheKeys = Object.keys(compilation.cache);

    for (let keyIndex = 0; keyIndex < cacheKeys.length; keyIndex++) {
      const cache = compilation.cache[cacheKeys[keyIndex]];
      if (cache.assets && assetName in cache.assets) {
        return cache.rawRequest;
      }
    }

    return null;
  }
function(compilation, assetName) {
    if (!compilation || !compilation.cache || typeof compilation.cache !== 'object') {
      return null;
    }

    const cacheKeys = Object.keys(compilation.cache);

    for (let keyIndex = 0; keyIndex < cacheKeys.length; keyIndex++) {
      const cache = compilation.cache[cacheKeys[keyIndex]];
      if (cache.assets && assetName in cache.assets) {
        return cache.rawRequest;
      }
    }

    return null;
  }
function ( compilation , assetName ) { if ( ! compilation || ! compilation . cache || typeof compilation . cache !== 'object' ) { return null ; } const cacheKeys = Object . keys ( compilation . cache ) ; for ( let keyIndex = 0 ; keyIndex < cacheKeys . length ; keyIndex ++ ) { const cache = compilation . cache [ cacheKeys [ keyIndex ] ] ; if ( cache . assets && assetName in cache . assets ) { return cache . rawRequest ; } } return null ; }
Tries to find the user reuqired file in cace. If it does it returns the
file path user used in the `require` statement. Otherwise it returns null.

@param {object} compilation - Object containing Webpack context
@param {string} assetName - Emitted file name
@return {string} path that user used in require/import
Tries to find the user reuqired file in cace . If it does it returns the file path user used in the require statement . Otherwise it returns null .