bare-module-resolve
Advanced tools
+37
-20
@@ -267,12 +267,5 @@ const { satisfies } = require('bare-semver') | ||
| do { | ||
| const packageURL = new URL('node_modules/' + packageName + '/', parentURL) | ||
| for (const packageURL of exports.lookupPackageRoot(packageName, parentURL)) { | ||
| const info = yield { package: packageURL } | ||
| parentURL.pathname = parentURL.pathname.substring( | ||
| 0, | ||
| parentURL.pathname.lastIndexOf('/') | ||
| ) | ||
| const info = yield { package: new URL('package.json', packageURL) } | ||
| if (info) { | ||
@@ -304,3 +297,3 @@ if (info.engines) exports.validateEngines(packageURL, info.engines, opts) | ||
| } | ||
| } while (parentURL.pathname !== '' && parentURL.pathname !== '/') | ||
| } | ||
@@ -403,4 +396,2 @@ return UNRESOLVED | ||
| packageURL = new URL('package.json', packageURL) | ||
| throw errors.PACKAGE_PATH_NOT_EXPORTED( | ||
@@ -529,4 +520,2 @@ `Package subpath '${subpath}' is not defined by "exports" in '${packageURL}'` | ||
| if (!satisfies(version, range)) { | ||
| packageURL = new URL('package.json', packageURL) | ||
| throw errors.UNSUPPORTED_ENGINE( | ||
@@ -565,4 +554,2 @@ `Package not compatible with engine '${engine}' ${version}, requires range '${range}' defined by "engines" in '${packageURL}'` | ||
| if (!target.startsWith('./') && !isImports) { | ||
| packageURL = new URL('package.json', packageURL) | ||
| throw errors.INVALID_PACKAGE_TARGET( | ||
@@ -755,3 +742,29 @@ `Invalid target '${target}' defined by "exports" in '${packageURL}'` | ||
| exports.lookupPackageScope = function* lookupPackageScope(url, opts = {}) { | ||
| exports.lookupPackageRoot = function* (packageName, parentURL) { | ||
| parentURL = new URL(parentURL.href) | ||
| do { | ||
| const packageURL = new URL('node_modules/' + packageName + '/', parentURL) | ||
| const info = yield new URL('package.json', packageURL) | ||
| if (info) return info | ||
| parentURL.pathname = parentURL.pathname.substring( | ||
| 0, | ||
| parentURL.pathname.lastIndexOf('/') | ||
| ) | ||
| if ( | ||
| parentURL.pathname.length === 3 && | ||
| exports.isWindowsDriveLetter(parentURL.pathname.substring(1)) | ||
| ) { | ||
| break | ||
| } | ||
| } while (parentURL.pathname !== '' && parentURL.pathname !== '/') | ||
| return null | ||
| } | ||
| exports.lookupPackageScope = function* lookupPackageScope(scopeURL, opts = {}) { | ||
| const { resolutions = null } = opts | ||
@@ -763,3 +776,3 @@ | ||
| resolutions, | ||
| url, | ||
| scopeURL, | ||
| opts | ||
@@ -771,3 +784,3 @@ )) { | ||
| const scopeURL = new URL(url.href) | ||
| scopeURL = new URL(scopeURL.href) | ||
@@ -777,4 +790,6 @@ do { | ||
| yield new URL('package.json', scopeURL) | ||
| const info = yield new URL('package.json', scopeURL) | ||
| if (info) return info | ||
| scopeURL.pathname = scopeURL.pathname.substring( | ||
@@ -792,2 +807,4 @@ 0, | ||
| } while (scopeURL.pathname !== '' && scopeURL.pathname !== '/') | ||
| return null | ||
| } | ||
@@ -794,0 +811,0 @@ |
+1
-1
| { | ||
| "name": "bare-module-resolve", | ||
| "version": "1.11.3", | ||
| "version": "1.12.0", | ||
| "description": "Low-level module resolution algorithm for Bare", | ||
@@ -5,0 +5,0 @@ "exports": { |
+4
-7
@@ -205,7 +205,5 @@ # bare-module-resolve | ||
| 9. If `packageSelf(packageName, packageSubpath, parentURL, options)` yields, return. | ||
| 10. Repeat: | ||
| 1. Let `packageURL` be the resolution of `node_modules/` concatenated with `packageName` and `/` relative to `parentURL`. | ||
| 2. Set `parentURL` to the substring of `parentURL` until the last `/`. | ||
| 3. Let `info` be the result of yielding the resolution of `package.json` relative to `packageURL`. | ||
| 4. If `info` is not `null`: | ||
| 10. For each value `packageURL` of `lookupPackageRoot(packageName, parentURL, options)`: | ||
| 1. Let `info` be the result of yielding `packageURL`. | ||
| 2. If `info` is not `null`: | ||
| 1. If `info.engines` is set: | ||
@@ -222,3 +220,2 @@ 1. Call `validateEngines(packageURL, info.engines, options)`. | ||
| 5. Return `directory(packageSubpath, packageURL, options)`. | ||
| 5. If `parentURL` is the file system root, return. | ||
@@ -263,3 +260,3 @@ #### `const generator = resolve.packageSelf(packageName, packageSubpath, parentURL[, options])` | ||
| 1. If `specifier` is `#` or starts with `#/`, throw. | ||
| 2. For each value `packageURL` of `lookupPackageScope(parentURL, opions)`: | ||
| 2. For each value `packageURL` of `lookupPackageScope(parentURL, options)`: | ||
| 1. Let `info` be the result of yielding `packageURL`. | ||
@@ -266,0 +263,0 @@ 2. If `info` is not `null`: |
55809
0.15%922
1.43%357
-0.83%