tsx.js 598 B

123456789101112131415161718192021222324252627
  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. const _ = require('lodash');
  9. const babylon = require('@babel/parser');
  10. const baseOptions = require('./tsOptions');
  11. const options = _.merge(baseOptions, { plugins: ['jsx'] });
  12. /**
  13. * Doesn't accept custom options because babylon should be used directly in
  14. * that case.
  15. */
  16. module.exports = function() {
  17. return {
  18. parse(code) {
  19. return babylon.parse(code, options);
  20. },
  21. };
  22. };