function transpileSource(packageId, name, source, language) {
  let src;
  switch (language) {
    case 'coffeescript': {
      if (!CoffeeScript) {
        return Promise.reject(new Error(`Unsupported component source language ${language} for ${packageId}/${name}: no CoffeeScript compiler installed`));
      }
      try {
        src = CoffeeScript.compile(source, {
          bare: true,
        });
      } catch (err) {
        return Promise.reject(err);
      }
      break;
    }
    case 'typescript': {
      if (!typescript) {
        return Promise.reject(new Error(`Unsupported component source language ${language} for ${packageId}/${name}: no TypeScript compiler installed`));
      }
      try {
        src = typescript.transpile(source, {
          module: typescript.ModuleKind.CommonJS,
          target: typescript.ScriptTarget.ES2015,
        });
      } catch (err) {
        return Promise.reject(err);
      }
      break;
    }
    case 'es6':
    case 'es2015':
    case 'js':
    case 'javascript': {
      src = source;
      break;
    }
    default: {
      return Promise.reject(new Error(`Unsupported component source language ${language} for ${packageId}/${name}`));
    }
  }
  return Promise.resolve(src);
}
@param {string} packageId
@param {string} name
@param {string} source
@param {string} language
@returns {Promise<string>}