File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -4,14 +4,22 @@ var conf = require("./config");
4
4
var webpack = require ( "webpack" ) ;
5
5
var merge = require ( "webpack-merge" ) ;
6
6
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 ( / ^ n o d e j s / ) ;
13
+ }
14
+
7
15
function webpackConfig ( dir , additionalConfig ) {
8
16
var config = conf . load ( ) ;
9
17
var babelOpts = { cacheDirectory : true } ;
10
18
if ( ! fs . existsSync ( path . join ( process . cwd ( ) , '.babelrc' ) ) ) {
11
19
babelOpts . presets = [
12
20
[ "env" , {
13
21
targets : {
14
- node : "6.10"
22
+ node : getBabelTarget ( )
15
23
}
16
24
} ]
17
25
] ;
You can’t perform that action at this time.
0 commit comments