Revert "Upgrade to Babel 6 and apply fewer transformations when transpiling babel files"

This commit is contained in:
Antonio Scandurra
2017-03-17 12:40:38 +01:00
committed by GitHub
parent ab17e4042b
commit bade347e01
5 changed files with 11 additions and 42 deletions

View File

@@ -6,7 +6,6 @@ var defaultOptions = require('../static/babelrc.json')
var babel = null
var babelVersionDirectory = null
var options = null
var PREFIXES = [
'/** @babel */',
@@ -48,27 +47,16 @@ exports.compile = function (sourceCode, filePath) {
var noop = function () {}
Logger.prototype.debug = noop
Logger.prototype.verbose = noop
options = {ast: false, babelrc: false}
for (var key in defaultOptions) {
if (key === 'plugins') {
const plugins = []
for (const [pluginName, pluginOptions] of defaultOptions[key]) {
plugins.push([require.resolve(`babel-plugin-${pluginName}`), pluginOptions])
}
options[key] = plugins
} else {
options[key] = defaultOptions[key]
}
}
}
if (process.platform === 'win32') {
filePath = 'file:///' + path.resolve(filePath).replace(/\\/g, '/')
}
options.filename = filePath
var options = {filename: filePath}
for (var key in defaultOptions) {
options[key] = defaultOptions[key]
}
return babel.transform(sourceCode, options).code
}