isExportFrom.js 628 B

123456789101112131415161718
  1. import {ContextualKeyword} from "../parser/tokenizer/keywords";
  2. import {TokenType as tt} from "../parser/tokenizer/types";
  3. /**
  4. * Starting at `export {`, look ahead and return `true` if this is an
  5. * `export {...} from` statement and `false` if this is a plain multi-export.
  6. */
  7. export default function isExportFrom(tokens) {
  8. let closeBraceIndex = tokens.currentIndex();
  9. while (!tokens.matches1AtIndex(closeBraceIndex, tt.braceR)) {
  10. closeBraceIndex++;
  11. }
  12. return (
  13. tokens.matchesContextualAtIndex(closeBraceIndex + 1, ContextualKeyword._from) &&
  14. tokens.matches1AtIndex(closeBraceIndex + 2, tt.string)
  15. );
  16. }