Skip to content

Commit 914b980

Browse files
zyzyzyryxyPiotr Paulski
andauthored
refactor: bundle all dependencies together (#450)
Final bundling step for improved startup times. --------- Co-authored-by: Piotr Paulski <[email protected]>
1 parent 4c65f59 commit 914b980

27 files changed

+103
-93
lines changed

package-lock.json

Lines changed: 20 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@
3737
},
3838
"homepage": "https://github.com/ChromeDevTools/chrome-devtools-mcp#readme",
3939
"mcpName": "io.github.ChromeDevTools/chrome-devtools-mcp",
40-
"dependencies": {
41-
"core-js": "3.46.0",
42-
"debug": "4.4.3",
43-
"yargs": "18.0.0"
44-
},
4540
"devDependencies": {
4641
"@eslint/js": "^9.35.0",
4742
"@modelcontextprotocol/sdk": "1.20.1",
@@ -57,6 +52,8 @@
5752
"@typescript-eslint/eslint-plugin": "^8.43.0",
5853
"@typescript-eslint/parser": "^8.43.0",
5954
"chrome-devtools-frontend": "1.0.1524741",
55+
"core-js": "3.46.0",
56+
"debug": "4.4.3",
6057
"eslint": "^9.35.0",
6158
"eslint-import-resolver-typescript": "^4.4.4",
6259
"eslint-plugin-import": "^2.32.0",
@@ -68,7 +65,8 @@
6865
"rollup-plugin-license": "^3.6.0",
6966
"sinon": "^21.0.0",
7067
"typescript": "^5.9.2",
71-
"typescript-eslint": "^8.43.0"
68+
"typescript-eslint": "^8.43.0",
69+
"yargs": "18.0.0"
7270
},
7371
"engines": {
7472
"node": "^20.19.0 || ^22.12.0 || >=23"

rollup.config.mjs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const allowedLicenses = [
4242
/**
4343
* @param {string} wrapperIndexPath
4444
* @param {import('rollup').OutputOptions} [extraOutputOptions={}]
45-
* @param {string[]} [external=[]]
45+
* @param {import('rollup').ExternalOption} [external=[]]
4646
* @returns {import('rollup').RollupOptions}
4747
*/
4848
const bundleDependency = (
@@ -110,12 +110,26 @@ const bundleDependency = (
110110
});
111111

112112
export default [
113-
bundleDependency('./build/src/third_party/modelcontextprotocol-sdk/index.js'),
114113
bundleDependency(
115-
'./build/src/third_party/puppeteer-core/index.js',
114+
'./build/src/third_party/index.js',
116115
{
117116
inlineDynamicImports: true,
118117
},
119-
['./bidi.js', '../bidi/bidi.js'],
118+
(source, importer, _isResolved) => {
119+
if (
120+
source === 'yargs' &&
121+
importer &&
122+
importer.includes('puppeteer-core')
123+
) {
124+
return true;
125+
}
126+
127+
const existingExternals = ['./bidi.js', '../bidi/bidi.js'];
128+
if (existingExternals.includes(source)) {
129+
return true;
130+
}
131+
132+
return false;
133+
},
120134
),
121135
];

src/DevToolsConnectionAdapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import {Connection} from '../node_modules/chrome-devtools-frontend/front_end/core/protocol_client/InspectorBackend.js';
88

9-
import {type ConnectionTransport} from './third_party/puppeteer-core/index.js';
9+
import {type ConnectionTransport} from './third_party/index.js';
1010

1111
/**
1212
* Allows a puppeteer {@link ConnectionTransport} to act like a DevTools {@link Connection}.

src/McpContext.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,20 @@ import fs from 'node:fs/promises';
77
import os from 'node:os';
88
import path from 'node:path';
99

10-
import type {Debugger} from 'debug';
11-
1210
import type {ListenerMap} from './PageCollector.js';
1311
import {NetworkCollector, PageCollector} from './PageCollector.js';
14-
import {Locator} from './third_party/puppeteer-core/index.js';
12+
import {Locator} from './third_party/index.js';
1513
import type {
1614
Browser,
1715
ConsoleMessage,
16+
Debugger,
1817
Dialog,
1918
ElementHandle,
2019
HTTPRequest,
2120
Page,
2221
SerializedAXNode,
2322
PredefinedNetworkConditions,
24-
} from './third_party/puppeteer-core/index.js';
23+
} from './third_party/index.js';
2524
import {listPages} from './tools/pages.js';
2625
import {takeSnapshot} from './tools/snapshot.js';
2726
import {CLOSE_PAGE_ERROR} from './tools/ToolDefinition.js';

src/McpResponse.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@ import {
1717
} from './formatters/networkFormatter.js';
1818
import {formatA11ySnapshot} from './formatters/snapshotFormatter.js';
1919
import type {McpContext} from './McpContext.js';
20-
import type {
21-
ImageContent,
22-
TextContent,
23-
} from './third_party/modelcontextprotocol-sdk/index.js';
2420
import type {
2521
ConsoleMessage,
22+
ImageContent,
2623
ResourceType,
27-
} from './third_party/puppeteer-core/index.js';
24+
TextContent,
25+
} from './third_party/index.js';
2826
import {handleDialog} from './tools/pages.js';
2927
import type {ImageContentData, Response} from './tools/ToolDefinition.js';
3028
import {paginate} from './utils/pagination.js';

src/PageCollector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
type HTTPRequest,
1212
type Page,
1313
type PageEvents,
14-
} from './third_party/puppeteer-core/index.js';
14+
} from './third_party/index.js';
1515

1616
export type ListenerMap<EventMap extends PageEvents = PageEvents> = {
1717
[K in keyof EventMap]?: (event: EventMap[K]) => void;

src/WaitForHelper.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
* Copyright 2025 Google LLC
44
* SPDX-License-Identifier: Apache-2.0
55
*/
6-
import type {CdpPage} from 'puppeteer-core/internal/cdp/Page.js';
7-
86
import {logger} from './logger.js';
9-
import type {Page, Protocol} from './third_party/puppeteer-core/index.js';
7+
import type {Page, Protocol, CdpPage} from './third_party/index.js';
108

119
export class WaitForHelper {
1210
#abortController = new AbortController();

src/browser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import type {
1313
ChromeReleaseChannel,
1414
LaunchOptions,
1515
Target,
16-
} from './third_party/puppeteer-core/index.js';
17-
import {puppeteer} from './third_party/puppeteer-core/index.js';
16+
} from './third_party/index.js';
17+
import {puppeteer} from './third_party/index.js';
1818

1919
let browser: Browser | undefined;
2020

src/cli.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
import type {Options as YargsOptions} from 'yargs';
8-
import yargs from 'yargs';
9-
import {hideBin} from 'yargs/helpers';
7+
import type {YargsOptions} from './third_party/index.js';
8+
import {yargs, hideBin} from './third_party/index.js';
109

1110
export const cliOptions = {
1211
browserUrl: {

0 commit comments

Comments
 (0)