Skip to content

Commit 6729ad1

Browse files
author
Piotr Paulski
committed
Move puppeteer-core into the main bundle.
1 parent cddcb0b commit 6729ad1

18 files changed

+35
-32
lines changed

rollup.config.mjs

Lines changed: 14 additions & 5 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,21 @@ const bundleDependency = (
110110
});
111111

112112
export default [
113-
bundleDependency('./build/src/third_party/index.js'),
114-
bundleDependency(
115-
'./build/src/third_party/puppeteer-core/index.js',
113+
bundleDependency('./build/src/third_party/index.js',
116114
{
117115
inlineDynamicImports: true,
118116
},
119-
['./bidi.js', '../bidi/bidi.js'],
117+
(source, importer, _isResolved) => {
118+
if (source === 'yargs' && importer && importer.includes('puppeteer-core')) {
119+
return true;
120+
}
121+
122+
const existingExternals = ['./bidi.js', '../bidi/bidi.js'];
123+
if (existingExternals.includes(source)) {
124+
return true;
125+
}
126+
127+
return false;
128+
},
120129
),
121130
];

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import path from 'node:path';
1010
import type {ListenerMap} from './PageCollector.js';
1111
import {NetworkCollector, PageCollector} from './PageCollector.js';
1212
import type {Debugger} from './third_party/index.js';
13-
import {Locator} from './third_party/puppeteer-core/index.js';
13+
import {Locator} from './third_party/index.js';
1414
import type {
1515
Browser,
1616
ConsoleMessage,
@@ -20,7 +20,7 @@ import type {
2020
Page,
2121
SerializedAXNode,
2222
PredefinedNetworkConditions,
23-
} from './third_party/puppeteer-core/index.js';
23+
} from './third_party/index.js';
2424
import {listPages} from './tools/pages.js';
2525
import {takeSnapshot} from './tools/snapshot.js';
2626
import {CLOSE_PAGE_ERROR} from './tools/ToolDefinition.js';

src/McpResponse.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import type {
2424
import type {
2525
ConsoleMessage,
2626
ResourceType,
27-
} from './third_party/puppeteer-core/index.js';
27+
} from './third_party/index.js';
2828
import {handleDialog} from './tools/pages.js';
2929
import type {ImageContentData, Response} from './tools/ToolDefinition.js';
3030
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66
import {logger} from './logger.js';
7-
import type {Page, Protocol, CdpPage} from './third_party/puppeteer-core/index.js';
7+
import type {Page, Protocol, CdpPage} from './third_party/index.js';
88

99
export class WaitForHelper {
1010
#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/formatters/networkFormatter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {isUtf8} from 'node:buffer';
99
import type {
1010
HTTPRequest,
1111
HTTPResponse,
12-
} from '../third_party/puppeteer-core/index.js';
12+
} from '../third_party/index.js';
1313

1414
const BODY_CONTEXT_SIZE_LIMIT = 10000;
1515

src/third_party/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ export {
2020
type TextContent,
2121
} from '@modelcontextprotocol/sdk/types.js';
2222
export {z as zod} from 'zod';
23+
export {Locator, PredefinedNetworkConditions} from 'puppeteer-core';
24+
export {default as puppeteer} from 'puppeteer-core';
25+
export type * from 'puppeteer-core';
26+
export type {CdpPage} from 'puppeteer-core/internal/cdp/Page.js';

src/third_party/puppeteer-core/index.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)