serverless-esbuild
Advanced tools
Comparing version
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.packExternalModules = void 0; | ||
exports.packExternalModules = exports.nodeExternalsPluginUtilsPath = void 0; | ||
const path_1 = __importDefault(require("path")); | ||
@@ -104,2 +104,14 @@ const fs_extra_1 = __importDefault(require("fs-extra")); | ||
} | ||
function nodeExternalsPluginUtilsPath() { | ||
try { | ||
const resolvedPackage = require.resolve('esbuild-node-externals/dist/utils', { | ||
paths: [process.cwd()], | ||
}); | ||
return resolvedPackage; | ||
} | ||
catch { | ||
// No-op | ||
} | ||
} | ||
exports.nodeExternalsPluginUtilsPath = nodeExternalsPluginUtilsPath; | ||
/** | ||
@@ -121,12 +133,15 @@ * We need a performant algorithm to install the packages for each single | ||
const plugins = this.plugins; | ||
if (plugins && | ||
plugins.map((plugin) => plugin.name).includes('node-externals') && | ||
fs_extra_1.default.existsSync(path_1.default.resolve(__dirname, '../../esbuild-node-externals/dist/utils.js'))) { | ||
const { findDependencies, findPackagePaths } = require('esbuild-node-externals/dist/utils'); | ||
const allowList = ((_b = (_a = this.buildOptions) === null || _a === void 0 ? void 0 : _a.nodeExternals) === null || _b === void 0 ? void 0 : _b.allowList) ? this.buildOptions.nodeExternals.allowList : []; | ||
this.buildOptions.external = findDependencies({ | ||
dependencies: true, | ||
packagePaths: findPackagePaths(), | ||
allowList, | ||
}); | ||
if (plugins && plugins.map((plugin) => plugin.name).includes('node-externals')) { | ||
const utilsPath = nodeExternalsPluginUtilsPath(); | ||
if (utilsPath) { | ||
const { findDependencies, findPackagePaths, } = require(utilsPath); | ||
this.buildOptions.external = findDependencies({ | ||
packagePaths: findPackagePaths(), | ||
dependencies: true, | ||
devDependencies: false, | ||
peerDependencies: false, | ||
optionalDependencies: false, | ||
allowList: (_b = (_a = this.buildOptions.nodeExternals) === null || _a === void 0 ? void 0 : _a.allowList) !== null && _b !== void 0 ? _b : [], | ||
}); | ||
} | ||
} | ||
@@ -133,0 +148,0 @@ let externals = []; |
{ | ||
"name": "serverless-esbuild", | ||
"version": "1.33.2", | ||
"version": "1.34.0", | ||
"description": "Serverless plugin for zero-config JavaScript and TypeScript code bundling using extremely fast esbuild", | ||
@@ -83,3 +83,4 @@ "keywords": [ | ||
"@typescript-eslint/parser": "^5.34.0", | ||
"esbuild": "^0.15.9", | ||
"esbuild": "^0.16.4", | ||
"esbuild-node-externals": "^1.6.0", | ||
"eslint": "^8.20.0", | ||
@@ -97,4 +98,10 @@ "husky": "^8.0.1", | ||
"peerDependencies": { | ||
"esbuild": ">=0.8 <0.16" | ||
"esbuild": ">=0.8 <0.17", | ||
"esbuild-node-externals": "^1.0.0" | ||
}, | ||
"peerDependenciesMeta": { | ||
"esbuild-node-externals": { | ||
"optional": true | ||
} | ||
}, | ||
"engines": { | ||
@@ -101,0 +108,0 @@ "node": ">=16.0.0" |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
99215
0.56%1701
0.89%13
8.33%24
4.35%10
11.11%