MCPcopy
hub / github.com/ChromeDevTools/chrome-devtools-mcp / generateBundle

Function generateBundle

rollup.config.mjs:88–117  ·  view source on GitHub ↗
(options, bundle)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

getPackageNameFunction · 0.85
keysMethod · 0.80
joinMethod · 0.80
hasMethod · 0.45

Tested by

no test coverage detected