@rollup/plugin-node-resolve 9.0.0 → 11.1.0

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 CHANGED
@@ -1,5 +1,56 @@
1
1
  # @rollup/plugin-node-resolve ChangeLog
2
2
 
3
+ ## v11.1.0
4
+
5
+ _2021-01-15_
6
+
7
+ ### Features
8
+
9
+ - feat: support pkg imports and export array (#693)
10
+
11
+ ## v11.0.1
12
+
13
+ _2020-12-14_
14
+
15
+ ### Bugfixes
16
+
17
+ - fix: export map specificity (#675)
18
+ - fix: add missing type import (#668)
19
+
20
+ ### Updates
21
+
22
+ - docs: corrected word "yse" to "use" (#723)
23
+
24
+ ## v11.0.0
25
+
26
+ _2020-11-30_
27
+
28
+ ### Breaking Changes
29
+
30
+ - refactor!: simplify builtins and remove `customResolveOptions` (#656)
31
+ - feat!: Mark built-ins as external (#627)
32
+ - feat!: support package entry points (#540)
33
+
34
+ ### Bugfixes
35
+
36
+ - fix: refactor handling builtins, do not log warning if no local version (#637)
37
+
38
+ ### Updates
39
+
40
+ - docs: fix import statements in examples in README.md (#646)
41
+
42
+ ## v10.0.0
43
+
44
+ _2020-10-27_
45
+
46
+ ### Breaking Changes
47
+
48
+ - fix!: resolve hash in path (#588)
49
+
50
+ ### Bugfixes
51
+
52
+ - fix: do not ignore exceptions (#564)
53
+
3
54
  ## v9.0.0
4
55
 
5
56
  _2020-08-13_
package/README.md CHANGED
@@ -42,8 +42,23 @@ export default {
42
42
 
43
43
  Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api).
44
44
 
45
+ ## Package entrypoints
46
+
47
+ This plugin supports the package entrypoints feature from node js, specified in the `exports` or `imports` field of a package. Check the [official documentation](https://nodejs.org/api/packages.html#packages_package_entry_points) for more information on how this works.
48
+
45
49
  ## Options
46
50
 
51
+ ### `exportConditions`
52
+
53
+ Type: `Array[...String]`<br>
54
+ Default: `[]`
55
+
56
+ Additional conditions of the package.json exports field to match when resolving modules. By default, this plugin looks for the `['default', 'module', 'import']` conditions when resolving imports.
57
+
58
+ When using `@rollup/plugin-commonjs` v16 or higher, this plugin will use the `['default', 'module', 'require']` conditions when resolving require statements.
59
+
60
+ Setting this option will add extra conditions on top of the default conditions. See https://nodejs.org/api/packages.html#packages_conditional_exports for more information.
61
+
47
62
  ### `browser`
48
63
 
49
64
  Type: `Boolean`<br>
@@ -51,18 +66,14 @@ Default: `false`
51
66
 
52
67
  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
68
 
54
- ### `customResolveOptions`
69
+ > This option does not work when a package is using [package entrypoints](https://nodejs.org/api/packages.html#packages_package_entry_points)
55
70
 
56
- Type: `Object`<br>
57
- Default: `null`
71
+ ### `moduleDirectories`
58
72
 
59
- An `Object` that specifies additional options that should be passed through to [`resolve`](https://www.npmjs.com/package/resolve).
73
+ Type: `Array[...String]`<br>
74
+ Default: `['node_modules']`
60
75
 
61
- ```
62
- customResolveOptions: {
63
- moduleDirectory: 'js_modules'
64
- }
65
- ```
76
+ One or more directories in which to recursively look for modules.
66
77
 
67
78
  ### `dedupe`
68
79
 
@@ -101,7 +112,7 @@ Specifies the extensions of files that the plugin will operate on.
101
112
  Type: `String`<br>
102
113
  Default: `'/'`
103
114
 
104
- Locks the module search within specified path (e.g. chroot). Modules defined outside this path will be marked as external.
115
+ Locks the module search within specified path (e.g. chroot). Modules defined outside this path will be ignored by this plugin.
105
116
 
106
117
  ### `mainFields`
107
118
 
@@ -111,14 +122,10 @@ Valid values: `['browser', 'jsnext:main', 'module', 'main']`
111
122
 
112
123
  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.
113
124
 
114
- ### `only`
115
-
116
- DEPRECATED: use "resolveOnly" instead
117
-
118
125
  ### `preferBuiltins`
119
126
 
120
127
  Type: `Boolean`<br>
121
- Default: `true`
128
+ Default: `true` (with warnings if a builtin module is used over a local version. Set to `true` to disable warning.)
122
129
 
123
130
  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.
124
131
 
@@ -150,13 +157,17 @@ Specifies the root directory from which to resolve modules. Typically used when
150
157
  rootDir: path.join(process.cwd(), '..')
151
158
  ```
152
159
 
160
+ ## Preserving symlinks
161
+
162
+ This plugin honours the rollup [`preserveSymlinks`](https://rollupjs.org/guide/en/#preservesymlinks) option.
163
+
153
164
  ## Using with @rollup/plugin-commonjs
154
165
 
155
166
  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/tree/master/packages/commonjs):
156
167
 
157
168
  ```js
158
169
  // rollup.config.js
159
- import resolve from '@rollup/plugin-node-resolve';
170
+ import { nodeResolve } from '@rollup/plugin-node-resolve';
160
171
  import commonjs from '@rollup/plugin-commonjs';
161
172
 
162
173
  export default {
@@ -166,27 +177,42 @@ export default {
166
177
  format: 'iife',
167
178
  name: 'MyModule'
168
179
  },
169
- plugins: [resolve(), commonjs()]
180
+ plugins: [nodeResolve(), commonjs()]
170
181
  };
171
182
  ```
172
183
 
173
184
  ## Resolving Built-Ins (like `fs`)
174
185
 
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.
186
+ By default this plugin will prefer built-ins over local modules, marking them as external.
187
+
188
+ See [`preferBuiltins`](#preferbuiltins).
176
189
 
177
- If you want to silence warnings about builtins, you can add the list of builtins to the `externals` option; like so:
190
+ To provide stubbed versions of Node built-ins, use a plugin like [rollup-plugin-node-polyfills](https://github.com/ionic-team/rollup-plugin-node-polyfills) or use [`builtin-modules`](https://github.com/sindresorhus/builtin-modules) with `external`, and set `preferBuiltins` to `false`. e.g.
178
191
 
179
192
  ```js
180
- import resolve from '@rollup/plugin-node-resolve';
193
+ import { nodeResolve } from '@rollup/plugin-node-resolve';
181
194
  import builtins from 'builtin-modules'
182
195
  export default ({
183
196
  input: ...,
184
- plugins: [resolve()],
197
+ plugins: [nodeResolve()],
185
198
  external: builtins,
186
199
  output: ...
187
200
  })
188
201
  ```
189
202
 
203
+ ## Resolving require statements
204
+
205
+ According to [NodeJS module resolution](https://nodejs.org/api/packages.html#packages_package_entry_points) `require` statements should resolve using the `require` condition in the package exports field, while es modules should use the `import` condition.
206
+
207
+ The node resolve plugin uses `import` by default, you can opt into using the `require` semantics by passing an extra option to the resolve function:
208
+
209
+ ```js
210
+ this.resolve(importee, importer, {
211
+ skipSelf: true,
212
+ custom: { 'node-resolve': { isRequire: true } }
213
+ });
214
+ ```
215
+
190
216
  ## Meta
191
217
 
192
218
  [CONTRIBUTING](/.github/CONTRIBUTING.md)