@rollup/plugin-node-resolve 6.0.0 → 6.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 +18 -2
- package/README.md +29 -22
- package/dist/index.es.js +3 -7
- package/dist/index.js +2 -6
- package/package.json +3 -5
- package/types/index.d.ts +8 -0
package/CHANGELOG.md
CHANGED
@@ -1,10 +1,26 @@
|
|
1
|
-
# @rollup/plugin-node-resolve
|
1
|
+
# @rollup/plugin-node-resolve ChangeLog
|
2
|
+
|
3
|
+
## v6.1.0
|
4
|
+
|
5
|
+
_2020-01-04_
|
6
|
+
|
7
|
+
### Bugfixes
|
8
|
+
|
9
|
+
- fix: allow deduplicating custom module dirs (#101)
|
10
|
+
|
11
|
+
### Features
|
12
|
+
|
13
|
+
- feat: add rootDir option (#98)
|
14
|
+
|
15
|
+
### Updates
|
16
|
+
|
17
|
+
- docs: improve doc related to mainFields (#138)
|
2
18
|
|
3
19
|
## 6.0.0
|
4
20
|
|
5
21
|
_2019-11-25_
|
6
22
|
|
7
|
-
- **Breaking:** Minimum compatible Rollup version is 1.
|
23
|
+
- **Breaking:** Minimum compatible Rollup version is 1.20.0
|
8
24
|
- **Breaking:** Minimum supported Node version is 8.0.0
|
9
25
|
- Published as @rollup/plugin-node-resolve
|
10
26
|
|
package/README.md
CHANGED
@@ -46,45 +46,40 @@ Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#comma
|
|
46
46
|
|
47
47
|
### `mainFields`
|
48
48
|
|
49
|
-
Type: `Array[String]`<br>
|
50
|
-
Default: `['module', 'main']
|
49
|
+
Type: `Array[...String]`<br>
|
50
|
+
Default: `['module', 'main']`<br>
|
51
|
+
Valid values: `['browser', 'jsnext', 'module', 'main']`
|
51
52
|
|
52
|
-
|
53
|
+
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.
|
53
54
|
|
54
55
|
### `module`
|
55
56
|
|
56
|
-
Type: `Boolean`<br>
|
57
|
-
Default: `true`
|
58
|
-
|
59
57
|
DEPRECATED: use "mainFields" instead
|
60
|
-
Use "module" field for ES6 module if possible
|
61
58
|
|
62
|
-
|
59
|
+
Use `pkg.module` field for ES6 module if possible. This option takes precedence over both "jsnext" and "main" in the list if such are present.
|
63
60
|
|
64
|
-
|
65
|
-
Default: `false`
|
61
|
+
### `jsnext`
|
66
62
|
|
67
63
|
DEPRECATED: use "mainFields" instead
|
68
|
-
Use "jsnext:main" if possible, legacy field pointing to ES6 module in third-party libraries, deprecated in favor of "pkg.module", see: https://github.com/rollup/rollup/wiki/pkg.module
|
69
64
|
|
70
|
-
|
65
|
+
Use `pkg['jsnext:main']` if possible, legacy field pointing to ES6 module in third-party libraries, deprecated in favor of `pkg.module`, see: https://github.com/rollup/rollup/wiki/pkg.module. This option takes precedence over "main" in the list if such is present.
|
71
66
|
|
72
|
-
|
73
|
-
Default: `true`
|
67
|
+
### `main`
|
74
68
|
|
75
69
|
DEPRECATED: use "mainFields" instead
|
76
|
-
|
70
|
+
|
71
|
+
Use `pkg.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.
|
77
72
|
|
78
73
|
### `browser`
|
79
74
|
|
80
75
|
Type: `Boolean`<br>
|
81
76
|
Default: `false`
|
82
77
|
|
83
|
-
|
78
|
+
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`.
|
84
79
|
|
85
80
|
### `extensions`
|
86
81
|
|
87
|
-
Type: `Array[String]`<br>
|
82
|
+
Type: `Array[...String]`<br>
|
88
83
|
Default: `['.mjs', '.js', '.json', '.node']`
|
89
84
|
|
90
85
|
Resolve extensions other than .js in the order specified.
|
@@ -105,7 +100,7 @@ Lock the module search in this path (like a chroot). Modules defined outside thi
|
|
105
100
|
|
106
101
|
### `only`
|
107
102
|
|
108
|
-
Type: `Array[String|RegExp]`<br>
|
103
|
+
Type: `Array[...String|RegExp]`<br>
|
109
104
|
Default: `null`
|
110
105
|
|
111
106
|
Example: `only: ['some_module', /^@some_scope\/.*$/]`
|
@@ -119,7 +114,7 @@ If true, inspect resolved files to check that they are ES2015 modules.
|
|
119
114
|
|
120
115
|
### `dedupe`
|
121
116
|
|
122
|
-
Type: `Array[String]`<br>
|
117
|
+
Type: `Array[...String]`<br>
|
123
118
|
Default: `[]`
|
124
119
|
|
125
120
|
Force resolving for these modules to root's node_modules that helps to prevent bundling the same package multiple times if package is imported from dependencies.
|
@@ -141,14 +136,26 @@ customResolveOptions: {
|
|
141
136
|
}
|
142
137
|
```
|
143
138
|
|
144
|
-
|
139
|
+
### `rootDir`
|
140
|
+
|
141
|
+
Type: `String`<br>
|
142
|
+
Default: `process.cwd()`
|
143
|
+
|
144
|
+
Root directory to resolve modules from. Used when resolving entrypoint imports, and when resolving deduplicated modules. Useful when executing rollup in a package of a monorepository.
|
145
|
+
|
146
|
+
```
|
147
|
+
// Set the root directory to be the parent folder
|
148
|
+
rootDir: path.join(process.cwd(), '..')
|
149
|
+
```
|
150
|
+
|
151
|
+
## Using with @rollup/plugin-commonjs
|
145
152
|
|
146
|
-
Since most packages in your node_modules folder are probably legacy CommonJS rather than JavaScript modules, you may need to use [rollup
|
153
|
+
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
154
|
|
148
155
|
```js
|
149
156
|
// rollup.config.js
|
150
157
|
import resolve from '@rollup/plugin-node-resolve';
|
151
|
-
import commonjs from 'rollup
|
158
|
+
import commonjs from '@rollup/plugin-commonjs';
|
152
159
|
|
153
160
|
export default {
|
154
161
|
input: 'main.js',
|
package/dist/index.es.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { dirname,
|
1
|
+
import { dirname, resolve, normalize, sep, extname } from 'path';
|
2
2
|
import fs, { realpathSync } from 'fs';
|
3
3
|
import builtinList from 'builtin-modules';
|
4
4
|
import resolveId from 'resolve';
|
@@ -166,6 +166,7 @@ function nodeResolve(options = {}) {
|
|
166
166
|
const isPreferBuiltinsSet = options.preferBuiltins === true || options.preferBuiltins === false;
|
167
167
|
const preferBuiltins = isPreferBuiltinsSet ? options.preferBuiltins : true;
|
168
168
|
const customResolveOptions = options.customResolveOptions || {};
|
169
|
+
const rootDir = options.rootDir || process.cwd();
|
169
170
|
const jail = options.jail;
|
170
171
|
const only = Array.isArray(options.only) ? options.only.map(o => o instanceof RegExp ? o : new RegExp(`^${String(o).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&')}$`)) : null;
|
171
172
|
const browserMapCache = new Map();
|
@@ -310,12 +311,7 @@ function nodeResolve(options = {}) {
|
|
310
311
|
|
311
312
|
|
312
313
|
if (/\0/.test(importee)) return null;
|
313
|
-
const basedir = importer ? dirname(importer)
|
314
|
-
|
315
|
-
if (shouldDedupe(importee)) {
|
316
|
-
importee = join(process.cwd(), 'node_modules', importee);
|
317
|
-
} // https://github.com/defunctzombie/package-browser-field-spec
|
318
|
-
|
314
|
+
const basedir = !importer || shouldDedupe(importee) ? rootDir : dirname(importer); // https://github.com/defunctzombie/package-browser-field-spec
|
319
315
|
|
320
316
|
const browser = browserMapCache.get(importer);
|
321
317
|
|
package/dist/index.js
CHANGED
@@ -171,6 +171,7 @@ function nodeResolve(options = {}) {
|
|
171
171
|
const isPreferBuiltinsSet = options.preferBuiltins === true || options.preferBuiltins === false;
|
172
172
|
const preferBuiltins = isPreferBuiltinsSet ? options.preferBuiltins : true;
|
173
173
|
const customResolveOptions = options.customResolveOptions || {};
|
174
|
+
const rootDir = options.rootDir || process.cwd();
|
174
175
|
const jail = options.jail;
|
175
176
|
const only = Array.isArray(options.only) ? options.only.map(o => o instanceof RegExp ? o : new RegExp(`^${String(o).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&')}$`)) : null;
|
176
177
|
const browserMapCache = new Map();
|
@@ -315,12 +316,7 @@ function nodeResolve(options = {}) {
|
|
315
316
|
|
316
317
|
|
317
318
|
if (/\0/.test(importee)) return null;
|
318
|
-
const basedir = importer ? path.dirname(importer)
|
319
|
-
|
320
|
-
if (shouldDedupe(importee)) {
|
321
|
-
importee = path.join(process.cwd(), 'node_modules', importee);
|
322
|
-
} // https://github.com/defunctzombie/package-browser-field-spec
|
323
|
-
|
319
|
+
const basedir = !importer || shouldDedupe(importee) ? rootDir : path.dirname(importer); // https://github.com/defunctzombie/package-browser-field-spec
|
324
320
|
|
325
321
|
const browser = browserMapCache.get(importer);
|
326
322
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@rollup/plugin-node-resolve",
|
3
|
-
"version": "6.
|
3
|
+
"version": "6.1.0",
|
4
4
|
"publishConfig": {
|
5
5
|
"access": "public"
|
6
6
|
},
|
@@ -8,7 +8,7 @@
|
|
8
8
|
"license": "MIT",
|
9
9
|
"repository": "rollup/plugins",
|
10
10
|
"author": "Rich Harris <richard.a.harris@gmail.com>",
|
11
|
-
"homepage": "https://github.com/rollup/plugins/packages/node-resolve/#readme",
|
11
|
+
"homepage": "https://github.com/rollup/plugins/tree/master/packages/node-resolve/#readme",
|
12
12
|
"bugs": "https://github.com/rollup/plugins/issues",
|
13
13
|
"main": "dist/index.js",
|
14
14
|
"engines": {
|
@@ -17,7 +17,7 @@
|
|
17
17
|
"scripts": {
|
18
18
|
"build": "rollup -c",
|
19
19
|
"ci:coverage": "nyc pnpm run test && nyc report --reporter=text-lcov > coverage.lcov",
|
20
|
-
"ci:lint": "pnpm run build && pnpm run lint
|
20
|
+
"ci:lint": "pnpm run build && pnpm run lint",
|
21
21
|
"ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}",
|
22
22
|
"ci:test": "pnpm run test -- --verbose && pnpm run test:ts",
|
23
23
|
"lint": "pnpm run lint:js && pnpm run lint:docs && pnpm run lint:package",
|
@@ -28,7 +28,6 @@
|
|
28
28
|
"prepare": "pnpm run build",
|
29
29
|
"prepublishOnly": "pnpm run lint && pnpm run test && pnpm run test:ts",
|
30
30
|
"pretest": "pnpm run build",
|
31
|
-
"security": "echo 'pnpm needs `npm audit` support'",
|
32
31
|
"test": "ava",
|
33
32
|
"test:ts": "tsc types/index.d.ts test/types.ts --noEmit"
|
34
33
|
},
|
@@ -74,7 +73,6 @@
|
|
74
73
|
"!**/types.ts"
|
75
74
|
]
|
76
75
|
},
|
77
|
-
"jsnext:main": "dist/index.es.js",
|
78
76
|
"module": "dist/index.es.js",
|
79
77
|
"types": "types/index.d.ts"
|
80
78
|
}
|
package/types/index.d.ts
CHANGED
@@ -92,6 +92,14 @@ export interface Options {
|
|
92
92
|
* to node-resolve
|
93
93
|
*/
|
94
94
|
customResolveOptions?: AsyncOpts;
|
95
|
+
|
96
|
+
/**
|
97
|
+
* Root directory to resolve modules from. Used when resolving entrypoint imports,
|
98
|
+
* and when resolving deduplicated modules. Useful when executing rollup in a package
|
99
|
+
* of a monorepository.
|
100
|
+
* @default process.cwd()
|
101
|
+
*/
|
102
|
+
rootDir?: string;
|
95
103
|
}
|
96
104
|
|
97
105
|
/**
|