UNPKG

2.73 kBTypeScriptView Raw
1import {Plugin} from 'rollup';
2import {AsyncOpts} from 'resolve';
3
4export interface Options {
5 /**
6 * the fields to scan in a package.json to determine the entry point
7 * if this list contains "browser", overrides specified in "pkg.browser"
8 * will be used
9 * @default ['module', 'main']
10 */
11 mainFields?: ReadonlyArray<string>;
12
13 /**
14 * @deprecated use "mainFields" instead
15 * use "module" field for ES6 module if possible
16 * @default true
17 */
18 module?: boolean;
19
20 /**
21 * @deprecated use "mainFields" instead
22 * use "jsnext:main" if possible
23 * legacy field pointing to ES6 module in third-party libraries,
24 * deprecated in favor of "pkg.module":
25 * - see: https://github.com/rollup/rollup/wiki/pkg.module
26 * @default false
27 */
28 jsnext?: boolean;
29
30 /**
31 * @deprecated use "mainFields" instead
32 * use "main" field or index.js, even if it's not an ES6 module
33 * (needs to be converted from CommonJS to ES6)
34 * – see https://github.com/rollup/rollup-plugin-commonjs
35 * @default true
36 */
37 main?: boolean;
38
39 /**
40 * some package.json files have a "browser" field which specifies
41 * alternative files to load for people bundling for the browser. If
42 * that's you, either use this option or add "browser" to the
43 * "mainfields" option, otherwise pkg.browser will be ignored
44 * @default false
45 */
46 browser?: boolean;
47
48 /**
49 * not all files you want to resolve are .js files
50 * @default [ '.mjs', '.js', '.json', '.node' ]
51 */
52 extensions?: ReadonlyArray<string>;
53
54 /**
55 * whether to prefer built-in modules (e.g. `fs`, `path`) or
56 * local ones with the same names
57 * @default true
58 */
59 preferBuiltins?: boolean;
60
61 /**
62 * Lock the module search in this path (like a chroot). Module defined
63 * outside this path will be marked as external
64 * @default '/'
65 */
66 jail?: string;
67
68 /**
69 * Set to an array of strings and/or regexps to lock the module search
70 * to modules that match at least one entry. Modules not matching any
71 * entry will be marked as external
72 * @default null
73 */
74 only?: ReadonlyArray<string | RegExp> | null;
75
76 /**
77 * If true, inspect resolved files to check that they are
78 * ES2015 modules
79 * @default false
80 */
81 modulesOnly?: boolean;
82
83 /**
84 * Force resolving for these modules to root's node_modules that helps
85 * to prevent bundling the same package multiple times if package is
86 * imported from dependencies.
87 */
88 dedupe?: string[] | ((importee: string) => boolean);
89
90 /**
91 * Any additional options that should be passed through
92 * to node-resolve
93 */
94 customResolveOptions?: AsyncOpts;
95}
96
97/**
98 * Locate modules using the Node resolution algorithm, for using third party modules in node_modules
99 */
100export default function nodeResolve(options?: Options): Plugin;