How to use the babel.transformFileSync 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 shuhei / babel-plugin-auto-assign / test / index.js View on Github external
it(fixtureName, function () {
    var fixturePath = path.resolve(__dirname, 'fixtures', fixtureName, 'fixture.js');
    var expectedPath = path.resolve(__dirname, 'fixtures', fixtureName, 'expected.js');
    var actual = babel.transformFileSync(fixturePath, {
      optional: ['es7.decorators'],
      plugins: ['../lib'],
      externalHelpers: true
    }).code;
    var expected = fs.readFileSync(expectedPath, { encoding: 'utf8' });
    assert.equal(actual + '\n', expected);
  });
}
github jridgewell / babel-plugin-transform-incremental-dom / test / index.js View on Github external
function transform(path, extra) {
  return babel.transformFileSync(path, {
    blacklist: ['strict', 'react'],
    plugins: [plugin],
    extra: extra
  }).code;
}
github restrry / babel-plugin-source-wrapper / test / index.js View on Github external
function runTest() {

    var output = babel.transformFileSync(actualPath, {
        sourceMaps: true,
        optional: ['runtime'],
        plugins: [
            require(pluginPath)({
                "registratorName": "loc_h8tz9yd7f1zl4t3711yc",
                "blackbox": ["**/fixtures/**"]
            })
        ]
    });

    var expected = fs.readFileSync(expectedPath, 'utf-8').replace(/\{\{(.*)\}\}/g, actualPath);

    diff.diffLines(
        normalizeLines(output.code),
        normalizeLines(expected)
    )
github olistic / warriorjs / src / Level.js View on Github external
loadPlayer() {
    eval(babel.transformFileSync(path.join(this.getPlayerPath(), 'Player.js')).code);
  }
github Globegitter / Nord.js / src / server.js View on Github external
'stage'    : 0,
      'blacklist': [
        'react',
        'es7.comprehensions',
        'es7.doExpressions',
        'es7.functionBind',
        'es7.objectRestSpread',
        'es7.trailingFunctionCommas'
      ],
      'loose'   : true,
      'optional': ['runtime'],
      'modules' : 'common'
    };

    for (const filePath of appFiles) {
      const {code} = transformFileSync(filePath, babelOptions);
      const filename = path.relative(this.userRootPath, filePath);
      const outFile = path.join(outPath, filename);
      fs.outputFileSync(outFile, code);
      outFiles.push(outFile);
    }

    return outFiles;
  }