UNPKG

3.55 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 * A list of directory names in which to recursively look for modules.
35 * @default ['node_modules']
36 */
37 moduleDirectories?: string[];
38
39 /**
40 * A list of absolute paths to additional locations to search for modules.
41 * This is analogous to setting the `NODE_PATH` environment variable for node.
42 * @default []
43 */
44 modulePaths?: string[];
45
46 /**
47 * An `Array` of modules names, which instructs the plugin to force resolving for the
48 * specified modules to the root `node_modules`. Helps to prevent bundling the same
49 * package multiple times if package is imported from dependencies.
50 */
51 dedupe?: string[] | ((importee: string) => boolean);
52
53 /**
54 * Specifies the extensions of files that the plugin will operate on.
55 * @default [ '.mjs', '.js', '.json', '.node' ]
56 */
57 extensions?: readonly string[];
58
59 /**
60 * Locks the module search within specified path (e.g. chroot). Modules defined
61 * outside this path will be marked as external.
62 * @default '/'
63 */
64 jail?: string;
65
66 /**
67 * Specifies the properties to scan within a `package.json`, used to determine the
68 * bundle entry point.
69 * @default ['module', 'main']
70 */
71 mainFields?: readonly string[];
72
73 /**
74 * If `true`, inspect resolved files to assert that they are ES2015 modules.
75 * @default false
76 */
77 modulesOnly?: boolean;
78
79 /**
80 * If `true`, the plugin will prefer built-in modules (e.g. `fs`, `path`). If `false`,
81 * the plugin will look for locally installed modules of the same name.
82 * @default true
83 */
84 preferBuiltins?: boolean;
85
86 /**
87 * An `Array` which instructs the plugin to limit module resolution to those whose
88 * names match patterns in the array.
89 * @default []
90 */
91 resolveOnly?: ReadonlyArray<string | RegExp> | null | ((module: string) => boolean);
92
93 /**
94 * Specifies the root directory from which to resolve modules. Typically used when
95 * resolving entry-point imports, and when resolving deduplicated modules.
96 * @default process.cwd()
97 */
98 rootDir?: string;
99}
100
101/**
102 * Locate modules using the Node resolution algorithm, for using third party modules in node_modules
103 */
104export function nodeResolve(options?: RollupNodeResolveOptions): Plugin;
105export default nodeResolve;
106
\No newline at end of file