getJSXPragmaInfo.js 494 B

12345678910111213141516171819202122
  1. export default function getJSXPragmaInfo(options) {
  2. const [base, suffix] = splitPragma(options.jsxPragma || "React.createElement");
  3. const [fragmentBase, fragmentSuffix] = splitPragma(options.jsxFragmentPragma || "React.Fragment");
  4. return {base, suffix, fragmentBase, fragmentSuffix};
  5. }
  6. function splitPragma(pragma) {
  7. let dotIndex = pragma.indexOf(".");
  8. if (dotIndex === -1) {
  9. dotIndex = pragma.length;
  10. }
  11. return [pragma.slice(0, dotIndex), pragma.slice(dotIndex)];
  12. }