(modulePath)
| 60 | path.join(process.cwd(), 'node_modules') + path.sep; |
| 61 | |
| 62 | function getPackageName(modulePath) { |
| 63 | // Handle rollup's virtual module paths (paths starting with 0x00) |
| 64 | const absolutePathStart = modulePath.indexOf(projectNodeModulesPath); |
| 65 | if (absolutePathStart < 0) { |
| 66 | return null; |
| 67 | } |
| 68 | |
| 69 | const relativePath = modulePath.slice( |
| 70 | projectNodeModulesPath.length + absolutePathStart, |
| 71 | ); |
| 72 | const segments = relativePath.split(path.sep); |
| 73 | |
| 74 | // handle scoped packages |
| 75 | if (segments[0].startsWith('@') && segments[1]) { |
| 76 | return `${segments[0]}/${segments[1]}`; |
| 77 | } |
| 78 | return segments[0]; |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * @returns {import('rollup').Plugin} |
no test coverage detected