How to use the recast/package.json.version function in recast

To help you get started, we’ve selected a few recast examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fkling / astexplorer / website / src / parsers / js / recast.js View on Github external
import React from 'react'; // eslint-disable-line no-unused-vars
import defaultParserInterface from './utils/defaultESTreeParserInterface';
import pkg from 'recast/package.json';

import flowParser, * as flowSettings from './flow';
import babylon6Parser, * as babylon6Settings from './babylon6';
import babylon7Parser, * as babylon7Settings from './babylon7';

const ID = 'recast';

export default {
  ...defaultParserInterface,

  id: ID,
  displayName: ID,
  version: pkg.version,
  homepage: pkg.homepage,
  locationProps: new Set(['range', 'loc', 'start', 'end']),

  loadParser(callback) {
    require(
      ['recast', 'babel5', 'babylon6', 'babylon7', 'flow-parser', 'recast/parsers/typescript'],
      (recast, babelCore, babylon6, babylon7, flow, typescript) => {
        callback({
          recast,
          parsers: {
            'babel5': babelCore,
            babylon6,
            babylon7,
            flow,
            typescript,
          },