@rollup/plugin-node-resolve 16.0.1 → 16.0.3

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/dist/cjs/index.js CHANGED
@@ -12,7 +12,7 @@ var url = require('url');
12
12
  var resolve = require('resolve');
13
13
  var pluginutils = require('@rollup/pluginutils');
14
14
 
15
- var version = "16.0.1";
15
+ var version = "16.0.3";
16
16
  var peerDependencies = {
17
17
  rollup: "^2.78.0||^3.0.0||^4.0.0"
18
18
  };
@@ -787,9 +787,18 @@ async function resolveWithExportMap({
787
787
  importer,
788
788
  moduleDirs: moduleDirectories,
789
789
  conditions: exportConditions,
790
+ // Resolve targets of "imports" mappings using the same algorithm
791
+ // we use for normal specifiers: try export maps first and then
792
+ // fall back to classic resolution. This is important for cases
793
+ // like "#foo/*": "@scope/pkg/*" where the target package relies
794
+ // on "exports" to expose subpaths. Using the classic resolver
795
+ // alone would fail to find those subpaths.
790
796
  resolveId(id /* , parent*/) {
791
- return resolveIdClassic({
792
- importSpecifier: id,
797
+ return resolveImportSpecifiers({
798
+ importer,
799
+ importSpecifierList: [id],
800
+ exportConditions,
801
+ // pass-through of the rest of the context
793
802
  packageInfoCache,
794
803
  extensions,
795
804
  mainFields,
@@ -797,11 +806,22 @@ async function resolveWithExportMap({
797
806
  useBrowserOverrides,
798
807
  baseDir,
799
808
  moduleDirectories,
800
- modulePaths
809
+ modulePaths,
810
+ rootDir,
811
+ ignoreSideEffectsForRoot,
812
+ allowExportsFolderMapping
801
813
  });
802
814
  }
803
815
  });
804
816
 
817
+ if (resolveResult == null) {
818
+ // When the target of an "imports" mapping cannot be resolved,
819
+ // surface a proper resolve error instead of throwing from
820
+ // fileURLToPath(null).
821
+ throw new ResolveError(
822
+ `Could not resolve import "${importSpecifier}" in ${importer} using imports.`
823
+ );
824
+ }
805
825
  const location = url.fileURLToPath(resolveResult);
806
826
  return {
807
827
  location: preserveSymlinks ? location : await resolveSymlink(location),
@@ -1167,7 +1187,7 @@ function nodeResolve(opts = {}) {
1167
1187
 
1168
1188
  const importSpecifierList = [importee];
1169
1189
 
1170
- if (importer === undefined && !importee[0].match(/^\.?\.?\//)) {
1190
+ if (importer === undefined && importee[0] && !importee[0].match(/^\.?\.?\//)) {
1171
1191
  // For module graph roots (i.e. when importer is undefined), we
1172
1192
  // need to handle 'path fragments` like `foo/bar` that are commonly
1173
1193
  // found in rollup config files. If importee doesn't look like a
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 = "16.0.1";
11
+ var version = "16.0.3";
12
12
  var peerDependencies = {
13
13
  rollup: "^2.78.0||^3.0.0||^4.0.0"
14
14
  };
@@ -783,9 +783,18 @@ async function resolveWithExportMap({
783
783
  importer,
784
784
  moduleDirs: moduleDirectories,
785
785
  conditions: exportConditions,
786
+ // Resolve targets of "imports" mappings using the same algorithm
787
+ // we use for normal specifiers: try export maps first and then
788
+ // fall back to classic resolution. This is important for cases
789
+ // like "#foo/*": "@scope/pkg/*" where the target package relies
790
+ // on "exports" to expose subpaths. Using the classic resolver
791
+ // alone would fail to find those subpaths.
786
792
  resolveId(id /* , parent*/) {
787
- return resolveIdClassic({
788
- importSpecifier: id,
793
+ return resolveImportSpecifiers({
794
+ importer,
795
+ importSpecifierList: [id],
796
+ exportConditions,
797
+ // pass-through of the rest of the context
789
798
  packageInfoCache,
790
799
  extensions,
791
800
  mainFields,
@@ -793,11 +802,22 @@ async function resolveWithExportMap({
793
802
  useBrowserOverrides,
794
803
  baseDir,
795
804
  moduleDirectories,
796
- modulePaths
805
+ modulePaths,
806
+ rootDir,
807
+ ignoreSideEffectsForRoot,
808
+ allowExportsFolderMapping
797
809
  });
798
810
  }
799
811
  });
800
812
 
813
+ if (resolveResult == null) {
814
+ // When the target of an "imports" mapping cannot be resolved,
815
+ // surface a proper resolve error instead of throwing from
816
+ // fileURLToPath(null).
817
+ throw new ResolveError(
818
+ `Could not resolve import "${importSpecifier}" in ${importer} using imports.`
819
+ );
820
+ }
801
821
  const location = fileURLToPath(resolveResult);
802
822
  return {
803
823
  location: preserveSymlinks ? location : await resolveSymlink(location),
@@ -1163,7 +1183,7 @@ function nodeResolve(opts = {}) {
1163
1183
 
1164
1184
  const importSpecifierList = [importee];
1165
1185
 
1166
- if (importer === undefined && !importee[0].match(/^\.?\.?\//)) {
1186
+ if (importer === undefined && importee[0] && !importee[0].match(/^\.?\.?\//)) {
1167
1187
  // For module graph roots (i.e. when importer is undefined), we
1168
1188
  // need to handle 'path fragments` like `foo/bar` that are commonly
1169
1189
  // found in rollup config files. If importee doesn't look like a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rollup/plugin-node-resolve",
3
- "version": "16.0.1",
3
+ "version": "16.0.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },