function generateMetadataForAssets(assets, chunks) {
  const mapping = {};

  // Start out by getting metadata for all the assets associated with a chunk.
  for (const chunk of chunks) {
    for (const file of chunk.files) {
      mapping[file] = {
        chunkName: chunk.name,
        hash: chunk.renderedHash,
      };
    }
  }

  // Next, loop through the total list of assets and find anything that isn't
  // associated with a chunk.
  for (const [file, asset] of Object.entries(assets)) {
    if (file in mapping) {
      continue;
    }

    mapping[file] = {
      // Just use an empty string to denote the lack of chunk association.
      chunkName: '',
      hash: getAssetHash(asset),
    };
  }

  return mapping;
}
function generateMetadataForAssets(assets, chunks) {
  const mapping = {};

  // Start out by getting metadata for all the assets associated with a chunk.
  for (const chunk of chunks) {
    for (const file of chunk.files) {
      mapping[file] = {
        chunkName: chunk.name,
        hash: chunk.renderedHash,
      };
    }
  }

  // Next, loop through the total list of assets and find anything that isn't
  // associated with a chunk.
  for (const [file, asset] of Object.entries(assets)) {
    if (file in mapping) {
      continue;
    }

    mapping[file] = {
      // Just use an empty string to denote the lack of chunk association.
      chunkName: '',
      hash: getAssetHash(asset),
    };
  }

  return mapping;
}
function generateMetadataForAssets ( assets , chunks ) { const mapping = { } ; // Start out by getting metadata for all the assets associated with a chunk. for ( const chunk of chunks ) { for ( const file of chunk . files ) { mapping [ file ] = { chunkName : chunk . name , hash : chunk . renderedHash , } ; } } // Next, loop through the total list of assets and find anything that isn't // associated with a chunk. for ( const [ file , asset ] of Object . entries ( assets ) ) { if ( file in mapping ) { continue ; } mapping [ file ] = { // Just use an empty string to denote the lack of chunk association. chunkName : '' , hash : getAssetHash ( asset ) , } ; } return mapping ; }
Takes in compilation.assets and compilation.chunks, and assigns metadata
to each file listed in assets:

- If the asset was created by a chunk, it assigns the existing chunk name and
chunk hash.
- If the asset was created outside of a chunk, it assigns a chunk name of ''
and generates a hash of the asset.

@param {Object} assets The compilation.assets
@param {Array<Object>} chunks The compilation.chunks
@return {Object<string, Object>} Mapping of asset paths to chunk name and
hash metadata.

@private
Takes in compilation . assets and compilation . chunks and assigns metadata to each file listed in assets :
Generate metadata for all the assets associated with a chunk.