packages/css/src/gen-css-bundles.js
function replaceCssModules (bundles, cssBundles, originBundleCssBundleMap, moduleClassnameMaps) {

  const cssBundlesStats = moduleClassnameMaps && cssBundles.map(bundle => {
    const moduleClassnames = bundle.modules.map(module => moduleClassnameMaps[module.path]);
    const combinedJson = assign(...[{}].concat(moduleClassnames));

    return {
      type: "css-stats",
      dest: `${bundle.dest}.json`,
      moduleHashes: [],
      raw: JSON.stringify(combinedJson)
    };
  }) || [];

  return bundles.map((bundle, bIdx) => {
    if (!(bIdx in originBundleCssBundleMap)) { return bundle; }
    const cssBundle = cssBundles[originBundleCssBundleMap[bIdx]];

    return assign({}, bundle, { modules: bundle.modules.map(module => {
      if (module.type !== "css") { return module; }

      const exportValue = moduleClassnameMaps && moduleClassnameMaps[module.path] ?
        fromObject(assign(
          {},
          moduleClassnameMaps[module.path],
          { _path: cssBundle.dest }
        )) :
        t.stringLiteral(cssBundle.dest);

      return assign({}, module, {
        type: "javascript",
        ast: exportObjTmpl({ EXPORT_VALUE: exportValue })
      });
    })});
  }).concat(cssBundles, cssBundlesStats);
}
function replaceCssModules (bundles, cssBundles, originBundleCssBundleMap, moduleClassnameMaps) {

  const cssBundlesStats = moduleClassnameMaps && cssBundles.map(bundle => {
    const moduleClassnames = bundle.modules.map(module => moduleClassnameMaps[module.path]);
    const combinedJson = assign(...[{}].concat(moduleClassnames));

    return {
      type: "css-stats",
      dest: `${bundle.dest}.json`,
      moduleHashes: [],
      raw: JSON.stringify(combinedJson)
    };
  }) || [];

  return bundles.map((bundle, bIdx) => {
    if (!(bIdx in originBundleCssBundleMap)) { return bundle; }
    const cssBundle = cssBundles[originBundleCssBundleMap[bIdx]];

    return assign({}, bundle, { modules: bundle.modules.map(module => {
      if (module.type !== "css") { return module; }

      const exportValue = moduleClassnameMaps && moduleClassnameMaps[module.path] ?
        fromObject(assign(
          {},
          moduleClassnameMaps[module.path],
          { _path: cssBundle.dest }
        )) :
        t.stringLiteral(cssBundle.dest);

      return assign({}, module, {
        type: "javascript",
        ast: exportObjTmpl({ EXPORT_VALUE: exportValue })
      });
    })});
  }).concat(cssBundles, cssBundlesStats);
}
function replaceCssModules ( bundles , cssBundles , originBundleCssBundleMap , moduleClassnameMaps ) { const cssBundlesStats = moduleClassnameMaps && cssBundles . map ( bundle => { const moduleClassnames = bundle . modules . map ( module => moduleClassnameMaps [ module . path ] ) ; const combinedJson = assign ( ... [ { } ] . concat ( moduleClassnames ) ) ; return { type : "css-stats" , dest : ` ${ bundle . dest } ` , moduleHashes : [ ] , raw : JSON . stringify ( combinedJson ) } ; } ) || [ ] ; return bundles . map ( ( bundle , bIdx ) => { if ( ! ( bIdx in originBundleCssBundleMap ) ) { return bundle ; } const cssBundle = cssBundles [ originBundleCssBundleMap [ bIdx ] ] ; return assign ( { } , bundle , { modules : bundle . modules . map ( module => { if ( module . type !== "css" ) { return module ; } const exportValue = moduleClassnameMaps && moduleClassnameMaps [ module . path ] ? fromObject ( assign ( { } , moduleClassnameMaps [ module . path ] , { _path : cssBundle . dest } ) ) : t . stringLiteral ( cssBundle . dest ) ; return assign ( { } , module , { type : "javascript" , ast : exportObjTmpl ( { EXPORT_VALUE : exportValue } ) } ) ; } ) } ) ; } ) . concat ( cssBundles , cssBundlesStats ) ; }
Replace CSS modules with JavaScript modules which reference the CSS
output bundle destination.

@param  {Array}  bundles                  Original bundles array.
@param  {Array}  cssBundles               New CSS bundles.
@param  {Object} originBundleCssBundleMap Mapping of origin bundle to sibling
CSS bundle.
@param  {Object} moduleClassnameMaps      Mapping of filename to friendly/module
classname maps.

@return {Array}                           Original bundles plus CSS bundles.
Replace CSS modules with JavaScript modules which reference the CSS output bundle destination .