1 | import type { Plugin } from 'rollup';
|
2 | type MaybeFalsy<T> = (T) | undefined | null | false;
|
3 | type MaybeArray<T> = (T) | (T)[];
|
4 | export interface ExternalsOptions {
|
5 | /**
|
6 | * Mark node built-in modules like `path`, `fs`... as external.
|
7 | *
|
8 | * Defaults to `true`.
|
9 | */
|
10 | builtins?: boolean;
|
11 | /**
|
12 | * node: prefix handing for importing Node builtins:
|
13 | * - `'add'` turns `'path'` to `'node:path'`
|
14 | * - `'strip'` turns `'node:path'` to `'path'`
|
15 | * - `'ignore'` leaves Node builtin names as-is
|
16 | *
|
17 | * Defaults to `add`.
|
18 | */
|
19 | builtinsPrefix?: 'add' | 'strip' | 'ignore';
|
20 | /**
|
21 | * Path/to/your/package.json file (or array of paths).
|
22 | *
|
23 | * Defaults to all package.json files found in parent directories recursively.
|
24 | * Won't go outside of a git repository.
|
25 | */
|
26 | packagePath?: string | string[];
|
27 | /**
|
28 | * Mark dependencies as external.
|
29 | *
|
30 | * Defaults to `true`.
|
31 | */
|
32 | deps?: boolean;
|
33 | /**
|
34 | * Mark devDependencies as external.
|
35 | *
|
36 | * Defaults to `false`.
|
37 | */
|
38 | devDeps?: boolean;
|
39 | /**
|
40 | * Mark peerDependencies as external.
|
41 | *
|
42 | * Defaults to `true`.
|
43 | */
|
44 | peerDeps?: boolean;
|
45 | /**
|
46 | * Mark optionalDependencies as external.
|
47 | *
|
48 | * Defaults to `true`.
|
49 | */
|
50 | optDeps?: boolean;
|
51 | /**
|
52 | * Force include these deps in the list of externals, regardless of other settings.
|
53 | *
|
54 | * Defaults to `[]` (force include nothing).
|
55 | */
|
56 | include?: MaybeArray<MaybeFalsy<string | RegExp>>;
|
57 | /**
|
58 | * Force exclude these deps from the list of externals, regardless of other settings.
|
59 | *
|
60 | * Defaults to `[]` (force exclude nothing).
|
61 | */
|
62 | exclude?: MaybeArray<MaybeFalsy<string | RegExp>>;
|
63 | }
|
64 | /**
|
65 | * A Rollup/Vite plugin that automatically declares NodeJS built-in modules,
|
66 | * and optionally npm dependencies, as 'external'.
|
67 | */
|
68 | declare function nodeExternals(options?: ExternalsOptions): Plugin;
|
69 | export default nodeExternals;
|
70 | export { nodeExternals };
|