@rollup/plugin-node-resolve 13.1.1 → 13.2.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 +24 -0
- package/README.md +7 -2
- package/dist/cjs/index.js +74 -65
- package/dist/es/index.js +74 -65
- package/package.json +3 -2
- package/types/index.d.ts +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,29 @@
|
|
1
1
|
# @rollup/plugin-node-resolve ChangeLog
|
2
2
|
|
3
|
+
## v13.2.0
|
4
|
+
|
5
|
+
_2022-04-11_
|
6
|
+
|
7
|
+
### Features
|
8
|
+
|
9
|
+
- feat: Add the ability to pass a function into resolveOnly (#1152)
|
10
|
+
|
11
|
+
## v13.1.3
|
12
|
+
|
13
|
+
_2022-01-05_
|
14
|
+
|
15
|
+
### Bugfixes
|
16
|
+
|
17
|
+
- fix: use correct version when published (#1063)
|
18
|
+
|
19
|
+
## v13.1.2
|
20
|
+
|
21
|
+
_2021-12-31_
|
22
|
+
|
23
|
+
### Bugfixes
|
24
|
+
|
25
|
+
- fix: forward meta-information from other plugins (#1062)
|
26
|
+
|
3
27
|
## v13.1.1
|
4
28
|
|
5
29
|
_2021-12-13_
|
package/README.md
CHANGED
@@ -140,12 +140,17 @@ If `true`, inspect resolved files to assert that they are ES2015 modules.
|
|
140
140
|
|
141
141
|
### `resolveOnly`
|
142
142
|
|
143
|
-
Type: `Array[...String|RegExp]`<br>
|
143
|
+
Type: `Array[...String|RegExp] | (module: string) => boolean`<br>
|
144
144
|
Default: `null`
|
145
145
|
|
146
146
|
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._
|
147
147
|
|
148
|
-
|
148
|
+
Alternatively, you may pass in a function that returns a boolean to confirm whether the module should be included or not.
|
149
|
+
|
150
|
+
Examples:
|
151
|
+
|
152
|
+
- `resolveOnly: ['batman', /^@batcave\/.*$/]`
|
153
|
+
- `resolveOnly: module => !module.includes('joker')`
|
149
154
|
|
150
155
|
### `rootDir`
|
151
156
|
|
package/dist/cjs/index.js
CHANGED
@@ -21,7 +21,7 @@ var isModule__default = /*#__PURE__*/_interopDefaultLegacy(isModule);
|
|
21
21
|
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
22
22
|
var resolve__default = /*#__PURE__*/_interopDefaultLegacy(resolve);
|
23
23
|
|
24
|
-
var version = "13.
|
24
|
+
var version = "13.2.0";
|
25
25
|
|
26
26
|
util.promisify(fs__default["default"].access);
|
27
27
|
const readFile$1 = util.promisify(fs__default["default"].readFile);
|
@@ -95,6 +95,53 @@ const isFileCached = makeCache(async (file) => {
|
|
95
95
|
|
96
96
|
const readCachedFile = makeCache(readFile$1);
|
97
97
|
|
98
|
+
function handleDeprecatedOptions(opts) {
|
99
|
+
const warnings = [];
|
100
|
+
|
101
|
+
if (opts.customResolveOptions) {
|
102
|
+
const { customResolveOptions } = opts;
|
103
|
+
if (customResolveOptions.moduleDirectory) {
|
104
|
+
// eslint-disable-next-line no-param-reassign
|
105
|
+
opts.moduleDirectories = Array.isArray(customResolveOptions.moduleDirectory)
|
106
|
+
? customResolveOptions.moduleDirectory
|
107
|
+
: [customResolveOptions.moduleDirectory];
|
108
|
+
|
109
|
+
warnings.push(
|
110
|
+
'node-resolve: The `customResolveOptions.moduleDirectory` option has been deprecated. Use `moduleDirectories`, which must be an array.'
|
111
|
+
);
|
112
|
+
}
|
113
|
+
|
114
|
+
if (customResolveOptions.preserveSymlinks) {
|
115
|
+
throw new Error(
|
116
|
+
'node-resolve: `customResolveOptions.preserveSymlinks` is no longer an option. We now always use the rollup `preserveSymlinks` option.'
|
117
|
+
);
|
118
|
+
}
|
119
|
+
|
120
|
+
[
|
121
|
+
'basedir',
|
122
|
+
'package',
|
123
|
+
'extensions',
|
124
|
+
'includeCoreModules',
|
125
|
+
'readFile',
|
126
|
+
'isFile',
|
127
|
+
'isDirectory',
|
128
|
+
'realpath',
|
129
|
+
'packageFilter',
|
130
|
+
'pathFilter',
|
131
|
+
'paths',
|
132
|
+
'packageIterator'
|
133
|
+
].forEach((resolveOption) => {
|
134
|
+
if (customResolveOptions[resolveOption]) {
|
135
|
+
throw new Error(
|
136
|
+
`node-resolve: \`customResolveOptions.${resolveOption}\` is no longer an option. If you need this, please open an issue.`
|
137
|
+
);
|
138
|
+
}
|
139
|
+
});
|
140
|
+
}
|
141
|
+
|
142
|
+
return { warnings };
|
143
|
+
}
|
144
|
+
|
98
145
|
// returns the imported package name for bare module imports
|
99
146
|
function getPackageName(id) {
|
100
147
|
if (id.startsWith('.') || id.startsWith('/')) {
|
@@ -863,53 +910,6 @@ async function resolveImportSpecifiers({
|
|
863
910
|
});
|
864
911
|
}
|
865
912
|
|
866
|
-
function handleDeprecatedOptions(opts) {
|
867
|
-
const warnings = [];
|
868
|
-
|
869
|
-
if (opts.customResolveOptions) {
|
870
|
-
const { customResolveOptions } = opts;
|
871
|
-
if (customResolveOptions.moduleDirectory) {
|
872
|
-
// eslint-disable-next-line no-param-reassign
|
873
|
-
opts.moduleDirectories = Array.isArray(customResolveOptions.moduleDirectory)
|
874
|
-
? customResolveOptions.moduleDirectory
|
875
|
-
: [customResolveOptions.moduleDirectory];
|
876
|
-
|
877
|
-
warnings.push(
|
878
|
-
'node-resolve: The `customResolveOptions.moduleDirectory` option has been deprecated. Use `moduleDirectories`, which must be an array.'
|
879
|
-
);
|
880
|
-
}
|
881
|
-
|
882
|
-
if (customResolveOptions.preserveSymlinks) {
|
883
|
-
throw new Error(
|
884
|
-
'node-resolve: `customResolveOptions.preserveSymlinks` is no longer an option. We now always use the rollup `preserveSymlinks` option.'
|
885
|
-
);
|
886
|
-
}
|
887
|
-
|
888
|
-
[
|
889
|
-
'basedir',
|
890
|
-
'package',
|
891
|
-
'extensions',
|
892
|
-
'includeCoreModules',
|
893
|
-
'readFile',
|
894
|
-
'isFile',
|
895
|
-
'isDirectory',
|
896
|
-
'realpath',
|
897
|
-
'packageFilter',
|
898
|
-
'pathFilter',
|
899
|
-
'paths',
|
900
|
-
'packageIterator'
|
901
|
-
].forEach((resolveOption) => {
|
902
|
-
if (customResolveOptions[resolveOption]) {
|
903
|
-
throw new Error(
|
904
|
-
`node-resolve: \`customResolveOptions.${resolveOption}\` is no longer an option. If you need this, please open an issue.`
|
905
|
-
);
|
906
|
-
}
|
907
|
-
});
|
908
|
-
}
|
909
|
-
|
910
|
-
return { warnings };
|
911
|
-
}
|
912
|
-
|
913
913
|
/* eslint-disable no-param-reassign, no-shadow, no-undefined */
|
914
914
|
|
915
915
|
const builtins = new Set(builtinList__default["default"]);
|
@@ -962,13 +962,22 @@ function nodeResolve(opts = {}) {
|
|
962
962
|
options.dedupe.includes(importee) || options.dedupe.includes(getPackageName(importee));
|
963
963
|
}
|
964
964
|
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
965
|
+
// creates a function from the patterns to test if a particular module should be bundled.
|
966
|
+
const allowPatterns = (patterns) => {
|
967
|
+
const regexPatterns = patterns.map((pattern) => {
|
968
|
+
if (pattern instanceof RegExp) {
|
969
|
+
return pattern;
|
970
|
+
}
|
971
|
+
const normalized = pattern.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
|
972
|
+
return new RegExp(`^${normalized}$`);
|
973
|
+
});
|
974
|
+
return (id) => !regexPatterns.length || regexPatterns.some((pattern) => pattern.test(id));
|
975
|
+
};
|
976
|
+
|
977
|
+
const resolveOnly =
|
978
|
+
typeof options.resolveOnly === 'function'
|
979
|
+
? options.resolveOnly
|
980
|
+
: allowPatterns(options.resolveOnly);
|
972
981
|
|
973
982
|
const browserMapCache = new Map();
|
974
983
|
let preserveSymlinks;
|
@@ -1011,11 +1020,8 @@ function nodeResolve(opts = {}) {
|
|
1011
1020
|
isRelativeImport = true;
|
1012
1021
|
}
|
1013
1022
|
|
1014
|
-
if
|
1015
|
-
|
1016
|
-
resolveOnly.length &&
|
1017
|
-
!resolveOnly.some((pattern) => pattern.test(id))
|
1018
|
-
) {
|
1023
|
+
// if it's not a relative import, and it's not requested, reject it.
|
1024
|
+
if (!isRelativeImport && !resolveOnly(id)) {
|
1019
1025
|
if (normalizeInput(rollupOptions.input).includes(importee)) {
|
1020
1026
|
return null;
|
1021
1027
|
}
|
@@ -1124,11 +1130,10 @@ function nodeResolve(opts = {}) {
|
|
1124
1130
|
}
|
1125
1131
|
return null;
|
1126
1132
|
}
|
1127
|
-
|
1133
|
+
return {
|
1128
1134
|
id: `${location}${importSuffix}`,
|
1129
1135
|
moduleSideEffects: hasModuleSideEffects(location)
|
1130
1136
|
};
|
1131
|
-
return result;
|
1132
1137
|
};
|
1133
1138
|
|
1134
1139
|
return {
|
@@ -1170,9 +1175,13 @@ function nodeResolve(opts = {}) {
|
|
1170
1175
|
importer,
|
1171
1176
|
Object.assign({ skipSelf: true }, resolveOptions)
|
1172
1177
|
);
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1178
|
+
if (resolvedResolved) {
|
1179
|
+
// Handle plugins that manually make the result external
|
1180
|
+
if (resolvedResolved.external) {
|
1181
|
+
return false;
|
1182
|
+
}
|
1183
|
+
// Pass on meta information added by other plugins
|
1184
|
+
return { ...resolved, meta: resolvedResolved.meta };
|
1176
1185
|
}
|
1177
1186
|
}
|
1178
1187
|
return resolved;
|
package/dist/es/index.js
CHANGED
@@ -8,7 +8,7 @@ import { pathToFileURL, fileURLToPath } from 'url';
|
|
8
8
|
import resolve$1 from 'resolve';
|
9
9
|
import { createFilter } from '@rollup/pluginutils';
|
10
10
|
|
11
|
-
var version = "13.
|
11
|
+
var version = "13.2.0";
|
12
12
|
|
13
13
|
promisify(fs.access);
|
14
14
|
const readFile$1 = promisify(fs.readFile);
|
@@ -82,6 +82,53 @@ const isFileCached = makeCache(async (file) => {
|
|
82
82
|
|
83
83
|
const readCachedFile = makeCache(readFile$1);
|
84
84
|
|
85
|
+
function handleDeprecatedOptions(opts) {
|
86
|
+
const warnings = [];
|
87
|
+
|
88
|
+
if (opts.customResolveOptions) {
|
89
|
+
const { customResolveOptions } = opts;
|
90
|
+
if (customResolveOptions.moduleDirectory) {
|
91
|
+
// eslint-disable-next-line no-param-reassign
|
92
|
+
opts.moduleDirectories = Array.isArray(customResolveOptions.moduleDirectory)
|
93
|
+
? customResolveOptions.moduleDirectory
|
94
|
+
: [customResolveOptions.moduleDirectory];
|
95
|
+
|
96
|
+
warnings.push(
|
97
|
+
'node-resolve: The `customResolveOptions.moduleDirectory` option has been deprecated. Use `moduleDirectories`, which must be an array.'
|
98
|
+
);
|
99
|
+
}
|
100
|
+
|
101
|
+
if (customResolveOptions.preserveSymlinks) {
|
102
|
+
throw new Error(
|
103
|
+
'node-resolve: `customResolveOptions.preserveSymlinks` is no longer an option. We now always use the rollup `preserveSymlinks` option.'
|
104
|
+
);
|
105
|
+
}
|
106
|
+
|
107
|
+
[
|
108
|
+
'basedir',
|
109
|
+
'package',
|
110
|
+
'extensions',
|
111
|
+
'includeCoreModules',
|
112
|
+
'readFile',
|
113
|
+
'isFile',
|
114
|
+
'isDirectory',
|
115
|
+
'realpath',
|
116
|
+
'packageFilter',
|
117
|
+
'pathFilter',
|
118
|
+
'paths',
|
119
|
+
'packageIterator'
|
120
|
+
].forEach((resolveOption) => {
|
121
|
+
if (customResolveOptions[resolveOption]) {
|
122
|
+
throw new Error(
|
123
|
+
`node-resolve: \`customResolveOptions.${resolveOption}\` is no longer an option. If you need this, please open an issue.`
|
124
|
+
);
|
125
|
+
}
|
126
|
+
});
|
127
|
+
}
|
128
|
+
|
129
|
+
return { warnings };
|
130
|
+
}
|
131
|
+
|
85
132
|
// returns the imported package name for bare module imports
|
86
133
|
function getPackageName(id) {
|
87
134
|
if (id.startsWith('.') || id.startsWith('/')) {
|
@@ -850,53 +897,6 @@ async function resolveImportSpecifiers({
|
|
850
897
|
});
|
851
898
|
}
|
852
899
|
|
853
|
-
function handleDeprecatedOptions(opts) {
|
854
|
-
const warnings = [];
|
855
|
-
|
856
|
-
if (opts.customResolveOptions) {
|
857
|
-
const { customResolveOptions } = opts;
|
858
|
-
if (customResolveOptions.moduleDirectory) {
|
859
|
-
// eslint-disable-next-line no-param-reassign
|
860
|
-
opts.moduleDirectories = Array.isArray(customResolveOptions.moduleDirectory)
|
861
|
-
? customResolveOptions.moduleDirectory
|
862
|
-
: [customResolveOptions.moduleDirectory];
|
863
|
-
|
864
|
-
warnings.push(
|
865
|
-
'node-resolve: The `customResolveOptions.moduleDirectory` option has been deprecated. Use `moduleDirectories`, which must be an array.'
|
866
|
-
);
|
867
|
-
}
|
868
|
-
|
869
|
-
if (customResolveOptions.preserveSymlinks) {
|
870
|
-
throw new Error(
|
871
|
-
'node-resolve: `customResolveOptions.preserveSymlinks` is no longer an option. We now always use the rollup `preserveSymlinks` option.'
|
872
|
-
);
|
873
|
-
}
|
874
|
-
|
875
|
-
[
|
876
|
-
'basedir',
|
877
|
-
'package',
|
878
|
-
'extensions',
|
879
|
-
'includeCoreModules',
|
880
|
-
'readFile',
|
881
|
-
'isFile',
|
882
|
-
'isDirectory',
|
883
|
-
'realpath',
|
884
|
-
'packageFilter',
|
885
|
-
'pathFilter',
|
886
|
-
'paths',
|
887
|
-
'packageIterator'
|
888
|
-
].forEach((resolveOption) => {
|
889
|
-
if (customResolveOptions[resolveOption]) {
|
890
|
-
throw new Error(
|
891
|
-
`node-resolve: \`customResolveOptions.${resolveOption}\` is no longer an option. If you need this, please open an issue.`
|
892
|
-
);
|
893
|
-
}
|
894
|
-
});
|
895
|
-
}
|
896
|
-
|
897
|
-
return { warnings };
|
898
|
-
}
|
899
|
-
|
900
900
|
/* eslint-disable no-param-reassign, no-shadow, no-undefined */
|
901
901
|
|
902
902
|
const builtins = new Set(builtinList);
|
@@ -949,13 +949,22 @@ function nodeResolve(opts = {}) {
|
|
949
949
|
options.dedupe.includes(importee) || options.dedupe.includes(getPackageName(importee));
|
950
950
|
}
|
951
951
|
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
952
|
+
// creates a function from the patterns to test if a particular module should be bundled.
|
953
|
+
const allowPatterns = (patterns) => {
|
954
|
+
const regexPatterns = patterns.map((pattern) => {
|
955
|
+
if (pattern instanceof RegExp) {
|
956
|
+
return pattern;
|
957
|
+
}
|
958
|
+
const normalized = pattern.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
|
959
|
+
return new RegExp(`^${normalized}$`);
|
960
|
+
});
|
961
|
+
return (id) => !regexPatterns.length || regexPatterns.some((pattern) => pattern.test(id));
|
962
|
+
};
|
963
|
+
|
964
|
+
const resolveOnly =
|
965
|
+
typeof options.resolveOnly === 'function'
|
966
|
+
? options.resolveOnly
|
967
|
+
: allowPatterns(options.resolveOnly);
|
959
968
|
|
960
969
|
const browserMapCache = new Map();
|
961
970
|
let preserveSymlinks;
|
@@ -998,11 +1007,8 @@ function nodeResolve(opts = {}) {
|
|
998
1007
|
isRelativeImport = true;
|
999
1008
|
}
|
1000
1009
|
|
1001
|
-
if
|
1002
|
-
|
1003
|
-
resolveOnly.length &&
|
1004
|
-
!resolveOnly.some((pattern) => pattern.test(id))
|
1005
|
-
) {
|
1010
|
+
// if it's not a relative import, and it's not requested, reject it.
|
1011
|
+
if (!isRelativeImport && !resolveOnly(id)) {
|
1006
1012
|
if (normalizeInput(rollupOptions.input).includes(importee)) {
|
1007
1013
|
return null;
|
1008
1014
|
}
|
@@ -1111,11 +1117,10 @@ function nodeResolve(opts = {}) {
|
|
1111
1117
|
}
|
1112
1118
|
return null;
|
1113
1119
|
}
|
1114
|
-
|
1120
|
+
return {
|
1115
1121
|
id: `${location}${importSuffix}`,
|
1116
1122
|
moduleSideEffects: hasModuleSideEffects(location)
|
1117
1123
|
};
|
1118
|
-
return result;
|
1119
1124
|
};
|
1120
1125
|
|
1121
1126
|
return {
|
@@ -1157,9 +1162,13 @@ function nodeResolve(opts = {}) {
|
|
1157
1162
|
importer,
|
1158
1163
|
Object.assign({ skipSelf: true }, resolveOptions)
|
1159
1164
|
);
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1165
|
+
if (resolvedResolved) {
|
1166
|
+
// Handle plugins that manually make the result external
|
1167
|
+
if (resolvedResolved.external) {
|
1168
|
+
return false;
|
1169
|
+
}
|
1170
|
+
// Pass on meta information added by other plugins
|
1171
|
+
return { ...resolved, meta: resolvedResolved.meta };
|
1163
1172
|
}
|
1164
1173
|
}
|
1165
1174
|
return resolved;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@rollup/plugin-node-resolve",
|
3
|
-
"version": "13.
|
3
|
+
"version": "13.2.0",
|
4
4
|
"publishConfig": {
|
5
5
|
"access": "public"
|
6
6
|
},
|
@@ -31,6 +31,7 @@
|
|
31
31
|
"ci:test": "pnpm test -- --verbose && pnpm test:ts",
|
32
32
|
"prebuild": "del-cli dist",
|
33
33
|
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
|
34
|
+
"prepublishOnly": "pnpm build",
|
34
35
|
"prerelease": "pnpm build",
|
35
36
|
"pretest": "pnpm build",
|
36
37
|
"release": "pnpm plugin:release --workspace-root -- --pkg $npm_package_name",
|
@@ -68,7 +69,7 @@
|
|
68
69
|
"@rollup/plugin-commonjs": "^16.0.0",
|
69
70
|
"@rollup/plugin-json": "^4.1.0",
|
70
71
|
"es5-ext": "^0.10.53",
|
71
|
-
"rollup": "^2.
|
72
|
+
"rollup": "^2.67.3",
|
72
73
|
"source-map": "^0.7.3",
|
73
74
|
"string-capitalize": "^1.0.1"
|
74
75
|
},
|
package/types/index.d.ts
CHANGED
@@ -81,7 +81,7 @@ export interface RollupNodeResolveOptions {
|
|
81
81
|
* names match patterns in the array.
|
82
82
|
* @default []
|
83
83
|
*/
|
84
|
-
resolveOnly?: ReadonlyArray<string | RegExp> | null;
|
84
|
+
resolveOnly?: ReadonlyArray<string | RegExp> | null | ((module: string) => boolean);
|
85
85
|
|
86
86
|
/**
|
87
87
|
* Specifies the root directory from which to resolve modules. Typically used when
|