tasks/generate-index.js
function formatSymbolExport(symbol, namespaces, imports) {
  const name = symbol.name;
  const parts = name.split('~');
  const isNamed = parts[0].indexOf('.') !== -1;
  const nsParts = parts[0].replace(/^module\:/, '').split(/[\/\.]/);
  const last = nsParts.length - 1;
  const importName = isNamed ?
    '_' + nsParts.slice(0, last).join('_') + '$' + nsParts[last] :
    '$' + nsParts.join('$');
  let line = nsParts[0];
  for (let i = 1, ii = nsParts.length; i < ii; ++i) {
    line += `.${nsParts[i]}`;
    namespaces[line] = (line in namespaces ? namespaces[line] : true) && i < ii - 1;
  }
  line += ` = ${importName};`;
  imports[getImport(symbol, nsParts.pop())] = true;
  return line;
}
function formatSymbolExport(symbol, namespaces, imports) {
  const name = symbol.name;
  const parts = name.split('~');
  const isNamed = parts[0].indexOf('.') !== -1;
  const nsParts = parts[0].replace(/^module\:/, '').split(/[\/\.]/);
  const last = nsParts.length - 1;
  const importName = isNamed ?
    '_' + nsParts.slice(0, last).join('_') + '$' + nsParts[last] :
    '$' + nsParts.join('$');
  let line = nsParts[0];
  for (let i = 1, ii = nsParts.length; i < ii; ++i) {
    line += `.${nsParts[i]}`;
    namespaces[line] = (line in namespaces ? namespaces[line] : true) && i < ii - 1;
  }
  line += ` = ${importName};`;
  imports[getImport(symbol, nsParts.pop())] = true;
  return line;
}
function formatSymbolExport ( symbol , namespaces , imports ) { const name = symbol . name ; const parts = name . split ( '~' ) ; const isNamed = parts [ 0 ] . indexOf ( '.' ) !== - 1 ; const nsParts = parts [ 0 ] . replace ( / ^module\: / , '' ) . split ( / [\/\.] / ) ; const last = nsParts . length - 1 ; const importName = isNamed ? '_' + nsParts . slice ( 0 , last ) . join ( '_' ) + '$' + nsParts [ last ] : '$' + nsParts . join ( '$' ) ; let line = nsParts [ 0 ] ; for ( let i = 1 , ii = nsParts . length ; i < ii ; ++ i ) { line += ` ${ nsParts [ i ] } ` ; namespaces [ line ] = ( line in namespaces ? namespaces [ line ] : true ) && i < ii - 1 ; } line += ` ${ importName } ` ; imports [ getImport ( symbol , nsParts . pop ( ) ) ] = true ; return line ; }
Generate code to export a named symbol.
@param {Object} symbol Symbol.
@param {Object<string, string>} namespaces Already defined namespaces.
@param {Object} imports Imports.
@return {string} Export code.
Generate code to export a named symbol .