UNPKG

3.33 kBTypeScriptView Raw
1import { Plugin } from 'rollup';
2
3export const DEFAULTS: {
4 customResolveOptions: {};
5 dedupe: [];
6 extensions: ['.mjs', '.js', '.json', '.node'];
7 resolveOnly: [];
8};
9
10export interface RollupNodeResolveOptions {
11 /**
12 * Additional conditions of the package.json exports field to match when resolving modules.
13 * By default, this plugin looks for the `'default', 'module', 'import']` conditions when resolving imports.
14 *
15 * When using `@rollup/plugin-commonjs` v16 or higher, this plugin will use the
16 * `['default', 'module', 'import']` conditions when resolving require statements.
17 *
18 * Setting this option will add extra conditions on top of the default conditions.
19 * See https://nodejs.org/api/packages.html#packages_conditional_exports for more information.
20 */
21 exportConditions?: string[];
22
23 /**
24 * If `true`, instructs the plugin to use the `"browser"` property in `package.json`
25 * files to specify alternative files to load for bundling. This is useful when
26 * bundling for a browser environment. Alternatively, a value of `'browser'` can be
27 * added to the `mainFields` option. If `false`, any `"browser"` properties in
28 * package files will be ignored. This option takes precedence over `mainFields`.
29 * @default false
30 */
31 browser?: boolean;
32
33 /**
34 * One or more directories in which to recursively look for modules.
35 * @default ['node_modules']
36 */
37 moduleDirectories?: string[];
38
39 /**
40 * An `Array` of modules names, which instructs the plugin to force resolving for the
41 * specified modules to the root `node_modules`. Helps to prevent bundling the same
42 * package multiple times if package is imported from dependencies.
43 */
44 dedupe?: string[] | ((importee: string) => boolean);
45
46 /**
47 * Specifies the extensions of files that the plugin will operate on.
48 * @default [ '.mjs', '.js', '.json', '.node' ]
49 */
50 extensions?: readonly string[];
51
52 /**
53 * Locks the module search within specified path (e.g. chroot). Modules defined
54 * outside this path will be marked as external.
55 * @default '/'
56 */
57 jail?: string;
58
59 /**
60 * Specifies the properties to scan within a `package.json`, used to determine the
61 * bundle entry point.
62 * @default ['module', 'main']
63 */
64 mainFields?: readonly string[];
65
66 /**
67 * If `true`, inspect resolved files to assert that they are ES2015 modules.
68 * @default false
69 */
70 modulesOnly?: boolean;
71
72 /**
73 * If `true`, the plugin will prefer built-in modules (e.g. `fs`, `path`). If `false`,
74 * the plugin will look for locally installed modules of the same name.
75 * @default true
76 */
77 preferBuiltins?: boolean;
78
79 /**
80 * An `Array` which instructs the plugin to limit module resolution to those whose
81 * names match patterns in the array.
82 * @default []
83 */
84 resolveOnly?: ReadonlyArray<string | RegExp> | null | ((module: string) => boolean);
85
86 /**
87 * Specifies the root directory from which to resolve modules. Typically used when
88 * resolving entry-point imports, and when resolving deduplicated modules.
89 * @default process.cwd()
90 */
91 rootDir?: string;
92}
93
94/**
95 * Locate modules using the Node resolution algorithm, for using third party modules in node_modules
96 */
97export function nodeResolve(options?: RollupNodeResolveOptions): Plugin;
98export default nodeResolve;
99
\No newline at end of file