From 52f59a5dd8293f2945ada8781e8e6c41f274fbd7 Mon Sep 17 00:00:00 2001 From: Angelo Ashmore Date: Tue, 8 Nov 2022 15:51:36 -1000 Subject: [PATCH] feat: add `internalDependencies` option (#2) --- src/index.ts | 1 + src/plugins/extendConfig.ts | 7 ++++++- src/types.ts | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index cd0b7c8..f932782 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,6 +7,7 @@ import type { Options } from "./types"; const DEFAULT_OPTIONS = { dts: true, + internalDependencies: [], }; const sdkPlugin = (rawOptions?: Partial): (Plugin | null)[] => { diff --git a/src/plugins/extendConfig.ts b/src/plugins/extendConfig.ts index 9c22e8f..098e5f9 100644 --- a/src/plugins/extendConfig.ts +++ b/src/plugins/extendConfig.ts @@ -35,7 +35,12 @@ export const extendConfigPlugin = (options: Options): Plugin => { ...Object.keys(options.packageJSON.optionalDependencies ?? {}), ...Object.keys(options.packageJSON.peerDependencies ?? {}), ].map((name) => new RegExp(`^${name}(?:\/.*)?$`)), - ], + ].filter( + (regexp) => + !options.internalDependencies.some((internalDependency) => + regexp.test(internalDependency), + ), + ), output: { preserveModules: true, preserveModulesRoot: "src", diff --git a/src/types.ts b/src/types.ts index 578b07b..f5a688b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -15,6 +15,11 @@ export interface Options { * @defaultValue `true` */ dts: boolean; + + /** + * A list of dependencies to ignore from Rollup's `external` option. + */ + internalDependencies: string[]; } /**