src/compiler/compile.js
/**
 * Returns the AST for an AMP Document with eligible components server-rendered.
 *
 * @param {import('./types').CompilerRequest} request
 * @return {import('./types').CompilerResponse}
 */
Returns the AST for an AMP Document with eligible components server-rendered.
Returns the AST for an AMP Document with eligible components server - rendered .
function compile(request) {
  const {component_versions: versions, document, nodes} = request ?? {};
  if (!versions) {
    throw new Error(missingPropErrorMsg);
  }
  const builders = getBuilders(versions);
  if (document) {
    return {document: compiler.renderAstDocument(document, builders)};
  } else if (nodes) {
    return {nodes: compiler.renderAstNodes(nodes, builders)};
  } else {
    throw new Error(missingPropErrorMsg);
  }
}
function compile ( request ) { const { component_versions : versions , document , nodes } = request ?? { } ; if ( ! versions ) { throw new Error ( missingPropErrorMsg ) ; } const builders = getBuilders ( versions ) ; if ( document ) { return { document : compiler . renderAstDocument ( document , builders ) } ; } else if ( nodes ) { return { nodes : compiler . renderAstNodes ( nodes , builders ) } ; } else { throw new Error ( missingPropErrorMsg ) ; } }
Returns the AST for an AMP Document with eligible components server-rendered.
Returns the AST for an AMP Document with eligible components server - rendered .