How to use the babel.transformFile function in babel

To help you get started, we’ve selected a few babel 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 wavesjs / waves-lfo / bin / scripts.js View on Github external
function transpile(src, stack) {
  var target = createTargetName(src);

  babel.transformFile(src, babelOptions, function (err, result) {
    if (err) { return console.log(err.codeFrame); }

    fse.outputFile(target, result.code, function(err) {
      if (err) { return console.error(err.message); }

      console.log(util.format(green + '=> "%s" successfully transpiled to "%s"' + NC, src, target));

      // next
      if (stack && stack.length) {
        transpile(stack.shift(), stack);
      }
    });
  });
}
github thealjey / webcompiler / lib / compiler.js View on Github external
export function packageJS(inPath: string, outPath: string, callback: any = Function.prototype) {
  transformFile(inPath, {loose: 'all', optional: ['runtime']}, function processCompiledJS(e, result) {
    if (e) {
      return consoleError(e);
    }
    fs.writeFile(outPath, result.code, function jsWriteScriptHandler(saveErr) {
      if (saveErr) {
        return consoleError(saveErr);
      }
      console.log('\x1b[32m%s: Compiled %s\x1b[0m', ++i, inPath);
      callback();
    });
  });
}
github jackmoore / sticky-position / build.js View on Github external
function transform(filepath) {
	babel.transformFile(filepath, {modules: 'umd'}, function (err,res) {
		if (err) {
			return console.log(err);
		} else {
			lint(res.code);
			build(res.code);
		}
	});
}
github wavesjs / waves-ui / bin / scripts.js View on Github external
function transpile(src) {
  var target = createTargetName(src);

  babel.transformFile(src, babelOptions, function(err, res) {
    if (err) { return console.log(err.message); }

    fse.outputFile(target, res.code, function(err, res) {
      if (err) { return console.log(err.message); }

      console.log(util.format(green + '=> "%s" successfully transpiled to "%s"' + NC, src, target));
    });
  });
}
github Mango / emitter / babel.js View on Github external
'use strict';

var fs = require('fs');
var babel = require('babel');

if (!fs.existsSync('./es5')) {
  fs.mkdirSync('./es5');
}

babel.transformFile('index.js', {'loose': ['es6.classes']}, function (err, result) {
  if (err) { console.log('Error : ' + err.message); }
  fs.writeFileSync('./es5/index.js', result.code);
});
github jilieryuyi / wing-binlog / web / lang / en / vendors / autosize / build.js View on Github external
function transform(filepath) {
	babel.transformFile(filepath, {modules: 'umd'}, function (err,res) {
		if (err) {
			return console.log(err);
		} else {
			lint(res.code);
			build(res.code);
		}
	});
}
github AzuraCast / AzuraCast / web / static / bower_components / autosize / build.js View on Github external
function transform(filepath) {
	babel.transformFile(filepath, {modules: 'umd'}, function (err,res) {
		if (err) {
			return console.log(err);
		} else {
			lint(res.code);
			build(res.code);
		}
	});
}
github cjihrig / scrabel / lib / index.js View on Github external
Insync.each(files, function (file, next) {
    Babel.transformFile(file.input, options, function (err, result) {
      if (err) {
        return next(err);
      }

      Fse.outputFile(file.output, result.code, next);
    });
  }, callback);
};