code: function generateBundleName(name, modules, conditionValueOrVariationObject) {
      // first check if the given modules already matches an existing bundle
      let existingBundleName;
      for (const bundleName of Object.keys(bundles)) {
        const bundleModules = bundles[bundleName].modules;
  
        if (
          containsModules(modules, bundleModules) &&
          containsModules(bundleModules, modules)
        ) {
          existingBundleName = bundleName;
        }
      }
      if (existingBundleName) {
        return existingBundleName;
      }
  
      let shortName = name.split('/').pop();
      const dotIndex = shortName.lastIndexOf('.');
      if (dotIndex > 0) {
        shortName = shortName.substr(0, dotIndex);
      }
  
      let bundleName = shortName.replace(/[ .]/g, '').toLowerCase();
      if (conditionValueOrVariationObject) {
        if (typeof conditionValueOrVariationObject === 'string') {
          bundleName += `-${conditionValueOrVariationObject}`;
        } else {
          for (const condition of Object.keys(conditionValueOrVariationObject)) {
            bundleName += `-${conditionValueOrVariationObject[condition]}`;
          }
        }
      }
  
      let i;
      if (bundles[bundleName]) {
        i = 1;
        while (bundles[`${bundleName}-${i}`]) {
          i += 1;
        }
      }
      return bundleName + (i ? `-${i}` : '');
    }
docs: simple random bundle name generation with duplication avoidance