diff --git a/rollup.config.mjs b/rollup.config.mjs index b03ee276..274a93c1 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -29,11 +29,14 @@ import license from 'rollup-plugin-license'; const isProduction = process.env.NODE_ENV === 'production'; -/** @type {import('rollup').RollupOptions} */ -const sdk = { - input: './build/src/third_party/modelcontextprotocol-sdk/index.js', +const allowed_licenses = ['MIT', 'Apache 2.0', 'Apache-2.0', 'BSD-3-Clause', 'BSD-2-Clause', 'ISC', '0BSD']; + +/** @returns {import('rollup').RollupOptions} */ +const bundleDependency = (wrapperIndexPath, extraOutputOptions = {}) => ({ + input: wrapperIndexPath, output: { - file: './build/src/third_party/modelcontextprotocol-sdk/index.js', + ...extraOutputOptions, + file: wrapperIndexPath, sourcemap: !isProduction, format: 'esm', }, @@ -48,7 +51,6 @@ const sdk = { thirdParty: { allow: { test: dependency => { - let allowed_licenses = ['MIT', 'Apache 2.0', 'BSD-2-Clause', 'ISC']; return allowed_licenses.includes(dependency.license); }, failOnUnlicensed: true, @@ -90,6 +92,9 @@ const sdk = { json(), nodeResolve(), ], -}; +}); -export default [sdk]; +export default [ + bundleDependency('./build/src/third_party/modelcontextprotocol-sdk/index.js'), + bundleDependency('./build/src/third_party/puppeteer-core/index.js', {inlineDynamicImports: true}), +]; diff --git a/src/browser.ts b/src/browser.ts index d76d5a9f..f129ec76 100644 --- a/src/browser.ts +++ b/src/browser.ts @@ -14,7 +14,8 @@ import type { LaunchOptions, Target, } from 'puppeteer-core'; -import puppeteer from 'puppeteer-core'; + +import {puppeteer} from './third_party/puppeteer-core/index.js'; let browser: Browser | undefined; diff --git a/src/third_party/puppeteer-core/index.ts b/src/third_party/puppeteer-core/index.ts new file mode 100644 index 00000000..42718705 --- /dev/null +++ b/src/third_party/puppeteer-core/index.ts @@ -0,0 +1,8 @@ +/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +export {Locator,PredefinedNetworkConditions} from 'puppeteer-core'; +export {default as puppeteer} from 'puppeteer-core'; diff --git a/src/tools/emulation.ts b/src/tools/emulation.ts index d65ac5e8..fed24a00 100644 --- a/src/tools/emulation.ts +++ b/src/tools/emulation.ts @@ -4,9 +4,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {PredefinedNetworkConditions} from 'puppeteer-core'; import {zod} from '../third_party/modelcontextprotocol-sdk/index.js'; +import {PredefinedNetworkConditions} from '../third_party/puppeteer-core/index.js'; import {ToolCategories} from './categories.js'; import {defineTool} from './ToolDefinition.js'; diff --git a/src/tools/snapshot.ts b/src/tools/snapshot.ts index fb774f78..bd148125 100644 --- a/src/tools/snapshot.ts +++ b/src/tools/snapshot.ts @@ -4,9 +4,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {Locator} from 'puppeteer-core'; import {zod} from '../third_party/modelcontextprotocol-sdk/index.js'; +import {Locator} from '../third_party/puppeteer-core/index.js'; import {ToolCategories} from './categories.js'; import {defineTool, timeoutSchema} from './ToolDefinition.js';