UNPKG

sucrase

Version:

Super-fast alternative to Babel for when you can target modern JS runtimes

23 lines (12 loc) 494 B
export default function getJSXPragmaInfo(options) { const [base, suffix] = splitPragma(options.jsxPragma || "React.createElement"); const [fragmentBase, fragmentSuffix] = splitPragma(options.jsxFragmentPragma || "React.Fragment"); return {base, suffix, fragmentBase, fragmentSuffix}; } function splitPragma(pragma) { let dotIndex = pragma.indexOf("."); if (dotIndex === -1) { dotIndex = pragma.length; } return [pragma.slice(0, dotIndex), pragma.slice(dotIndex)]; }