|
|
@ -25,6 +25,7 @@ CachingPrecompiler.prototype._factory = function (babelConfig, cacheDir) { |
|
|
|
var presetES2015 = require('babel-preset-es2015'); |
|
|
|
var transformRuntime = require('babel-plugin-transform-runtime'); |
|
|
|
|
|
|
|
var rewriteRuntime = this._createRewritePlugin(); |
|
|
|
var powerAssert = this._createEspowerPlugin(babel); |
|
|
|
|
|
|
|
function buildOptions(filename, code) { |
|
|
@ -49,7 +50,7 @@ CachingPrecompiler.prototype._factory = function (babelConfig, cacheDir) { |
|
|
|
}); |
|
|
|
|
|
|
|
options.plugins = options.plugins || []; |
|
|
|
options.plugins.push(powerAssert, transformRuntime); |
|
|
|
options.plugins.push(powerAssert, transformRuntime, rewriteRuntime); |
|
|
|
|
|
|
|
return options; |
|
|
|
} |
|
|
@ -64,6 +65,22 @@ CachingPrecompiler.prototype._factory = function (babelConfig, cacheDir) { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
CachingPrecompiler.prototype._createRewritePlugin = function () { |
|
|
|
var wrapListener = require('babel-plugin-detective/wrap-listener'); |
|
|
|
|
|
|
|
function rewriteRuntimeListener(path) { |
|
|
|
if (path.isLiteral() && /^babel-runtime[\\\/]?/.test(path.node.value)) { |
|
|
|
path.node.value = require.resolve(path.node.value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return wrapListener(rewriteRuntimeListener, 'rewrite-runtime', { |
|
|
|
generated: true, |
|
|
|
require: true, |
|
|
|
import: true |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
CachingPrecompiler.prototype._createEspowerPlugin = function (babel) { |
|
|
|
var createEspowerPlugin = require('babel-plugin-espower/create'); |
|
|
|
var enhanceAssert = require('./enhance-assert'); |
|
|
|