(specifier, base)
| 265 | } |
| 266 | |
| 267 | function getPackageJSONURL(specifier, base) { |
| 268 | const { packageName, packageSubpath, isScoped } = parsePackageName(specifier, base); |
| 269 | |
| 270 | // ResolveSelf |
| 271 | const packageConfig = getPackageScopeConfig(base); |
| 272 | if (packageConfig.exists) { |
| 273 | if (packageConfig.exports != null && packageConfig.name === packageName) { |
| 274 | const packageJSONPath = packageConfig.pjsonPath; |
| 275 | return { packageJSONUrl: pathToFileURL(packageJSONPath), packageJSONPath, packageSubpath }; |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | let packageJSONUrl = new URL(`./node_modules/${packageName}/package.json`, base); |
| 280 | let packageJSONPath = fileURLToPath(packageJSONUrl); |
| 281 | let lastPath; |
| 282 | do { |
| 283 | const stat = internalFsBinding.internalModuleStat( |
| 284 | StringPrototypeSlice(packageJSONPath, 0, packageJSONPath.length - 13), |
| 285 | ); |
| 286 | // Check for !stat.isDirectory() |
| 287 | if (stat !== 1) { |
| 288 | lastPath = packageJSONPath; |
| 289 | packageJSONUrl = new URL( |
| 290 | `${isScoped ? '../' : ''}../../../node_modules/${packageName}/package.json`, |
| 291 | packageJSONUrl, |
| 292 | ); |
| 293 | packageJSONPath = fileURLToPath(packageJSONUrl); |
| 294 | continue; |
| 295 | } |
| 296 | |
| 297 | // Package match. |
| 298 | return { packageJSONUrl, packageJSONPath, packageSubpath }; |
| 299 | } while (packageJSONPath.length !== lastPath.length); |
| 300 | |
| 301 | throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base), null); |
| 302 | } |
| 303 | |
| 304 | /** @type {import('./esm/resolve.js').defaultResolve} */ |
| 305 | let defaultResolve; |
no test coverage detected
searching dependent graphs…