Skip to content

Commit f1fe838

Browse files
author
Piotr Paulski
committed
refactor: bundle puppeteer-core
1 parent 5c871c3 commit f1fe838

File tree

5 files changed

+24
-10
lines changed

5 files changed

+24
-10
lines changed

rollup.config.mjs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,14 @@ import license from 'rollup-plugin-license';
2929

3030
const isProduction = process.env.NODE_ENV === 'production';
3131

32-
/** @type {import('rollup').RollupOptions} */
33-
const sdk = {
34-
input: './build/src/third_party/modelcontextprotocol-sdk/index.js',
32+
const allowed_licenses = ['MIT', 'Apache 2.0', 'Apache-2.0', 'BSD-3-Clause', 'BSD-2-Clause', 'ISC', '0BSD'];
33+
34+
/** @returns {import('rollup').RollupOptions} */
35+
const bundleDependency = (wrapperIndexPath, extraOutputOptions = {}) => ({
36+
input: wrapperIndexPath,
3537
output: {
36-
file: './build/src/third_party/modelcontextprotocol-sdk/index.js',
38+
...extraOutputOptions,
39+
file: wrapperIndexPath,
3740
sourcemap: !isProduction,
3841
format: 'esm',
3942
},
@@ -48,7 +51,6 @@ const sdk = {
4851
thirdParty: {
4952
allow: {
5053
test: dependency => {
51-
let allowed_licenses = ['MIT', 'Apache 2.0', 'BSD-2-Clause', 'ISC'];
5254
return allowed_licenses.includes(dependency.license);
5355
},
5456
failOnUnlicensed: true,
@@ -90,6 +92,9 @@ const sdk = {
9092
json(),
9193
nodeResolve(),
9294
],
93-
};
95+
});
9496

95-
export default [sdk];
97+
export default [
98+
bundleDependency('./build/src/third_party/modelcontextprotocol-sdk/index.js'),
99+
bundleDependency('./build/src/third_party/puppeteer-core/index.js', {inlineDynamicImports: true}),
100+
];

src/browser.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import type {
1414
LaunchOptions,
1515
Target,
1616
} from 'puppeteer-core';
17-
import puppeteer from 'puppeteer-core';
17+
18+
import {puppeteer} from './third_party/puppeteer-core/index.js';
1819

1920
let browser: Browser | undefined;
2021

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @license
3+
* Copyright 2025 Google LLC
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
export {Locator,PredefinedNetworkConditions} from 'puppeteer-core';
8+
export {default as puppeteer} from 'puppeteer-core';

src/tools/emulation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
import {PredefinedNetworkConditions} from 'puppeteer-core';
87

98
import {zod} from '../third_party/modelcontextprotocol-sdk/index.js';
9+
import {PredefinedNetworkConditions} from '../third_party/puppeteer-core/index.js';
1010

1111
import {ToolCategories} from './categories.js';
1212
import {defineTool} from './ToolDefinition.js';

src/tools/snapshot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
import {Locator} from 'puppeteer-core';
87

98
import {zod} from '../third_party/modelcontextprotocol-sdk/index.js';
9+
import {Locator} from '../third_party/puppeteer-core/index.js';
1010

1111
import {ToolCategories} from './categories.js';
1212
import {defineTool, timeoutSchema} from './ToolDefinition.js';

0 commit comments

Comments
 (0)