rollup.config.mjs (1424B)
1 /** 2 * @license 3 * Copyright 2024 Google Inc. 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 import path from 'path'; 7 8 import {getBabelOutputPlugin} from '@rollup/plugin-babel'; 9 import {nodeResolve} from '@rollup/plugin-node-resolve'; 10 11 const cwd = process.cwd(); 12 13 export default { 14 input: 'lib/esm/puppeteer/puppeteer-core-browser.js', 15 output: { 16 format: 'iife', 17 file: 'lib/es5-iife/puppeteer-core-browser.js', 18 name: 'Puppeteer', 19 }, 20 external: (id, parent, isResolved) => { 21 if (id.includes('BrowserConnector')) { 22 return false; 23 } 24 if (id.includes('BrowserWebSocketTransport')) { 25 return false; 26 } 27 if (id.includes('node_modules')) { 28 return true; 29 } 30 if (id.startsWith(path.join(cwd, `lib`, `esm`, `puppeteer`, `bidi`))) { 31 return true; 32 } 33 if (id.startsWith(path.join(cwd, `lib`, `esm`, `puppeteer`, `node`))) { 34 return true; 35 } 36 return false; 37 }, 38 plugins: [ 39 nodeResolve({ 40 browser: true, 41 }), 42 getBabelOutputPlugin({ 43 plugins: [ 44 '@babel/plugin-transform-class-static-block', 45 '@babel/plugin-transform-private-methods', 46 '@babel/plugin-transform-private-property-in-object', 47 '@babel/plugin-transform-class-properties', 48 '@babel/plugin-transform-dynamic-import', 49 '@babel/plugin-transform-modules-commonjs', 50 ], 51 allowAllFormats: true, 52 compact: false, 53 }), 54 ], 55 };