esbuild-node-externals
Advanced tools
Comparing version 1.9.0 to 1.10.0
# Changelog | ||
## [1.10.0](https://www.github.com/pradel/esbuild-node-externals/compare/v1.9.0...v1.10.0) (2023-11-20) | ||
### Features | ||
* add flag to support workspaces dependencies ([#41](https://www.github.com/pradel/esbuild-node-externals/issues/41)) ([50b01b0](https://www.github.com/pradel/esbuild-node-externals/commit/50b01b0e106c3427b72b3366d47df6876b4ddcc5)) | ||
## [1.9.0](https://www.github.com/pradel/esbuild-node-externals/compare/v1.8.0...v1.9.0) (2023-08-30) | ||
@@ -4,0 +11,0 @@ |
@@ -9,4 +9,5 @@ import type { Plugin } from 'esbuild'; | ||
allowList?: string[]; | ||
allowWorkspaces?: boolean; | ||
} | ||
export declare const nodeExternalsPlugin: (paramsOptions?: Options) => Plugin; | ||
export default nodeExternalsPlugin; |
@@ -12,2 +12,3 @@ "use strict"; | ||
allowList: [], | ||
allowWorkspaces: false, | ||
...paramsOptions, | ||
@@ -27,2 +28,3 @@ packagePath: paramsOptions.packagePath && typeof paramsOptions.packagePath === 'string' | ||
allowList: options.allowList, | ||
allowWorkspaces: options.allowWorkspaces, | ||
}); | ||
@@ -29,0 +31,0 @@ return { |
@@ -9,2 +9,3 @@ export declare const findPackagePaths: () => string[]; | ||
allowList: string[]; | ||
allowWorkspaces: boolean; | ||
}) => string[]; |
@@ -31,2 +31,12 @@ "use strict"; | ||
exports.findPackagePaths = findPackagePaths; | ||
function getDependencyKeys(map = {}, allowWorkspaces = false) { | ||
var _a; | ||
if (!map) { | ||
return []; | ||
} | ||
if (!allowWorkspaces) { | ||
return Object.keys(map); | ||
} | ||
return (_a = Object.keys(map)) === null || _a === void 0 ? void 0 : _a.filter((depKey) => map[depKey] !== 'workspace:*'); | ||
} | ||
const findDependencies = (options) => { | ||
@@ -50,3 +60,3 @@ const packageJsonKeys = [ | ||
return packageJsonKeys | ||
.map((key) => (packageJson[key] ? Object.keys(packageJson[key]) : [])) | ||
.map((key) => getDependencyKeys(packageJson[key], options.allowWorkspaces)) | ||
.flat(1) | ||
@@ -53,0 +63,0 @@ .filter((packageName) => !options.allowList.includes(packageName)); |
{ | ||
"name": "esbuild-node-externals", | ||
"version": "1.9.0", | ||
"version": "1.10.0", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "typings": "dist/index.d.ts", |
@@ -85,2 +85,6 @@ # esbuild-node-externals | ||
#### `options.allowWorkspaces` (default to `false`) | ||
Automatically exclude all packages defined as workspaces (`workspace:*`) in a monorepo. | ||
## Inspiration | ||
@@ -87,0 +91,0 @@ |
@@ -12,2 +12,3 @@ import type { Plugin } from 'esbuild'; | ||
allowList?: string[]; | ||
allowWorkspaces?: boolean; | ||
} | ||
@@ -22,2 +23,3 @@ | ||
allowList: [] as string[], | ||
allowWorkspaces: false, | ||
...paramsOptions, | ||
@@ -39,2 +41,3 @@ packagePath: | ||
allowList: options.allowList, | ||
allowWorkspaces: options.allowWorkspaces, | ||
}); | ||
@@ -41,0 +44,0 @@ |
@@ -46,2 +46,13 @@ import path from 'path'; | ||
function getDependencyKeys(map: Record<string, string> = {}, allowWorkspaces: boolean = false): string[] { | ||
if (!map) { | ||
return []; | ||
} | ||
if (!allowWorkspaces) { | ||
return Object.keys(map); | ||
} | ||
// Filter out shared workspaces | ||
return Object.keys(map)?.filter((depKey) => map[depKey] !== 'workspace:*'); | ||
} | ||
/** | ||
@@ -57,2 +68,3 @@ * Return an array of the package.json dependencies that should be excluded from the build. | ||
allowList: string[]; | ||
allowWorkspaces: boolean; | ||
}): string[] => { | ||
@@ -79,3 +91,4 @@ const packageJsonKeys = [ | ||
return packageJsonKeys | ||
.map((key) => (packageJson[key] ? Object.keys(packageJson[key]) : [])) | ||
// Automatically exclude keys for interconnected yarn workspaces. | ||
.map((key) => getDependencyKeys(packageJson[key], options.allowWorkspaces)) | ||
.flat(1) | ||
@@ -82,0 +95,0 @@ .filter((packageName) => !options.allowList.includes(packageName)); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
24415
284
96