(absPath: string)
| 1414 | } |
| 1415 | |
| 1416 | private getSourceRootAbsModuleId(absPath: string) { |
| 1417 | const relPath = pathRelative(this.sourceRoot, absPath); |
| 1418 | |
| 1419 | if (relPath.startsWith("..")) { |
| 1420 | // absPath is not a subdirectory of this.sourceRoot. |
| 1421 | return; |
| 1422 | } |
| 1423 | |
| 1424 | const dirs = relPath.split("/"); |
| 1425 | dirs.pop(); // Discard the module's filename. |
| 1426 | while (dirs[0] === "") { |
| 1427 | dirs.shift(); |
| 1428 | } |
| 1429 | |
| 1430 | const isApp = ! this.name; |
| 1431 | const bundlingForWeb = this.isWeb(); |
| 1432 | |
| 1433 | const topLevelDir = dirs[0]; |
| 1434 | if (topLevelDir === "private" || |
| 1435 | topLevelDir === "packages" || |
| 1436 | topLevelDir === "programs" || |
| 1437 | topLevelDir === "cordova-build-override") { |
| 1438 | // Don't load anything from these special top-level directories |
| 1439 | return; |
| 1440 | } |
| 1441 | |
| 1442 | for (let dir of dirs) { |
| 1443 | if (dir.charAt(0) === ".") { |
| 1444 | // Files/directories whose names start with a dot are never loaded |
| 1445 | return; |
| 1446 | } |
| 1447 | |
| 1448 | if (isApp) { |
| 1449 | if (bundlingForWeb) { |
| 1450 | if (dir === "server") { |
| 1451 | // If we're bundling an app for a client architecture, any files |
| 1452 | // contained by a server-only directory that is not contained by |
| 1453 | // a node_modules directory must be ignored. |
| 1454 | return; |
| 1455 | } |
| 1456 | } else if (dir === "client") { |
| 1457 | // If we're bundling an app for a server architecture, any files |
| 1458 | // contained by a client-only directory that is not contained by |
| 1459 | // a node_modules directory must be ignored. |
| 1460 | return; |
| 1461 | } |
| 1462 | } |
| 1463 | |
| 1464 | if (dir === "node_modules") { |
| 1465 | // Accept any file within a node_modules directory. |
| 1466 | return ensureLeadingSlash(relPath); |
| 1467 | } |
| 1468 | } |
| 1469 | |
| 1470 | return ensureLeadingSlash(relPath); |
| 1471 | } |
| 1472 | |
| 1473 | // Called by this.resolver when a module identifier cannot be resolved. |
no test coverage detected