fix(babel): Resolve require paths for presets, fix plugin ES6 support

This commit is contained in:
Ben Gotow 2016-05-15 17:52:49 -05:00
parent 3344223bfc
commit dafe2d89ba

View file

@ -2,7 +2,6 @@
var crypto = require('crypto')
var path = require('path')
var defaultOptions = require('../../static/babelrc.json')
var babel = null
var babelVersionDirectory = null
@ -12,6 +11,14 @@ var babelVersionDirectory = null
// babel-polyfill.
require('babel-regenerator-runtime');
// We run babel with lots of different working directories (like plugin folders).
// To make sure presets always resolve to the correct path inside N1, resolve
// them to their absolute paths ahead of time.
var defaultOptions = require('../../static/babelrc.json')
defaultOptions.presets = defaultOptions.presets.map((modulename) =>
require.resolve(`babel-preset-${modulename}`)
);
exports.shouldCompile = function (sourceCode, filePath) {
return (filePath.endsWith('.es6') || filePath.endsWith('.jsx'))
}