Huge News!Announcing our $40M Series B led by Abstract Ventures.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.5.0 to 1.6.0

7

CHANGELOG.md
# Changelog
## [1.6.0](https://www.github.com/pradel/esbuild-node-externals/compare/v1.5.0...v1.6.0) (2022-12-12)
### Features
* allow esbuild 0.16 ([#35](https://www.github.com/pradel/esbuild-node-externals/issues/35)) ([881f75b](https://www.github.com/pradel/esbuild-node-externals/commit/881f75ba61a18b888c54d1dafb0ac5d11d05c65c))
## [1.5.0](https://www.github.com/pradel/esbuild-node-externals/compare/v1.4.1...v1.5.0) (2022-08-29)

@@ -4,0 +11,0 @@

2

dist/index.d.ts

@@ -1,2 +0,2 @@

import { Plugin } from 'esbuild';
import type { Plugin } from 'esbuild';
export interface Options {

@@ -3,0 +3,0 @@ packagePath?: string | string[];

@@ -6,5 +6,13 @@ "use strict";

const nodeExternalsPlugin = (paramsOptions = {}) => {
const options = Object.assign(Object.assign({ dependencies: true, devDependencies: true, peerDependencies: true, optionalDependencies: true, allowList: [] }, paramsOptions), { packagePath: paramsOptions.packagePath && typeof paramsOptions.packagePath === 'string'
const options = {
dependencies: true,
devDependencies: true,
peerDependencies: true,
optionalDependencies: true,
allowList: [],
...paramsOptions,
packagePath: paramsOptions.packagePath && typeof paramsOptions.packagePath === 'string'
? [paramsOptions.packagePath]
: paramsOptions.packagePath });
: paramsOptions.packagePath,
};
const nodeModules = (0, utils_1.findDependencies)({

@@ -23,11 +31,7 @@ packagePaths: options.packagePath

setup(build) {
// On every module resolved, we check if the module name should be an external
build.onResolve({ namespace: 'file', filter: /.*/ }, (args) => {
// To allow allowList to target sub imports
if (options.allowList.includes(args.path)) {
return null;
}
// To allow sub imports from packages we take only the first path to deduct the name
let moduleName = args.path.split('/')[0];
// In case of scoped package
if (args.path.startsWith('@')) {

@@ -37,3 +41,2 @@ const split = args.path.split('/');

}
// Mark the module as external so it is not resolved
if (nodeModules.includes(moduleName)) {

@@ -40,0 +43,0 @@ return { path: args.path, external: true };

@@ -1,11 +0,2 @@

/**
* Iterates over package.json file paths recursively found in parent directories, starting from the
* current working directory. If the current working directory is in a git repository, then package.json
* files outside of the git repository will not be yielded.
* Inspired by https://github.com/Septh/rollup-plugin-node-externals/blob/f13ee95c6f1f01d8ba2276bf491aac399adc5482/src/dependencies.ts#L18
*/
export declare const findPackagePaths: () => string[];
/**
* Return an array of the package.json dependencies that should be excluded from the build.
*/
export declare const findDependencies: (options: {

@@ -12,0 +3,0 @@ packagePaths: string[];

@@ -5,8 +5,5 @@ "use strict";

const tslib_1 = require("tslib");
const path_1 = (0, tslib_1.__importDefault)(require("path"));
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
const find_up_1 = (0, tslib_1.__importDefault)(require("find-up"));
/**
* Determines if the `child` path is under the `parent` path.
*/
const path_1 = tslib_1.__importDefault(require("path"));
const fs_1 = tslib_1.__importDefault(require("fs"));
const find_up_1 = tslib_1.__importDefault(require("find-up"));
const isInDirectory = (parent, child) => {

@@ -19,10 +16,3 @@ const relativePath = path_1.default.relative(parent, child);

};
/**
* Iterates over package.json file paths recursively found in parent directories, starting from the
* current working directory. If the current working directory is in a git repository, then package.json
* files outside of the git repository will not be yielded.
* Inspired by https://github.com/Septh/rollup-plugin-node-externals/blob/f13ee95c6f1f01d8ba2276bf491aac399adc5482/src/dependencies.ts#L18
*/
const findPackagePaths = () => {
// Find git root if in git repository
const gitDirectoryPath = find_up_1.default.sync('.git', {

@@ -43,5 +33,2 @@ type: 'directory',

exports.findPackagePaths = findPackagePaths;
/**
* Return an array of the package.json dependencies that should be excluded from the build.
*/
const findDependencies = (options) => {

@@ -48,0 +35,0 @@ const packageJsonKeys = [

{
"name": "esbuild-node-externals",
"version": "1.5.0",
"version": "1.6.0",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"scripts": {
"typecheck": "tsc --noEmit",
"prebuild": "rimraf ./dist",
"build": "tsc",

@@ -23,14 +25,18 @@ "watch": "tsc --watch"

],
"engines": {
"node": ">=12"
},
"dependencies": {
"find-up": "^5.0.0",
"tslib": "^2.4.1"
},
"peerDependencies": {
"esbuild": "0.12 - 0.15"
"esbuild": "0.12 - 0.16"
},
"devDependencies": {
"@types/node": "16.11.7",
"esbuild": "^0.13.0",
"typescript": "4.4.4"
},
"dependencies": {
"find-up": "5.0.0",
"tslib": "2.3.1"
"esbuild": "^0.16.4",
"rimraf": "^3.0.2",
"typescript": "^4.9.4"
}
}

@@ -1,2 +0,3 @@

import { Plugin } from 'esbuild';
import type { Plugin } from 'esbuild';
import { findPackagePaths, findDependencies } from './utils';

@@ -3,0 +4,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