diff --git a/index.js b/index.js index ae0ea28c..92ea856f 100644 --- a/index.js +++ b/index.js @@ -47,16 +47,16 @@ function applyUserConfig(config, userConfig, servicePath, runtime) { const runtimeVersion = Number.parseInt((runtime || "").replace("nodejs", ""), 10) || 12; - // Exclude aws-sdk from default if runtime >= 18 - const forceExclude = config.options.forceExclude.filter( - (item) => !(runtimeVersion >= 18 && item === "aws-sdk") - ); + // Force exclude aws-sdk for versions below Node 18 + if (runtimeVersion < 18) { + config.options.forceExclude.push("aws-sdk"); + } // Concat forceExclude if provided if (userConfig.forceExclude) { - userConfig.forceExclude = forceExclude.concat(userConfig.forceExclude); - } else { - userConfig.forceExclude = forceExclude; + userConfig.forceExclude = config.options.forceExclude.concat( + userConfig.forceExclude + ); } // Concat externals if a list of packages are provided diff --git a/src/config.js b/src/config.js index bd3a99ea..9f6df374 100644 --- a/src/config.js +++ b/src/config.js @@ -20,8 +20,7 @@ module.exports = { packagerOptions: {}, generateStatsFiles: false, tsConfig: "tsconfig.json", - // Exclude aws-sdk since it's available in the Lambda runtime (< nodejs18.x) - forceExclude: ["aws-sdk"], + forceExclude: [], disableForkTsChecker: false, // Set non Webpack compatible packages as externals // Or if we want to exclude all packages in the node_modules: