Skip to content

Commit

Permalink
custom babel target for each node version
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardodino committed Apr 4, 2018
1 parent 9f6a6d0 commit 1008ebc
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,22 @@ var conf = require("./config");
var webpack = require("webpack");
var merge = require("webpack-merge");

// custom babel target for each node version
function getBabelTarget(){
var runtimes = ["nodejs8.10", "nodejs4.3.2", "nodejs6.10.3"];
var current = process.env["AWS_LAMBDA_JS_RUNTIME"] || "nodejs6.10.3";
var unknown = runtimes.indexOf(current) === -1;
return unknown ? "6.10" : current.replace(/^nodejs/);
}

function webpackConfig(dir, additionalConfig) {
var config = conf.load();
var babelOpts = {cacheDirectory: true};
if (!fs.existsSync(path.join(process.cwd(), '.babelrc'))) {
babelOpts.presets = [
["env", {
targets: {
node: "6.10"
node: getBabelTarget()
}
}]
];
Expand Down

0 comments on commit 1008ebc

Please sign in to comment.