(options, bundle)
| 86 | return { |
| 87 | name: 'gather-bundled-dependencies', |
| 88 | generateBundle(options, bundle) { |
| 89 | for (const chunk of Object.values(bundle)) { |
| 90 | if (chunk.type === 'chunk' && chunk.modules) { |
| 91 | // chunk.modules is an object where keys are the absolute file paths |
| 92 | Object.keys(chunk.modules).forEach(modulePath => { |
| 93 | const packageName = getPackageName(modulePath); |
| 94 | if (packageName) { |
| 95 | aggregatedStats.bundledPackages.add(packageName); |
| 96 | } |
| 97 | }); |
| 98 | } |
| 99 | } |
| 100 | aggregatedStats.bundlesProcessed++; |
| 101 | |
| 102 | // Only write the file when the last bundle is finished |
| 103 | if (aggregatedStats.bundlesProcessed === aggregatedStats.totalBundles) { |
| 104 | const outputPath = path.join(thirdPartyDir, 'bundled-packages.json'); |
| 105 | |
| 106 | const bundledDevDeps = Object.fromEntries( |
| 107 | Object.entries(devDependencies).filter( |
| 108 | ([name]) => |
| 109 | aggregatedStats.bundledPackages.has(name) || |
| 110 | name === 'chrome-devtools-frontend' || |
| 111 | name === 'lighthouse', |
| 112 | ), |
| 113 | ); |
| 114 | |
| 115 | fs.writeFileSync(outputPath, JSON.stringify(bundledDevDeps, null, 2)); |
| 116 | } |
| 117 | }, |
| 118 | }; |
| 119 | } |
| 120 |
nothing calls this directly
no test coverage detected