babel-utils / babel-file

Easily create a Babel File object

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

babel-file

Easily create a Babel File object

  • Constructs File object
  • Adds/parses code with nice errors
import createFile from 'babel-file';
import createBabylonOptions from 'babylon-options';

const file = createFile(code, {
  filename: 'filename.js',
  parserOpts: createBabylonOptions({
    stage: 2,
  }),
});

file.code;
file.ast;
file.path;

Accepts all the same options as the normal Babel File object.

About

Easily create a Babel File object

License:MIT License


Languages

Language:JavaScript 100.0%