UNPKG

@tsbb/babel

Version:

TSBB is a zero-config CLI that helps you develop, test, and publish modern TypeScript project.

13 lines (12 loc) 454 B
import { transformFile, loadPartialConfig } from '@babel/core'; export function transform(fileName, ops = {}) { const babelOptions = loadPartialConfig({ ...ops, cwd: process.cwd() }); return new Promise((resolve, reject) => { transformFile(fileName, { ...babelOptions?.options, babelrc: true }, (err, result) => { if (err) { return reject(err); } resolve(result); }); }); }