UNPKG

3.97 kBTypeScriptView Raw
1import type { 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 *
83 * If a function is provided, it will be called to determine whether to prefer built-ins.
84 * @default true
85 */
86 preferBuiltins?: boolean | ((module: string) => boolean);
87
88 /**
89 * An `Array` which instructs the plugin to limit module resolution to those whose
90 * names match patterns in the array.
91 * @default []
92 */
93 resolveOnly?: ReadonlyArray<string | RegExp> | null | ((module: string) => boolean);
94
95 /**
96 * Specifies the root directory from which to resolve modules. Typically used when
97 * resolving entry-point imports, and when resolving deduplicated modules.
98 * @default process.cwd()
99 */
100 rootDir?: string;
101
102 /**
103 * Allow folder mappings in package exports (trailing /)
104 * This was deprecated in Node 14 and removed with Node 17, see DEP0148.
105 * So this option might be changed to default to `false` in a future release.
106 * @default true
107 */
108 allowExportsFolderMapping?: boolean;
109}
110
111/**
112 * Locate modules using the Node resolution algorithm, for using third party modules in node_modules
113 */
114export function nodeResolve(options?: RollupNodeResolveOptions): Plugin;
115export default nodeResolve;
116
\No newline at end of file