@rollup/plugin-node-resolve 6.0.0 → 7.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -2
- package/README.md +63 -54
- package/dist/index.es.js +436 -325
- package/dist/index.js +436 -325
- package/package.json +12 -14
- package/types/index.d.ts +40 -56
package/CHANGELOG.md
CHANGED
@@ -1,10 +1,50 @@
|
|
1
|
-
# @rollup/plugin-node-resolve
|
1
|
+
# @rollup/plugin-node-resolve ChangeLog
|
2
|
+
|
3
|
+
## v7.1.1
|
4
|
+
|
5
|
+
_2020-02-03_
|
6
|
+
|
7
|
+
### Bugfixes
|
8
|
+
|
9
|
+
- fix: main fields regression (#196)
|
10
|
+
|
11
|
+
## v7.1.0
|
12
|
+
|
13
|
+
_2020-02-01_
|
14
|
+
|
15
|
+
### Updates
|
16
|
+
|
17
|
+
- refactor: clean codebase and fix external warnings (#155)
|
18
|
+
|
19
|
+
## v7.0.0
|
20
|
+
|
21
|
+
_2020-01-07_
|
22
|
+
|
23
|
+
### Breaking Changes
|
24
|
+
|
25
|
+
- feat: dedupe by package name (#99)
|
26
|
+
|
27
|
+
## v6.1.0
|
28
|
+
|
29
|
+
_2020-01-04_
|
30
|
+
|
31
|
+
### Bugfixes
|
32
|
+
|
33
|
+
- fix: allow deduplicating custom module dirs (#101)
|
34
|
+
|
35
|
+
### Features
|
36
|
+
|
37
|
+
- feat: add rootDir option (#98)
|
38
|
+
|
39
|
+
### Updates
|
40
|
+
|
41
|
+
- docs: improve doc related to mainFields (#138)
|
2
42
|
|
3
43
|
## 6.0.0
|
4
44
|
|
5
45
|
_2019-11-25_
|
6
46
|
|
7
|
-
- **Breaking:** Minimum compatible Rollup version is 1.
|
47
|
+
- **Breaking:** Minimum compatible Rollup version is 1.20.0
|
8
48
|
- **Breaking:** Minimum supported Node version is 8.0.0
|
9
49
|
- Published as @rollup/plugin-node-resolve
|
10
50
|
|
package/README.md
CHANGED
@@ -44,111 +44,120 @@ Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#comma
|
|
44
44
|
|
45
45
|
## Options
|
46
46
|
|
47
|
-
### `
|
47
|
+
### `browser`
|
48
48
|
|
49
|
-
Type: `
|
50
|
-
Default: `
|
49
|
+
Type: `Boolean`<br>
|
50
|
+
Default: `false`
|
51
51
|
|
52
|
-
|
52
|
+
If `true`, instructs the plugin to use the `"browser"` property in `package.json` files to specify alternative files to load for bundling. This is useful when bundling for a browser environment. Alternatively, a value of `'browser'` can be added to the `mainFields` option. If `false`, any `"browser"` properties in package files will be ignored. This option takes precedence over `mainFields`.
|
53
53
|
|
54
|
-
### `
|
54
|
+
### `customResolveOptions`
|
55
55
|
|
56
56
|
Type: `Boolean`<br>
|
57
|
-
Default: `
|
57
|
+
Default: `null`
|
58
58
|
|
59
|
-
|
60
|
-
Use "module" field for ES6 module if possible
|
59
|
+
An `Object` that specifies additional options that should be passed through to `node-resolve`.
|
61
60
|
|
62
|
-
|
61
|
+
```
|
62
|
+
customResolveOptions: {
|
63
|
+
moduleDirectory: 'js_modules'
|
64
|
+
}
|
65
|
+
```
|
63
66
|
|
64
|
-
|
65
|
-
Default: `false`
|
67
|
+
### `dedupe`
|
66
68
|
|
67
|
-
|
68
|
-
|
69
|
+
Type: `Array[...String]`<br>
|
70
|
+
Default: `[]`
|
69
71
|
|
70
|
-
|
72
|
+
An `Array` of modules names, which instructs the plugin to force resolving for the specified modules to the root `node_modules`. Helps to prevent bundling the same package multiple times if package is imported from dependencies.
|
71
73
|
|
72
|
-
|
73
|
-
|
74
|
+
```js
|
75
|
+
dedupe: ['my-package', '@namespace/my-package'];
|
76
|
+
```
|
74
77
|
|
75
|
-
|
76
|
-
Use "main" field or index.js, even if it's not an ES6 module (needs to be converted from CommonJS to ES6) – see https://github.com/rollup/rollup-plugin-commonjs
|
78
|
+
This will deduplicate bare imports such as:
|
77
79
|
|
78
|
-
|
80
|
+
```js
|
81
|
+
import 'my-package';
|
82
|
+
import '@namespace/my-package';
|
83
|
+
```
|
79
84
|
|
80
|
-
|
81
|
-
Default: `false`
|
85
|
+
And it will deduplicate deep imports such as:
|
82
86
|
|
83
|
-
|
87
|
+
```js
|
88
|
+
import 'my-package/foo.js';
|
89
|
+
import '@namespace/my-package/bar.js';
|
90
|
+
```
|
84
91
|
|
85
92
|
### `extensions`
|
86
93
|
|
87
|
-
Type: `Array[String]`<br>
|
94
|
+
Type: `Array[...String]`<br>
|
88
95
|
Default: `['.mjs', '.js', '.json', '.node']`
|
89
96
|
|
90
|
-
|
91
|
-
|
92
|
-
### `preferBuiltins`
|
93
|
-
|
94
|
-
Type: `Boolean`<br>
|
95
|
-
Default: `true`
|
96
|
-
|
97
|
-
Whether to prefer built-in modules (e.g. `fs`, `path`) or local ones with the same names
|
97
|
+
Specifies the extensions of files that the plugin will operate on.
|
98
98
|
|
99
99
|
### `jail`
|
100
100
|
|
101
101
|
Type: `String`<br>
|
102
102
|
Default: `'/'`
|
103
103
|
|
104
|
-
|
104
|
+
Locks the module search within specified path (e.g. chroot). Modules defined outside this path will be marked as external.
|
105
|
+
|
106
|
+
### `mainFields`
|
107
|
+
|
108
|
+
Type: `Array[...String]`<br>
|
109
|
+
Default: `['module', 'main']`<br>
|
110
|
+
Valid values: `['browser', 'jsnext', 'module', 'main']`
|
111
|
+
|
112
|
+
Specifies the properties to scan within a `package.json`, used to determine the bundle entry point. The order of property names is significant, as the first-found property is used as the resolved entry point. If the array contains `'browser'`, key/values specified in the `package.json` `browser` property will be used.
|
105
113
|
|
106
114
|
### `only`
|
107
115
|
|
108
|
-
|
109
|
-
Default: `null`
|
116
|
+
DEPRECATED: use "resolveOnly" instead
|
110
117
|
|
111
|
-
|
118
|
+
### `preferBuiltins`
|
119
|
+
|
120
|
+
Type: `Boolean`<br>
|
121
|
+
Default: `true`
|
122
|
+
|
123
|
+
If `true`, the plugin will prefer built-in modules (e.g. `fs`, `path`). If `false`, the plugin will look for locally installed modules of the same name.
|
112
124
|
|
113
125
|
### `modulesOnly`
|
114
126
|
|
115
127
|
Type: `Boolean`<br>
|
116
128
|
Default: `false`
|
117
129
|
|
118
|
-
If true
|
130
|
+
If `true`, inspect resolved files to assert that they are ES2015 modules.
|
119
131
|
|
120
|
-
### `
|
132
|
+
### `resolveOnly`
|
121
133
|
|
122
|
-
Type: `Array[String]`<br>
|
123
|
-
Default: `
|
134
|
+
Type: `Array[...String|RegExp]`<br>
|
135
|
+
Default: `null`
|
124
136
|
|
125
|
-
|
137
|
+
An `Array` which instructs the plugin to limit module resolution to those whose names match patterns in the array. _Note: Modules not matching any patterns will be marked as external._
|
126
138
|
|
127
|
-
|
128
|
-
dedupe: [ 'react', 'react-dom' ]
|
129
|
-
```
|
139
|
+
Example: `resolveOnly: ['batman', /^@batcave\/.*$/]`
|
130
140
|
|
131
|
-
### `
|
141
|
+
### `rootDir`
|
132
142
|
|
133
|
-
Type: `
|
134
|
-
Default: `
|
143
|
+
Type: `String`<br>
|
144
|
+
Default: `process.cwd()`
|
135
145
|
|
136
|
-
|
146
|
+
Specifies the root directory from which to resolve modules. Typically used when resolving entry-point imports, and when resolving deduplicated modules. Useful when executing rollup in a package of a mono-repository.
|
137
147
|
|
138
148
|
```
|
139
|
-
|
140
|
-
|
141
|
-
}
|
149
|
+
// Set the root directory to be the parent folder
|
150
|
+
rootDir: path.join(process.cwd(), '..')
|
142
151
|
```
|
143
152
|
|
144
|
-
## Using with rollup
|
153
|
+
## Using with @rollup/plugin-commonjs
|
145
154
|
|
146
|
-
Since most packages in your node_modules folder are probably legacy CommonJS rather than JavaScript modules, you may need to use [rollup
|
155
|
+
Since most packages in your node_modules folder are probably legacy CommonJS rather than JavaScript modules, you may need to use [@rollup/plugin-commonjs](https://github.com/rollup/plugins/packages/commonjs):
|
147
156
|
|
148
157
|
```js
|
149
158
|
// rollup.config.js
|
150
159
|
import resolve from '@rollup/plugin-node-resolve';
|
151
|
-
import commonjs from 'rollup
|
160
|
+
import commonjs from '@rollup/plugin-commonjs';
|
152
161
|
|
153
162
|
export default {
|
154
163
|
input: 'main.js',
|
@@ -163,7 +172,7 @@ export default {
|
|
163
172
|
|
164
173
|
## Resolving Built-Ins (like `fs`)
|
165
174
|
|
166
|
-
This plugin won't resolve any builtins (e.g. `fs`). If you need to resolve builtins you can install local modules and set `preferBuiltins` to `false`, or install a plugin like [rollup-plugin-node-
|
175
|
+
This plugin won't resolve any builtins (e.g. `fs`). If you need to resolve builtins you can install local modules and set `preferBuiltins` to `false`, or install a plugin like [rollup-plugin-node-polyfills](https://github.com/ionic-team/rollup-plugin-node-polyfills) which provides stubbed versions of these methods.
|
167
176
|
|
168
177
|
If you want to silence warnings about builtins, you can add the list of builtins to the `externals` option; like so:
|
169
178
|
|