Skip to content

Commit

Permalink
feat: allow options to be function
Browse files Browse the repository at this point in the history
  • Loading branch information
kshutkin committed Oct 11, 2023
1 parent 2f719ca commit 5ef5451
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/eight-actors-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rollup-extras/plugin-externals": minor
---

allow options to be function
3 changes: 3 additions & 0 deletions plugin-externals/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import packageDirectory from 'pkg-dir';
const factories = { logger };

export default function(options: ExternalsPluginOptions = {}) {
if (typeof options === 'function') {
options = { external: options };
}
const { pluginName, external, logger, verbose } = getOptionsObject(options, {
pluginName: '@rollup-extras/plugin-externals',
verbose: false
Expand Down
2 changes: 1 addition & 1 deletion plugin-externals/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ export type ExternalsPluginOptions = {
pluginName?: string,
verbose?: boolean,
external?: (id: string, external: boolean, importer?: string) => boolean
};
} | ((id: string, external: boolean, importer?: string) => boolean);

0 comments on commit 5ef5451

Please sign in to comment.