getParser.js 648 B

12345678910111213141516171819202122232425
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. 'use strict';
  8. module.exports = function getParser(parserName, options) {
  9. switch (parserName) {
  10. case 'babylon':
  11. return require('../parser/babylon')(options);
  12. case 'flow':
  13. return require('../parser/flow')(options);
  14. case 'ts':
  15. return require('../parser/ts')(options);
  16. case 'tsx':
  17. return require('../parser/tsx')(options);
  18. case 'babel':
  19. default:
  20. return require('../parser/babel5Compat')(options);
  21. }
  22. };