New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

esbuild-node-externals

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esbuild-node-externals - npm Package Compare versions

Comparing version 1.11.0 to 1.12.0

12

CHANGELOG.md
# Changelog
## [1.12.0](https://www.github.com/pradel/esbuild-node-externals/compare/v1.11.0...v1.12.0) (2023-12-20)
### Features
* handle esbuild `absWorkingDir` option ([#52](https://www.github.com/pradel/esbuild-node-externals/issues/52)) ([8e6e809](https://www.github.com/pradel/esbuild-node-externals/commit/8e6e809d4d643e97991d58df3e14c7d56f2c73e0))
### Bug Fixes
* enhance workspaced deps filter ([#53](https://www.github.com/pradel/esbuild-node-externals/issues/53)) ([83ed85a](https://www.github.com/pradel/esbuild-node-externals/commit/83ed85a9ba1a3670551bdb9bdba525d219a56065))
## [1.11.0](https://www.github.com/pradel/esbuild-node-externals/compare/v1.10.0...v1.11.0) (2023-11-20)

@@ -4,0 +16,0 @@

1

dist/index.d.ts

@@ -11,4 +11,5 @@ import type { Plugin } from 'esbuild';

allowWorkspaces?: boolean;
cwd?: string;
}
export declare const nodeExternalsPlugin: (paramsOptions?: Options) => Plugin;
export default nodeExternalsPlugin;

31

dist/index.js

@@ -5,2 +5,10 @@ "use strict";

const utils_1 = require("./utils");
const foundPackagePaths = new Map();
const findPackagePathsMemoized = (cwd) => {
if (foundPackagePaths.has(cwd)) {
return foundPackagePaths.get(cwd);
}
foundPackagePaths.set(cwd, (0, utils_1.findPackagePaths)(cwd));
return findPackagePathsMemoized(cwd);
};
const nodeExternalsPlugin = (paramsOptions = {}) => {

@@ -19,16 +27,17 @@ const options = {

const allowPredicate = options.allowList && (0, utils_1.createAllowPredicate)(options.allowList);
const nodeModules = (0, utils_1.findDependencies)({
packagePaths: options.packagePath
? options.packagePath
: (0, utils_1.findPackagePaths)(),
dependencies: options.dependencies,
devDependencies: options.devDependencies,
peerDependencies: options.peerDependencies,
optionalDependencies: options.optionalDependencies,
allowPredicate,
allowWorkspaces: options.allowWorkspaces,
});
return {
name: 'node-externals',
setup(build) {
const cwd = options.cwd || build.initialOptions.absWorkingDir || process.cwd();
const nodeModules = (0, utils_1.findDependencies)({
packagePaths: options.packagePath
? options.packagePath
: findPackagePathsMemoized(cwd),
dependencies: options.dependencies,
devDependencies: options.devDependencies,
peerDependencies: options.peerDependencies,
optionalDependencies: options.optionalDependencies,
allowPredicate,
allowWorkspaces: options.allowWorkspaces,
});
build.onResolve({ namespace: 'file', filter: /.*/ }, (args) => {

@@ -35,0 +44,0 @@ if (allowPredicate === null || allowPredicate === void 0 ? void 0 : allowPredicate(args.path)) {

export type AllowPredicate = (path: string) => boolean;
export type AllowList = (string | RegExp)[] | AllowPredicate;
export declare const createAllowPredicate: (allowList: AllowList) => AllowPredicate;
export declare const findPackagePaths: () => string[];
export declare const findPackagePaths: (_cwd?: string) => string[];
export declare const findDependencies: (options: {

@@ -6,0 +6,0 @@ packagePaths: string[];

@@ -21,8 +21,9 @@ "use strict";

};
const findPackagePaths = () => {
const findPackagePaths = (_cwd = process.cwd()) => {
const gitDirectoryPath = find_up_1.default.sync('.git', {
type: 'directory',
cwd: _cwd,
});
const gitRootPath = gitDirectoryPath === undefined ? undefined : path_1.default.dirname(gitDirectoryPath);
let cwd = process.cwd();
let cwd = _cwd;
let packagePath;

@@ -39,3 +40,2 @@ const packagePaths = [];

function getDependencyKeys(map = {}, allowWorkspaces = false) {
var _a;
if (!map) {

@@ -47,3 +47,3 @@ return [];

}
return (_a = Object.keys(map)) === null || _a === void 0 ? void 0 : _a.filter((depKey) => map[depKey] !== 'workspace:*');
return Object.keys(map).filter((depKey) => !map[depKey].startsWith('workspace:'));
}

@@ -50,0 +50,0 @@ const findDependencies = (options) => {

{
"name": "esbuild-node-externals",
"version": "1.11.0",
"version": "1.12.0",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "typings": "dist/index.d.ts",

@@ -89,2 +89,6 @@ # esbuild-node-externals

#### `options.cwd` (default to `buildOptions.absWorkingDir || process.cwd()`)
Sets the current working directory for the plugin.
## Inspiration

@@ -91,0 +95,0 @@

@@ -18,4 +18,15 @@ import type { Plugin } from 'esbuild';

allowWorkspaces?: boolean;
cwd?: string;
}
const foundPackagePaths: Map<string, string[]> = new Map();
const findPackagePathsMemoized = (cwd: string): string[] => {
if (foundPackagePaths.has(cwd)) {
return foundPackagePaths.get(cwd)!;
}
foundPackagePaths.set(cwd, findPackagePaths(cwd));
return findPackagePathsMemoized(cwd);
};
export const nodeExternalsPlugin = (paramsOptions: Options = {}): Plugin => {

@@ -38,13 +49,2 @@ const options = {

const nodeModules = findDependencies({
packagePaths: options.packagePath
? options.packagePath
: findPackagePaths(),
dependencies: options.dependencies,
devDependencies: options.devDependencies,
peerDependencies: options.peerDependencies,
optionalDependencies: options.optionalDependencies,
allowPredicate,
allowWorkspaces: options.allowWorkspaces,
});

@@ -54,2 +54,14 @@ return {

setup(build) {
const cwd = options.cwd || build.initialOptions.absWorkingDir || process.cwd()
const nodeModules = findDependencies({
packagePaths: options.packagePath
? options.packagePath
: findPackagePathsMemoized(cwd),
dependencies: options.dependencies,
devDependencies: options.devDependencies,
peerDependencies: options.peerDependencies,
optionalDependencies: options.optionalDependencies,
allowPredicate,
allowWorkspaces: options.allowWorkspaces,
});
// On every module resolved, we check if the module name should be an external

@@ -56,0 +68,0 @@ build.onResolve({ namespace: 'file', filter: /.*/ }, (args) => {

@@ -37,6 +37,7 @@ import path from 'path';

*/
export const findPackagePaths = (): string[] => {
export const findPackagePaths = (_cwd: string = process.cwd()): string[] => {
// Find git root if in git repository
const gitDirectoryPath = findUp.sync('.git', {
type: 'directory',
cwd: _cwd,
});

@@ -46,3 +47,3 @@ const gitRootPath: string | undefined =

let cwd: string = process.cwd();
let cwd: string = _cwd;
let packagePath: string | undefined;

@@ -73,3 +74,3 @@ const packagePaths: string[] = [];

// Filter out shared workspaces
return Object.keys(map)?.filter((depKey) => map[depKey] !== 'workspace:*');
return Object.keys(map).filter((depKey) => !map[depKey].startsWith('workspace:'));
}

@@ -76,0 +77,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc