Skip to content

Commit 1008ebc

Browse files
committed
custom babel target for each node version
1 parent 9f6a6d0 commit 1008ebc

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/build.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,22 @@ var conf = require("./config");
44
var webpack = require("webpack");
55
var merge = require("webpack-merge");
66

7+
// custom babel target for each node version
8+
function getBabelTarget(){
9+
var runtimes = ["nodejs8.10", "nodejs4.3.2", "nodejs6.10.3"];
10+
var current = process.env["AWS_LAMBDA_JS_RUNTIME"] || "nodejs6.10.3";
11+
var unknown = runtimes.indexOf(current) === -1;
12+
return unknown ? "6.10" : current.replace(/^nodejs/);
13+
}
14+
715
function webpackConfig(dir, additionalConfig) {
816
var config = conf.load();
917
var babelOpts = {cacheDirectory: true};
1018
if (!fs.existsSync(path.join(process.cwd(), '.babelrc'))) {
1119
babelOpts.presets = [
1220
["env", {
1321
targets: {
14-
node: "6.10"
22+
node: getBabelTarget()
1523
}
1624
}]
1725
];

0 commit comments

Comments
 (0)