From 880ad5a86c15db1d46bdab3d8aa5ca201d639ec5 Mon Sep 17 00:00:00 2001 From: James Stuckey Weber Date: Wed, 1 Nov 2023 16:23:21 -0400 Subject: [PATCH] Exports algorithm --- lib/src/importer/node_package.dart | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/src/importer/node_package.dart b/lib/src/importer/node_package.dart index 887419532..eb8012ed9 100644 --- a/lib/src/importer/node_package.dart +++ b/lib/src/importer/node_package.dart @@ -153,7 +153,7 @@ Uri? resolvePackageExports(Uri packageRoot, String subpath, var resolvedIndexpaths = _nodePackageExportsResolve(packageRoot, subpathIndexVariants, exports); - if (resolvedIndexpaths.length == 1) return resolvedPaths.first; + if (resolvedIndexpaths.length == 1) return resolvedIndexpaths.first; if (resolvedIndexpaths.length > 1) { throw "Unable to determine which of multiple potential" "resolutions found for $subpath in $packageName should be used."; @@ -169,10 +169,18 @@ List _nodePackageExportsResolve( Uri packageRoot, List subpathVariants, Object exports) { Uri? processVariant(String subpath) { if (subpath == '') { - // main export Object? mainExport = _getMainExport(exports); if (mainExport == null) return null; - return _packageTargetResolve(subpath, exports, packageRoot); + return _packageTargetResolve(subpath, mainExport, packageRoot); + } else { + if (exports is Map && + exports.keys.every((key) => key.startsWith('.'))) { + var matchKey = "./$subpath"; + if (exports.containsKey(matchKey)) { + return _packageTargetResolve( + matchKey, exports[matchKey] as Object, packageRoot); + } + } } return null; }