@rollup/plugin-node-resolve 13.0.5 → 13.1.2

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,37 @@
1
1
  # @rollup/plugin-node-resolve ChangeLog
2
2
 
3
+ ## v13.1.2
4
+
5
+ _2021-12-31_
6
+
7
+ ### Bugfixes
8
+
9
+ - fix: forward meta-information from other plugins (#1062)
10
+
11
+ ## v13.1.1
12
+
13
+ _2021-12-13_
14
+
15
+ ### Updates
16
+
17
+ - test: add tests for mixing custom `exportConditions` with `browser: true` (#1043)
18
+
19
+ ## v13.1.0
20
+
21
+ _2021-12-13_
22
+
23
+ ### Features
24
+
25
+ - feat: expose plugin version (#1050)
26
+
27
+ ## v13.0.6
28
+
29
+ _2021-10-19_
30
+
31
+ ### Bugfixes
32
+
33
+ - fix: pass on isEntry flag (#1016)
34
+
3
35
  ## v13.0.5
4
36
 
5
37
  _2021-09-21_
package/dist/cjs/index.js CHANGED
@@ -21,10 +21,12 @@ 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
- util.promisify(fs__default['default'].access);
25
- const readFile$1 = util.promisify(fs__default['default'].readFile);
26
- const realpath = util.promisify(fs__default['default'].realpath);
27
- const stat = util.promisify(fs__default['default'].stat);
24
+ var version = "13.1.1";
25
+
26
+ util.promisify(fs__default["default"].access);
27
+ const readFile$1 = util.promisify(fs__default["default"].readFile);
28
+ const realpath = util.promisify(fs__default["default"].realpath);
29
+ const stat = util.promisify(fs__default["default"].stat);
28
30
 
29
31
  async function fileExists(filePath) {
30
32
  try {
@@ -93,6 +95,53 @@ const isFileCached = makeCache(async (file) => {
93
95
 
94
96
  const readCachedFile = makeCache(readFile$1);
95
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
+
96
145
  // returns the imported package name for bare module imports
97
146
  function getPackageName(id) {
98
147
  if (id.startsWith('.') || id.startsWith('/')) {
@@ -261,16 +310,16 @@ function isModuleDir(current, moduleDirs) {
261
310
  }
262
311
 
263
312
  async function findPackageJson(base, moduleDirs) {
264
- const { root } = path__default['default'].parse(base);
313
+ const { root } = path__default["default"].parse(base);
265
314
  let current = base;
266
315
 
267
316
  while (current !== root && !isModuleDir(current, moduleDirs)) {
268
- const pkgJsonPath = path__default['default'].join(current, 'package.json');
317
+ const pkgJsonPath = path__default["default"].join(current, 'package.json');
269
318
  if (await fileExists(pkgJsonPath)) {
270
- const pkgJsonString = fs__default['default'].readFileSync(pkgJsonPath, 'utf-8');
319
+ const pkgJsonString = fs__default["default"].readFileSync(pkgJsonPath, 'utf-8');
271
320
  return { pkgJson: JSON.parse(pkgJsonString), pkgPath: current, pkgJsonPath };
272
321
  }
273
- current = path__default['default'].resolve(current, '..');
322
+ current = path__default["default"].resolve(current, '..');
274
323
  }
275
324
  return null;
276
325
  }
@@ -554,8 +603,8 @@ async function resolvePackageImports({
554
603
  });
555
604
  }
556
605
 
557
- const resolveImportPath = util.promisify(resolve__default['default']);
558
- const readFile = util.promisify(fs__default['default'].readFile);
606
+ const resolveImportPath = util.promisify(resolve__default["default"]);
607
+ const readFile = util.promisify(fs__default["default"].readFile);
559
608
 
560
609
  async function getPackageJson(importer, pkgName, resolveOptions, moduleDirectories) {
561
610
  if (importer) {
@@ -861,56 +910,9 @@ async function resolveImportSpecifiers({
861
910
  });
862
911
  }
863
912
 
864
- function handleDeprecatedOptions(opts) {
865
- const warnings = [];
866
-
867
- if (opts.customResolveOptions) {
868
- const { customResolveOptions } = opts;
869
- if (customResolveOptions.moduleDirectory) {
870
- // eslint-disable-next-line no-param-reassign
871
- opts.moduleDirectories = Array.isArray(customResolveOptions.moduleDirectory)
872
- ? customResolveOptions.moduleDirectory
873
- : [customResolveOptions.moduleDirectory];
874
-
875
- warnings.push(
876
- 'node-resolve: The `customResolveOptions.moduleDirectory` option has been deprecated. Use `moduleDirectories`, which must be an array.'
877
- );
878
- }
879
-
880
- if (customResolveOptions.preserveSymlinks) {
881
- throw new Error(
882
- 'node-resolve: `customResolveOptions.preserveSymlinks` is no longer an option. We now always use the rollup `preserveSymlinks` option.'
883
- );
884
- }
885
-
886
- [
887
- 'basedir',
888
- 'package',
889
- 'extensions',
890
- 'includeCoreModules',
891
- 'readFile',
892
- 'isFile',
893
- 'isDirectory',
894
- 'realpath',
895
- 'packageFilter',
896
- 'pathFilter',
897
- 'paths',
898
- 'packageIterator'
899
- ].forEach((resolveOption) => {
900
- if (customResolveOptions[resolveOption]) {
901
- throw new Error(
902
- `node-resolve: \`customResolveOptions.${resolveOption}\` is no longer an option. If you need this, please open an issue.`
903
- );
904
- }
905
- });
906
- }
907
-
908
- return { warnings };
909
- }
910
-
911
913
  /* eslint-disable no-param-reassign, no-shadow, no-undefined */
912
914
 
913
- const builtins = new Set(builtinList__default['default']);
915
+ const builtins = new Set(builtinList__default["default"]);
914
916
  const ES6_BROWSER_EMPTY = '\0node-resolve:empty.js';
915
917
  const deepFreeze = (object) => {
916
918
  Object.freeze(object);
@@ -936,7 +938,7 @@ const defaults = {
936
938
  moduleDirectories: ['node_modules'],
937
939
  ignoreSideEffectsForRoot: false
938
940
  };
939
- const DEFAULTS = deepFreeze(deepMerge__default['default']({}, defaults));
941
+ const DEFAULTS = deepFreeze(deepMerge__default["default"]({}, defaults));
940
942
 
941
943
  function nodeResolve(opts = {}) {
942
944
  const { warnings } = handleDeprecatedOptions(opts);
@@ -971,7 +973,7 @@ function nodeResolve(opts = {}) {
971
973
  const browserMapCache = new Map();
972
974
  let preserveSymlinks;
973
975
 
974
- const doResolveId = async (context, importee, importer, opts) => {
976
+ const doResolveId = async (context, importee, importer, custom) => {
975
977
  // strip query params from import
976
978
  const [importPath, params] = importee.split('?');
977
979
  const importSuffix = `${params ? `?${params}` : ''}`;
@@ -1041,8 +1043,7 @@ function nodeResolve(opts = {}) {
1041
1043
  }
1042
1044
 
1043
1045
  const warn = (...args) => context.warn(...args);
1044
- const isRequire =
1045
- opts && opts.custom && opts.custom['node-resolve'] && opts.custom['node-resolve'].isRequire;
1046
+ const isRequire = custom && custom['node-resolve'] && custom['node-resolve'].isRequire;
1046
1047
  const exportConditions = isRequire ? conditionsCjs : conditionsEsm;
1047
1048
 
1048
1049
  if (useBrowserOverrides && !exportConditions.includes('browser'))
@@ -1115,7 +1116,7 @@ function nodeResolve(opts = {}) {
1115
1116
 
1116
1117
  if (options.modulesOnly && (await fileExists(location))) {
1117
1118
  const code = await readFile$1(location, 'utf-8');
1118
- if (isModule__default['default'](code)) {
1119
+ if (isModule__default["default"](code)) {
1119
1120
  return {
1120
1121
  id: `${location}${importSuffix}`,
1121
1122
  moduleSideEffects: hasModuleSideEffects(location)
@@ -1123,16 +1124,17 @@ function nodeResolve(opts = {}) {
1123
1124
  }
1124
1125
  return null;
1125
1126
  }
1126
- const result = {
1127
+ return {
1127
1128
  id: `${location}${importSuffix}`,
1128
1129
  moduleSideEffects: hasModuleSideEffects(location)
1129
1130
  };
1130
- return result;
1131
1131
  };
1132
1132
 
1133
1133
  return {
1134
1134
  name: 'node-resolve',
1135
1135
 
1136
+ version,
1137
+
1136
1138
  buildStart(options) {
1137
1139
  rollupOptions = options;
1138
1140
 
@@ -1149,7 +1151,7 @@ function nodeResolve(opts = {}) {
1149
1151
  isDirCached.clear();
1150
1152
  },
1151
1153
 
1152
- async resolveId(importee, importer, opts) {
1154
+ async resolveId(importee, importer, resolveOptions) {
1153
1155
  if (importee === ES6_BROWSER_EMPTY) {
1154
1156
  return importee;
1155
1157
  }
@@ -1160,12 +1162,20 @@ function nodeResolve(opts = {}) {
1160
1162
  importer = undefined;
1161
1163
  }
1162
1164
 
1163
- const resolved = await doResolveId(this, importee, importer, opts);
1165
+ const resolved = await doResolveId(this, importee, importer, resolveOptions.custom);
1164
1166
  if (resolved) {
1165
- const resolvedResolved = await this.resolve(resolved.id, importer, { skipSelf: true });
1166
- const isExternal = !!(resolvedResolved && resolvedResolved.external);
1167
- if (isExternal) {
1168
- return false;
1167
+ const resolvedResolved = await this.resolve(
1168
+ resolved.id,
1169
+ importer,
1170
+ Object.assign({ skipSelf: true }, resolveOptions)
1171
+ );
1172
+ if (resolvedResolved) {
1173
+ // Handle plugins that manually make the result external
1174
+ if (resolvedResolved.external) {
1175
+ return false;
1176
+ }
1177
+ // Pass on meta information added by other plugins
1178
+ return { ...resolved, meta: resolvedResolved.meta };
1169
1179
  }
1170
1180
  }
1171
1181
  return resolved;
@@ -1185,5 +1195,5 @@ function nodeResolve(opts = {}) {
1185
1195
  }
1186
1196
 
1187
1197
  exports.DEFAULTS = DEFAULTS;
1188
- exports.default = nodeResolve;
1198
+ exports["default"] = nodeResolve;
1189
1199
  exports.nodeResolve = nodeResolve;
package/dist/es/index.js CHANGED
@@ -8,6 +8,8 @@ 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.1.1";
12
+
11
13
  promisify(fs.access);
12
14
  const readFile$1 = promisify(fs.readFile);
13
15
  const realpath = promisify(fs.realpath);
@@ -80,6 +82,53 @@ const isFileCached = makeCache(async (file) => {
80
82
 
81
83
  const readCachedFile = makeCache(readFile$1);
82
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
+
83
132
  // returns the imported package name for bare module imports
84
133
  function getPackageName(id) {
85
134
  if (id.startsWith('.') || id.startsWith('/')) {
@@ -848,53 +897,6 @@ async function resolveImportSpecifiers({
848
897
  });
849
898
  }
850
899
 
851
- function handleDeprecatedOptions(opts) {
852
- const warnings = [];
853
-
854
- if (opts.customResolveOptions) {
855
- const { customResolveOptions } = opts;
856
- if (customResolveOptions.moduleDirectory) {
857
- // eslint-disable-next-line no-param-reassign
858
- opts.moduleDirectories = Array.isArray(customResolveOptions.moduleDirectory)
859
- ? customResolveOptions.moduleDirectory
860
- : [customResolveOptions.moduleDirectory];
861
-
862
- warnings.push(
863
- 'node-resolve: The `customResolveOptions.moduleDirectory` option has been deprecated. Use `moduleDirectories`, which must be an array.'
864
- );
865
- }
866
-
867
- if (customResolveOptions.preserveSymlinks) {
868
- throw new Error(
869
- 'node-resolve: `customResolveOptions.preserveSymlinks` is no longer an option. We now always use the rollup `preserveSymlinks` option.'
870
- );
871
- }
872
-
873
- [
874
- 'basedir',
875
- 'package',
876
- 'extensions',
877
- 'includeCoreModules',
878
- 'readFile',
879
- 'isFile',
880
- 'isDirectory',
881
- 'realpath',
882
- 'packageFilter',
883
- 'pathFilter',
884
- 'paths',
885
- 'packageIterator'
886
- ].forEach((resolveOption) => {
887
- if (customResolveOptions[resolveOption]) {
888
- throw new Error(
889
- `node-resolve: \`customResolveOptions.${resolveOption}\` is no longer an option. If you need this, please open an issue.`
890
- );
891
- }
892
- });
893
- }
894
-
895
- return { warnings };
896
- }
897
-
898
900
  /* eslint-disable no-param-reassign, no-shadow, no-undefined */
899
901
 
900
902
  const builtins = new Set(builtinList);
@@ -958,7 +960,7 @@ function nodeResolve(opts = {}) {
958
960
  const browserMapCache = new Map();
959
961
  let preserveSymlinks;
960
962
 
961
- const doResolveId = async (context, importee, importer, opts) => {
963
+ const doResolveId = async (context, importee, importer, custom) => {
962
964
  // strip query params from import
963
965
  const [importPath, params] = importee.split('?');
964
966
  const importSuffix = `${params ? `?${params}` : ''}`;
@@ -1028,8 +1030,7 @@ function nodeResolve(opts = {}) {
1028
1030
  }
1029
1031
 
1030
1032
  const warn = (...args) => context.warn(...args);
1031
- const isRequire =
1032
- opts && opts.custom && opts.custom['node-resolve'] && opts.custom['node-resolve'].isRequire;
1033
+ const isRequire = custom && custom['node-resolve'] && custom['node-resolve'].isRequire;
1033
1034
  const exportConditions = isRequire ? conditionsCjs : conditionsEsm;
1034
1035
 
1035
1036
  if (useBrowserOverrides && !exportConditions.includes('browser'))
@@ -1110,16 +1111,17 @@ function nodeResolve(opts = {}) {
1110
1111
  }
1111
1112
  return null;
1112
1113
  }
1113
- const result = {
1114
+ return {
1114
1115
  id: `${location}${importSuffix}`,
1115
1116
  moduleSideEffects: hasModuleSideEffects(location)
1116
1117
  };
1117
- return result;
1118
1118
  };
1119
1119
 
1120
1120
  return {
1121
1121
  name: 'node-resolve',
1122
1122
 
1123
+ version,
1124
+
1123
1125
  buildStart(options) {
1124
1126
  rollupOptions = options;
1125
1127
 
@@ -1136,7 +1138,7 @@ function nodeResolve(opts = {}) {
1136
1138
  isDirCached.clear();
1137
1139
  },
1138
1140
 
1139
- async resolveId(importee, importer, opts) {
1141
+ async resolveId(importee, importer, resolveOptions) {
1140
1142
  if (importee === ES6_BROWSER_EMPTY) {
1141
1143
  return importee;
1142
1144
  }
@@ -1147,12 +1149,20 @@ function nodeResolve(opts = {}) {
1147
1149
  importer = undefined;
1148
1150
  }
1149
1151
 
1150
- const resolved = await doResolveId(this, importee, importer, opts);
1152
+ const resolved = await doResolveId(this, importee, importer, resolveOptions.custom);
1151
1153
  if (resolved) {
1152
- const resolvedResolved = await this.resolve(resolved.id, importer, { skipSelf: true });
1153
- const isExternal = !!(resolvedResolved && resolvedResolved.external);
1154
- if (isExternal) {
1155
- return false;
1154
+ const resolvedResolved = await this.resolve(
1155
+ resolved.id,
1156
+ importer,
1157
+ Object.assign({ skipSelf: true }, resolveOptions)
1158
+ );
1159
+ if (resolvedResolved) {
1160
+ // Handle plugins that manually make the result external
1161
+ if (resolvedResolved.external) {
1162
+ return false;
1163
+ }
1164
+ // Pass on meta information added by other plugins
1165
+ return { ...resolved, meta: resolvedResolved.meta };
1156
1166
  }
1157
1167
  }
1158
1168
  return resolved;
@@ -1171,5 +1181,4 @@ function nodeResolve(opts = {}) {
1171
1181
  };
1172
1182
  }
1173
1183
 
1174
- export default nodeResolve;
1175
- export { DEFAULTS, nodeResolve };
1184
+ export { DEFAULTS, nodeResolve as default, nodeResolve };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rollup/plugin-node-resolve",
3
- "version": "13.0.5",
3
+ "version": "13.1.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -68,7 +68,7 @@
68
68
  "@rollup/plugin-commonjs": "^16.0.0",
69
69
  "@rollup/plugin-json": "^4.1.0",
70
70
  "es5-ext": "^0.10.53",
71
- "rollup": "^2.42.0",
71
+ "rollup": "^2.58.0",
72
72
  "source-map": "^0.7.3",
73
73
  "string-capitalize": "^1.0.1"
74
74
  },