mirror of
https://github.com/hanzoai/puppeteer.git
synced 2026-09-24 17:02:14 +00:00
feat!: move packages to ESM only (#14355)
This commit is contained in:
@@ -130,7 +130,7 @@ information on using pull requests.
|
||||
Our coding style is fully defined in
|
||||
[`eslint.config`](https://github.com/puppeteer/puppeteer/blob/main/eslint.config.mjs)
|
||||
([ESLint](https://eslint.org/)) and
|
||||
[`.prettierrc.cjs`](https://github.com/puppeteer/puppeteer/blob/main/.prettierrc.cjs)
|
||||
[`prettier.config.js`](https://github.com/puppeteer/puppeteer/blob/main/prettier.config.js)
|
||||
([Prettier](https://prettier.io)).
|
||||
|
||||
Code is checked for PRs automatically and you can check your code
|
||||
|
||||
@@ -23,13 +23,13 @@ See https://github.com/puppeteer/puppeteer/tree/main/examples/puppeteer-in-exten
|
||||
|
||||
To run Puppeteer in an extension, first you need to produce a browser-compatible build using a bundler such as rollup or webpack:
|
||||
|
||||
1. When importing Puppeteer use the browser-specific entrypoint from puppeteer-core `puppeteer-core/lib/esm/puppeteer/puppeteer-core-browser.js'`:
|
||||
1. When importing Puppeteer use the browser-specific entrypoint from puppeteer-core `puppeteer-core/lib/puppeteer/puppeteer-core-browser.js'`:
|
||||
|
||||
```ts
|
||||
import {
|
||||
connect,
|
||||
ExtensionTransport,
|
||||
} from 'puppeteer-core/lib/esm/puppeteer/puppeteer-core-browser.js';
|
||||
} from 'puppeteer-core/lib/puppeteer/puppeteer-core-browser.js';
|
||||
|
||||
// Create a tab or find a tab to attach to.
|
||||
const tab = await chrome.tabs.create({
|
||||
@@ -59,8 +59,8 @@ export default {
|
||||
dir: 'out',
|
||||
},
|
||||
// If you do not need to use WebDriver BiDi protocol,
|
||||
// exclude chromium-bidi/lib/cjs/bidiMapper/BidiMapper.js to minimize the bundle size.
|
||||
external: ['chromium-bidi/lib/cjs/bidiMapper/BidiMapper.js'],
|
||||
// exclude chromium-bidi/lib/bidiMapper/BidiMapper.js to minimize the bundle size.
|
||||
external: ['chromium-bidi/lib/bidiMapper/BidiMapper.js'],
|
||||
plugins: [
|
||||
nodeResolve({
|
||||
// Indicate that we target a browser environment.
|
||||
|
||||
@@ -29,10 +29,10 @@ See https://github.com/puppeteer/puppeteer/tree/main/examples/puppeteer-in-brows
|
||||
|
||||
To run Puppeteer in the browser, first you need to produce a browser-compatible build using a bundler such as rollup or webpack:
|
||||
|
||||
1. When importing Puppeteer use the browser-specific entrypoint from puppeteer-core `puppeteer-core/lib/esm/puppeteer/puppeteer-core-browser.js'`:
|
||||
1. When importing Puppeteer use the browser-specific entrypoint from puppeteer-core `puppeteer-core/lib/puppeteer/puppeteer-core-browser.js'`:
|
||||
|
||||
```ts
|
||||
import puppeteer from 'puppeteer-core/lib/esm/puppeteer/puppeteer-core-browser.js';
|
||||
import puppeteer from 'puppeteer-core/lib/puppeteer/puppeteer-core-browser.js';
|
||||
|
||||
const browser = await puppeteer.connect({
|
||||
browserWSEndpoint: wsUrl,
|
||||
@@ -55,8 +55,8 @@ export default {
|
||||
dir: 'out',
|
||||
},
|
||||
// If you do not need to use WebDriver BiDi protocol,
|
||||
// exclude chromium-bidi/lib/cjs/bidiMapper/BidiMapper.js to minimize the bundle size.
|
||||
external: ['chromium-bidi/lib/cjs/bidiMapper/BidiMapper.js'],
|
||||
// exclude chromium-bidi/lib/bidiMapper/BidiMapper.js to minimize the bundle size.
|
||||
external: ['chromium-bidi/lib/bidiMapper/BidiMapper.js'],
|
||||
plugins: [
|
||||
nodeResolve({
|
||||
// Indicate that we target a browser environment.
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
// TODO: can rollup find the browser entrypoint?
|
||||
|
||||
import puppeteer from 'puppeteer-core/lib/esm/puppeteer/puppeteer-core-browser.js';
|
||||
import puppeteer from 'puppeteer-core/lib/puppeteer/puppeteer-core-browser.js';
|
||||
|
||||
async function onConnectClick() {
|
||||
const wsUrl = document.querySelector('#ws').value;
|
||||
|
||||
@@ -12,8 +12,8 @@ export default {
|
||||
dir: 'out',
|
||||
},
|
||||
// If you do not need to use WebDriver BiDi protocol,
|
||||
// exclude chromium-bidi/lib/cjs/bidiMapper/BidiMapper.js to minimize the bundle size.
|
||||
external: ['chromium-bidi/lib/cjs/bidiMapper/BidiMapper.js'],
|
||||
// exclude chromium-bidi/lib/bidiMapper/BidiMapper.js to minimize the bundle size.
|
||||
external: ['chromium-bidi/lib/bidiMapper/BidiMapper.js'],
|
||||
plugins: [
|
||||
nodeResolve({
|
||||
browser: true,
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import {
|
||||
connect,
|
||||
ExtensionTransport,
|
||||
} from 'puppeteer-core/lib/esm/puppeteer/puppeteer-core-browser.js';
|
||||
} from 'puppeteer-core/lib/puppeteer/puppeteer-core-browser.js';
|
||||
|
||||
globalThis.testConnect = async url => {
|
||||
const tab = await chrome.tabs.create({
|
||||
|
||||
@@ -12,8 +12,8 @@ export default {
|
||||
dir: 'out',
|
||||
},
|
||||
// If you do not need to use WebDriver BiDi protocol,
|
||||
// exclude chromium-bidi/lib/cjs/bidiMapper/BidiMapper.js to minimize the bundle size.
|
||||
external: ['chromium-bidi/lib/cjs/bidiMapper/BidiMapper.js'],
|
||||
// exclude chromium-bidi/lib/bidiMapper/BidiMapper.js to minimize the bundle size.
|
||||
external: ['chromium-bidi/lib/bidiMapper/BidiMapper.js'],
|
||||
plugins: [
|
||||
nodeResolve({
|
||||
browser: true,
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@
|
||||
]
|
||||
},
|
||||
"doctest": {
|
||||
"command": "npx ./tools/doctest 'packages/puppeteer-core/lib/esm/**/*.js'",
|
||||
"command": "npx ./tools/doctest 'packages/puppeteer-core/lib/**/*.js'",
|
||||
"dependencies": [
|
||||
"./packages/puppeteer-core:build",
|
||||
"./tools/doctest:build"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
||||
"mainEntryPointFilePath": "<projectFolder>/lib/esm/main.d.ts",
|
||||
"mainEntryPointFilePath": "<projectFolder>/lib/main.d.ts",
|
||||
|
||||
"extends": "./api-extractor.json",
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
||||
"mainEntryPointFilePath": "<projectFolder>/lib/esm/main.d.ts",
|
||||
"mainEntryPointFilePath": "<projectFolder>/lib/main.d.ts",
|
||||
"bundledPackages": [],
|
||||
|
||||
"apiReport": {
|
||||
|
||||
@@ -9,53 +9,27 @@
|
||||
"clean": "../../tools/clean.mjs",
|
||||
"test": "wireit"
|
||||
},
|
||||
"type": "commonjs",
|
||||
"bin": "lib/cjs/main-cli.js",
|
||||
"main": "./lib/cjs/main.js",
|
||||
"module": "./lib/esm/main.js",
|
||||
"exports": {
|
||||
"import": "./lib/esm/main.js",
|
||||
"require": "./lib/cjs/main.js"
|
||||
},
|
||||
"type": "module",
|
||||
"bin": "lib/main-cli.js",
|
||||
"main": "./lib/main.js",
|
||||
"module": "./lib/main.js",
|
||||
"wireit": {
|
||||
"build": {
|
||||
"command": "tsc -b && node --experimental-strip-types ../../tools/chmod.ts 755 lib/cjs/main-cli.js lib/esm/main-cli.js",
|
||||
"command": "tsc -b && node --experimental-strip-types ../../tools/chmod.ts 755 lib/main-cli.js",
|
||||
"files": [
|
||||
"src/**/*.ts",
|
||||
"tsconfig.json"
|
||||
],
|
||||
"clean": "if-file-deleted",
|
||||
"output": [
|
||||
"lib/**",
|
||||
"!lib/esm/package.json"
|
||||
],
|
||||
"dependencies": [
|
||||
"generate:package-json"
|
||||
]
|
||||
},
|
||||
"generate:package-json": {
|
||||
"command": "node --experimental-strip-types ../../tools/generate_module_package_json.ts lib/esm/package.json",
|
||||
"files": [
|
||||
"../../tools/generate_module_package_json.ts"
|
||||
],
|
||||
"output": [
|
||||
"lib/esm/package.json"
|
||||
]
|
||||
},
|
||||
"generate:package-json:test": {
|
||||
"command": "node --experimental-strip-types ../../tools/generate_module_package_json.ts test/build/package.json",
|
||||
"files": [
|
||||
"../../tools/generate_module_package_json.ts"
|
||||
],
|
||||
"output": [
|
||||
"test/build/package.json"
|
||||
"lib/**"
|
||||
]
|
||||
},
|
||||
"build:docs": {
|
||||
"command": "api-extractor run --local --config \"./api-extractor.docs.json\"",
|
||||
"files": [
|
||||
"api-extractor.docs.json",
|
||||
"lib/esm/main.d.ts",
|
||||
"lib/main.d.ts",
|
||||
"tsconfig.json"
|
||||
],
|
||||
"dependencies": [
|
||||
@@ -74,7 +48,6 @@
|
||||
],
|
||||
"dependencies": [
|
||||
"build",
|
||||
"generate:package-json:test",
|
||||
"../testserver:build"
|
||||
]
|
||||
},
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"extends": "../../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"outDir": "../lib/cjs"
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"extends": "../../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../lib/esm"
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
|
||||
import {CLI} from '../../lib/esm/CLI.js';
|
||||
import {CLI} from '../../lib/CLI.js';
|
||||
|
||||
import {
|
||||
createMockedReadlineInterface,
|
||||
|
||||
@@ -9,7 +9,7 @@ import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
|
||||
import {Browser, Cache} from '../../lib/esm/main.js';
|
||||
import {Browser, Cache} from '../../lib/main.js';
|
||||
|
||||
describe('Cache', () => {
|
||||
let tmpDir = '/tmp/puppeteer-browsers-test';
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
import assert from 'node:assert';
|
||||
import path from 'node:path';
|
||||
|
||||
import {BrowserPlatform} from '../../../lib/esm/browser-data/browser-data.js';
|
||||
import {BrowserPlatform} from '../../../lib/browser-data/browser-data.js';
|
||||
import {
|
||||
resolveDownloadUrl,
|
||||
relativeExecutablePath,
|
||||
resolveBuildId,
|
||||
} from '../../../lib/esm/browser-data/chrome-headless-shell.js';
|
||||
} from '../../../lib/browser-data/chrome-headless-shell.js';
|
||||
|
||||
describe('chrome-headless-shell', () => {
|
||||
it('should resolve download URLs', () => {
|
||||
|
||||
@@ -9,7 +9,7 @@ import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
|
||||
import {CLI} from '../../../lib/esm/CLI.js';
|
||||
import {CLI} from '../../../lib/CLI.js';
|
||||
import {
|
||||
createMockedReadlineInterface,
|
||||
setupTestServer,
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
Browser,
|
||||
BrowserPlatform,
|
||||
Cache,
|
||||
} from '../../../lib/esm/main.js';
|
||||
} from '../../../lib/main.js';
|
||||
import {getServerUrl, setupTestServer} from '../utils.js';
|
||||
import {testChromeDriverBuildId} from '../versions.js';
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import path from 'node:path';
|
||||
import {
|
||||
BrowserPlatform,
|
||||
ChromeReleaseChannel,
|
||||
} from '../../../lib/esm/browser-data/browser-data.js';
|
||||
} from '../../../lib/browser-data/browser-data.js';
|
||||
import {
|
||||
resolveDownloadUrl,
|
||||
relativeExecutablePath,
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
resolveBuildId,
|
||||
compareVersions,
|
||||
resolveDefaultUserDataDir,
|
||||
} from '../../../lib/esm/browser-data/chrome.js';
|
||||
} from '../../../lib/browser-data/chrome.js';
|
||||
|
||||
describe('Chrome', () => {
|
||||
it('should resolve download URLs', () => {
|
||||
|
||||
@@ -9,8 +9,8 @@ import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
|
||||
import * as chrome from '../../../lib/esm/browser-data/chrome.js';
|
||||
import {CLI} from '../../../lib/esm/CLI.js';
|
||||
import * as chrome from '../../../lib/browser-data/chrome.js';
|
||||
import {CLI} from '../../../lib/CLI.js';
|
||||
import {
|
||||
createMockedReadlineInterface,
|
||||
setupTestServer,
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
BrowserPlatform,
|
||||
Cache,
|
||||
computeExecutablePath,
|
||||
} from '../../../lib/esm/main.js';
|
||||
} from '../../../lib/main.js';
|
||||
import {getServerUrl, setupTestServer} from '../utils.js';
|
||||
import {testChromeBuildId} from '../versions.js';
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
install,
|
||||
Browser,
|
||||
BrowserPlatform,
|
||||
} from '../../../lib/esm/main.js';
|
||||
} from '../../../lib/main.js';
|
||||
import {getServerUrl, setupTestServer, clearCache} from '../utils.js';
|
||||
import {testChromeBuildId} from '../versions.js';
|
||||
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
import assert from 'node:assert';
|
||||
import path from 'node:path';
|
||||
|
||||
import {BrowserPlatform} from '../../../lib/esm/browser-data/browser-data.js';
|
||||
import {BrowserPlatform} from '../../../lib/browser-data/browser-data.js';
|
||||
import {
|
||||
resolveDownloadUrl,
|
||||
relativeExecutablePath,
|
||||
resolveBuildId,
|
||||
} from '../../../lib/esm/browser-data/chromedriver.js';
|
||||
} from '../../../lib/browser-data/chromedriver.js';
|
||||
|
||||
describe('ChromeDriver', () => {
|
||||
it('should resolve download URLs', () => {
|
||||
|
||||
@@ -9,7 +9,7 @@ import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
|
||||
import {CLI} from '../../../lib/esm/CLI.js';
|
||||
import {CLI} from '../../../lib/CLI.js';
|
||||
import {
|
||||
createMockedReadlineInterface,
|
||||
setupTestServer,
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
Browser,
|
||||
BrowserPlatform,
|
||||
Cache,
|
||||
} from '../../../lib/esm/main.js';
|
||||
} from '../../../lib/main.js';
|
||||
import {getServerUrl, setupTestServer} from '../utils.js';
|
||||
import {testChromeDriverBuildId} from '../versions.js';
|
||||
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
import assert from 'node:assert';
|
||||
import path from 'node:path';
|
||||
|
||||
import {BrowserPlatform} from '../../../lib/esm/browser-data/browser-data.js';
|
||||
import {BrowserPlatform} from '../../../lib/browser-data/browser-data.js';
|
||||
import {
|
||||
resolveDownloadUrl,
|
||||
relativeExecutablePath,
|
||||
compareVersions,
|
||||
} from '../../../lib/esm/browser-data/chromium.js';
|
||||
} from '../../../lib/browser-data/chromium.js';
|
||||
|
||||
describe('Chromium', () => {
|
||||
it('should resolve download URLs', () => {
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
install,
|
||||
Browser,
|
||||
BrowserPlatform,
|
||||
} from '../../../lib/esm/main.js';
|
||||
} from '../../../lib/main.js';
|
||||
import {getServerUrl, setupTestServer, clearCache} from '../utils.js';
|
||||
import {testChromiumBuildId} from '../versions.js';
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import path from 'node:path';
|
||||
import {
|
||||
internalConstantsForTesting,
|
||||
unpackArchive,
|
||||
} from '../../lib/esm/fileUtil.js';
|
||||
} from '../../lib/fileUtil.js';
|
||||
|
||||
describe('fileUtil', function () {
|
||||
let tmpDir = '/tmp/puppeteer-browsers-test';
|
||||
|
||||
@@ -11,8 +11,8 @@ import path from 'node:path';
|
||||
|
||||
import sinon from 'sinon';
|
||||
|
||||
import * as firefox from '../../../lib/esm/browser-data/firefox.js';
|
||||
import {CLI} from '../../../lib/esm/CLI.js';
|
||||
import * as firefox from '../../../lib/browser-data/firefox.js';
|
||||
import {CLI} from '../../../lib/CLI.js';
|
||||
import {
|
||||
createMockedReadlineInterface,
|
||||
getServerUrl,
|
||||
|
||||
@@ -9,13 +9,13 @@ import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
|
||||
import {BrowserPlatform} from '../../../lib/esm/browser-data/browser-data.js';
|
||||
import {BrowserPlatform} from '../../../lib/browser-data/browser-data.js';
|
||||
import {
|
||||
compareVersions,
|
||||
createProfile,
|
||||
relativeExecutablePath,
|
||||
resolveDownloadUrl,
|
||||
} from '../../../lib/esm/browser-data/firefox.js';
|
||||
} from '../../../lib/browser-data/firefox.js';
|
||||
|
||||
describe('Firefox', () => {
|
||||
it('should resolve download URLs for Nightly', () => {
|
||||
|
||||
@@ -9,7 +9,7 @@ import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
|
||||
import {install, Browser, BrowserPlatform} from '../../../lib/esm/main.js';
|
||||
import {install, Browser, BrowserPlatform} from '../../../lib/main.js';
|
||||
import {setupTestServer, getServerUrl, clearCache} from '../utils.js';
|
||||
import {testFirefoxBuildId} from '../versions.js';
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
Browser,
|
||||
BrowserPlatform,
|
||||
createProfile,
|
||||
} from '../../../lib/esm/main.js';
|
||||
} from '../../../lib/main.js';
|
||||
import {setupTestServer, getServerUrl, clearCache} from '../utils.js';
|
||||
import {testFirefoxBuildId} from '../versions.js';
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
install,
|
||||
type BrowserProvider,
|
||||
type DownloadOptions,
|
||||
} from '../../lib/esm/main.js';
|
||||
} from '../../lib/main.js';
|
||||
|
||||
import {getServerUrl, setupTestServer} from './utils.js';
|
||||
import {testChromeBuildId} from './versions.js';
|
||||
|
||||
@@ -9,7 +9,7 @@ import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
|
||||
import {CLI} from '../../lib/esm/CLI.js';
|
||||
import {CLI} from '../../lib/CLI.js';
|
||||
|
||||
import {
|
||||
createMockedReadlineInterface,
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
Browser,
|
||||
BrowserPlatform,
|
||||
Cache,
|
||||
} from '../../lib/esm/main.js';
|
||||
} from '../../lib/main.js';
|
||||
|
||||
import {getServerUrl, setupTestServer} from './utils.js';
|
||||
import {testChromeBuildId} from './versions.js';
|
||||
|
||||
@@ -12,8 +12,8 @@ import {Writable, Readable} from 'node:stream';
|
||||
|
||||
import {TestServer} from '@pptr/testserver';
|
||||
|
||||
import {isErrorLike} from '../../lib/esm/launch.js';
|
||||
import {Cache} from '../../lib/esm/main.js';
|
||||
import {isErrorLike} from '../../lib/launch.js';
|
||||
import {Cache} from '../../lib/main.js';
|
||||
|
||||
export function createMockedReadlineInterface(
|
||||
input: string,
|
||||
|
||||
@@ -14,7 +14,7 @@ import {normalize, join, dirname} from 'node:path';
|
||||
|
||||
import {BrowserPlatform, install} from '@puppeteer/browsers';
|
||||
|
||||
import {downloadPaths} from '../lib/esm/browser-data/browser-data.js';
|
||||
import {downloadPaths} from '../lib/browser-data/browser-data.js';
|
||||
import * as versions from '../test/build/versions.js';
|
||||
|
||||
function getBrowser(str) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"files": [],
|
||||
"references": [
|
||||
{"path": "./src/tsconfig.esm.json"},
|
||||
{"path": "./src/tsconfig.cjs.json"}
|
||||
]
|
||||
"compilerOptions": {
|
||||
"outDir": "lib",
|
||||
"rootDir": "src"
|
||||
},
|
||||
"include": ["src/**/*"]
|
||||
}
|
||||
|
||||
@@ -1,15 +1,5 @@
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
|
||||
|
||||
"extends": ["@microsoft/api-extractor/extends/tsdoc-base.json"],
|
||||
"tagDefinitions": [
|
||||
{
|
||||
"tagName": "@license",
|
||||
"syntaxKind": "modifier",
|
||||
"allowMultiple": false
|
||||
}
|
||||
],
|
||||
"supportForTags": {
|
||||
"@license": true
|
||||
}
|
||||
"extends": ["../../tsdoc.json"]
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ export function getCommandForRunner(runner: TestRunner): [string, ...string[]] {
|
||||
case TestRunner.Jest:
|
||||
return [`jest`, '-c', 'e2e/jest.config.js'];
|
||||
case TestRunner.Mocha:
|
||||
return [`mocha`, '--config=./e2e/.mocharc.js'];
|
||||
return [`mocha`, '--config=./e2e/.mocharc.cjs'];
|
||||
case TestRunner.Node:
|
||||
return [
|
||||
'node',
|
||||
|
||||
@@ -84,7 +84,7 @@ void describe('@puppeteer/ng-schematics: ng-add', () => {
|
||||
const {devDependencies} = getPackageJson(tree);
|
||||
const {options} = getAngularJsonScripts(tree);
|
||||
|
||||
expect(tree.files).toContain('/e2e/.mocharc.js');
|
||||
expect(tree.files).toContain('/e2e/.mocharc.cjs');
|
||||
expect(devDependencies).toContain('mocha');
|
||||
expect(devDependencies).toContain('@types/mocha');
|
||||
expect(options['testRunner']).toBe('mocha');
|
||||
@@ -194,7 +194,7 @@ void describe('@puppeteer/ng-schematics: ng-add', () => {
|
||||
const {devDependencies} = getPackageJson(tree);
|
||||
const {options} = getAngularJsonScripts(tree);
|
||||
|
||||
expect(tree.files).toContain(getMultiApplicationFile('e2e/.mocharc.js'));
|
||||
expect(tree.files).toContain(getMultiApplicationFile('e2e/.mocharc.cjs'));
|
||||
expect(devDependencies).toContain('mocha');
|
||||
expect(devDependencies).toContain('@types/mocha');
|
||||
expect(options['testRunner']).toBe('mocha');
|
||||
|
||||
@@ -115,6 +115,7 @@ class AngularProject {
|
||||
...packageJson['scripts'],
|
||||
...AngularProject.#scripts(this.#runner),
|
||||
};
|
||||
packageJson['devDependencies']['puppeteer'] = '../../../puppeteer';
|
||||
await writeFile(packageJsonFile, JSON.stringify(packageJson, null, 2));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,5 @@
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
|
||||
|
||||
"extends": ["@microsoft/api-extractor/extends/tsdoc-base.json"],
|
||||
"tagDefinitions": [
|
||||
{
|
||||
"tagName": "@license",
|
||||
"syntaxKind": "modifier",
|
||||
"allowMultiple": false
|
||||
}
|
||||
],
|
||||
"supportForTags": {
|
||||
"@license": true
|
||||
}
|
||||
"extends": ["../../tsdoc.json"]
|
||||
}
|
||||
|
||||
@@ -61,21 +61,9 @@ export const generateInjectedTask = task({
|
||||
},
|
||||
});
|
||||
|
||||
export const generatePackageJsonTask = task({
|
||||
name: 'generate:package-json',
|
||||
run: async () => {
|
||||
await mkdir('lib/esm', {recursive: true});
|
||||
await writeFile('lib/esm/package.json', JSON.stringify({type: 'module'}));
|
||||
},
|
||||
});
|
||||
|
||||
export const generateTask = task({
|
||||
name: 'generate',
|
||||
dependencies: [
|
||||
generateInjectedTask,
|
||||
generatePackageJsonTask,
|
||||
updateVersionTask,
|
||||
],
|
||||
dependencies: [generateInjectedTask, updateVersionTask],
|
||||
});
|
||||
|
||||
export const buildTscTask = task({
|
||||
@@ -90,7 +78,6 @@ export const buildTask = task({
|
||||
name: 'build',
|
||||
dependencies: [buildTscTask],
|
||||
run: async () => {
|
||||
const formats = ['esm', 'cjs'];
|
||||
const packages = (await readdir('third_party', {withFileTypes: true}))
|
||||
.filter(dirent => {
|
||||
return dirent.isDirectory();
|
||||
@@ -99,75 +86,73 @@ export const buildTask = task({
|
||||
return name;
|
||||
});
|
||||
const builders = [];
|
||||
for (const format of formats) {
|
||||
const folder = posixPath.join('lib', format, 'third_party');
|
||||
for (const name of packages) {
|
||||
const entrypoint = posixPath.join(folder, name, `${name}.js`);
|
||||
builders.push(
|
||||
await esbuild.build({
|
||||
entryPoints: [entrypoint],
|
||||
outfile: entrypoint,
|
||||
bundle: true,
|
||||
allowOverwrite: true,
|
||||
format,
|
||||
target: 'node18',
|
||||
// Do not minify for readability and leave minification to
|
||||
// consumers.
|
||||
minify: false,
|
||||
legalComments: 'inline',
|
||||
}),
|
||||
);
|
||||
let license = '';
|
||||
switch (name) {
|
||||
case 'rxjs':
|
||||
license = await readFile(
|
||||
path.join(
|
||||
path.dirname(require.resolve('rxjs')),
|
||||
'..',
|
||||
'..',
|
||||
'LICENSE.txt',
|
||||
),
|
||||
'utf-8',
|
||||
);
|
||||
break;
|
||||
case 'mitt':
|
||||
license = await readFile(
|
||||
path.join(path.dirname(require.resolve('mitt')), '..', 'LICENSE'),
|
||||
'utf-8',
|
||||
);
|
||||
break;
|
||||
case 'parsel-js':
|
||||
license = await readFile(
|
||||
path.join(
|
||||
path.dirname(require.resolve('parsel-js')),
|
||||
'..',
|
||||
'LICENSE',
|
||||
),
|
||||
'utf-8',
|
||||
);
|
||||
break;
|
||||
case 'urlpattern-polyfill':
|
||||
license = await readFile(
|
||||
path.join(
|
||||
path.dirname(require.resolve('urlpattern-polyfill')),
|
||||
'LICENSE',
|
||||
),
|
||||
'utf-8',
|
||||
);
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Add license handling for ${path}`);
|
||||
}
|
||||
const content = await readFile(entrypoint, 'utf-8');
|
||||
await writeFile(
|
||||
entrypoint,
|
||||
`/**
|
||||
const folder = posixPath.join('lib', 'third_party');
|
||||
for (const name of packages) {
|
||||
const entrypoint = posixPath.join(folder, name, `${name}.js`);
|
||||
builders.push(
|
||||
await esbuild.build({
|
||||
entryPoints: [entrypoint],
|
||||
outfile: entrypoint,
|
||||
bundle: true,
|
||||
allowOverwrite: true,
|
||||
format: 'esm',
|
||||
target: 'node20',
|
||||
// Do not minify for readability and leave minification to
|
||||
// consumers.
|
||||
minify: false,
|
||||
legalComments: 'inline',
|
||||
}),
|
||||
);
|
||||
let license = '';
|
||||
switch (name) {
|
||||
case 'rxjs':
|
||||
license = await readFile(
|
||||
path.join(
|
||||
path.dirname(require.resolve('rxjs')),
|
||||
'..',
|
||||
'..',
|
||||
'LICENSE.txt',
|
||||
),
|
||||
'utf-8',
|
||||
);
|
||||
break;
|
||||
case 'mitt':
|
||||
license = await readFile(
|
||||
path.join(path.dirname(require.resolve('mitt')), '..', 'LICENSE'),
|
||||
'utf-8',
|
||||
);
|
||||
break;
|
||||
case 'parsel-js':
|
||||
license = await readFile(
|
||||
path.join(
|
||||
path.dirname(require.resolve('parsel-js')),
|
||||
'..',
|
||||
'LICENSE',
|
||||
),
|
||||
'utf-8',
|
||||
);
|
||||
break;
|
||||
case 'urlpattern-polyfill':
|
||||
license = await readFile(
|
||||
path.join(
|
||||
path.dirname(require.resolve('urlpattern-polyfill')),
|
||||
'LICENSE',
|
||||
),
|
||||
'utf-8',
|
||||
);
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Add license handling for ${path}`);
|
||||
}
|
||||
const content = await readFile(entrypoint, 'utf-8');
|
||||
await writeFile(
|
||||
entrypoint,
|
||||
`/**
|
||||
${license}
|
||||
*/
|
||||
${content}`,
|
||||
'utf-8',
|
||||
);
|
||||
}
|
||||
'utf-8',
|
||||
);
|
||||
}
|
||||
await Promise.all(builders);
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
||||
"mainEntryPointFilePath": "<projectFolder>/lib/esm/puppeteer/puppeteer-core.d.ts",
|
||||
"mainEntryPointFilePath": "<projectFolder>/lib/puppeteer/puppeteer-core.d.ts",
|
||||
|
||||
"extends": "./api-extractor.json",
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
||||
"mainEntryPointFilePath": "<projectFolder>/lib/esm/puppeteer/puppeteer-core.d.ts",
|
||||
"mainEntryPointFilePath": "<projectFolder>/lib/puppeteer/puppeteer-core.d.ts",
|
||||
"bundledPackages": [],
|
||||
|
||||
"apiReport": {
|
||||
|
||||
@@ -8,20 +8,20 @@
|
||||
"headless",
|
||||
"automation"
|
||||
],
|
||||
"type": "commonjs",
|
||||
"main": "./lib/cjs/puppeteer/puppeteer-core.js",
|
||||
"browser": "./lib/esm/puppeteer/puppeteer-core-browser.js",
|
||||
"module": "./lib/esm/puppeteer/puppeteer-core.js",
|
||||
"type": "module",
|
||||
"main": "./lib/puppeteer/puppeteer-core.js",
|
||||
"browser": "./lib/puppeteer/puppeteer-core-browser.js",
|
||||
"module": "./lib/puppeteer/puppeteer-core.js",
|
||||
"types": "./lib/types.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./lib/types.d.ts",
|
||||
"import": "./lib/esm/puppeteer/puppeteer-core.js",
|
||||
"require": "./lib/cjs/puppeteer/puppeteer-core.js"
|
||||
"import": "./lib/puppeteer/puppeteer-core.js",
|
||||
"require": "./lib/puppeteer/puppeteer-core.js"
|
||||
},
|
||||
"./internal/*": {
|
||||
"import": "./lib/esm/puppeteer/*",
|
||||
"require": "./lib/cjs/puppeteer/*"
|
||||
"import": "./lib/puppeteer/*",
|
||||
"require": "./lib/puppeteer/*"
|
||||
},
|
||||
"./*": {
|
||||
"import": "./*",
|
||||
@@ -71,7 +71,7 @@
|
||||
"command": "api-extractor run --local --config \"./api-extractor.docs.json\"",
|
||||
"files": [
|
||||
"api-extractor.docs.json",
|
||||
"lib/esm/puppeteer/puppeteer-core.d.ts",
|
||||
"lib/puppeteer/puppeteer-core.d.ts",
|
||||
"tsconfig.json"
|
||||
],
|
||||
"dependencies": [
|
||||
@@ -91,7 +91,7 @@
|
||||
"Herebyfile.mjs"
|
||||
],
|
||||
"output": [
|
||||
"lib/{cjs,esm}/**"
|
||||
"lib/**"
|
||||
]
|
||||
},
|
||||
"build:es5": {
|
||||
@@ -111,7 +111,7 @@
|
||||
"command": "api-extractor run --local && eslint --fix lib/types.d.ts --no-ignore",
|
||||
"files": [
|
||||
"api-extractor.json",
|
||||
"lib/esm/puppeteer/types.d.ts",
|
||||
"lib/puppeteer/types.d.ts",
|
||||
"tsconfig.json"
|
||||
],
|
||||
"output": [
|
||||
@@ -122,13 +122,13 @@
|
||||
]
|
||||
},
|
||||
"unit": {
|
||||
"command": "node --test --test-reporter=spec \"lib/cjs/**/*.test.js\"",
|
||||
"command": "node --test --test-reporter=spec \"lib/**/*.test.js\"",
|
||||
"dependencies": [
|
||||
"build"
|
||||
]
|
||||
},
|
||||
"unit:only": {
|
||||
"command": "node --test --test-only --test-reporter=spec \"lib/cjs/**/*.test.js\"",
|
||||
"command": "node --test --test-only --test-reporter=spec \"lib/**/*.test.js\"",
|
||||
"dependencies": [
|
||||
"build"
|
||||
]
|
||||
|
||||
@@ -11,7 +11,7 @@ import {nodeResolve} from '@rollup/plugin-node-resolve';
|
||||
const cwd = process.cwd();
|
||||
|
||||
export default {
|
||||
input: 'lib/esm/puppeteer/puppeteer-core-browser.js',
|
||||
input: 'lib/puppeteer/puppeteer-core-browser.js',
|
||||
output: {
|
||||
format: 'iife',
|
||||
file: 'lib/es5-iife/puppeteer-core-browser.js',
|
||||
@@ -30,10 +30,10 @@ export default {
|
||||
if (id.includes('@puppeteer/browsers')) {
|
||||
return true;
|
||||
}
|
||||
if (id.startsWith(path.join(cwd, `lib`, `esm`, `puppeteer`, `bidi`))) {
|
||||
if (id.startsWith(path.join(cwd, `lib`, `puppeteer`, `bidi`))) {
|
||||
return true;
|
||||
}
|
||||
if (id.startsWith(path.join(cwd, `lib`, `esm`, `puppeteer`, `node`))) {
|
||||
if (id.startsWith(path.join(cwd, `lib`, `puppeteer`, `node`))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -46,7 +46,10 @@ export interface WebMCPAnnotation {
|
||||
*/
|
||||
export type WebMCPInvocationStatus = 'Completed' | 'Canceled' | 'Error';
|
||||
|
||||
interface ProtocolWebMCPTool {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export interface ProtocolWebMCPTool {
|
||||
name: string;
|
||||
description: string;
|
||||
inputSchema?: object;
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"extends": "../../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"module": "CommonJS",
|
||||
"moduleResolution": "Node",
|
||||
"outDir": "../lib/cjs/puppeteer"
|
||||
},
|
||||
"references": [{"path": "../third_party/tsconfig.cjs.json"}]
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"extends": "../../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../lib/esm/puppeteer"
|
||||
},
|
||||
"references": [{"path": "../third_party/tsconfig.json"}]
|
||||
}
|
||||
@@ -37,7 +37,7 @@ describe('Function', function () {
|
||||
describe('stringifyFunction', () => {
|
||||
it('should work', async () => {
|
||||
// @ts-expect-error no types
|
||||
const {variations} = await import('../../../../function-fixture.mjs');
|
||||
const {variations} = await import('../../../function-fixture.mjs');
|
||||
for (const v of variations) {
|
||||
const fnStr = stringifyFunction(v);
|
||||
try {
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"extends": "../../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"outDir": "../lib/cjs/third_party",
|
||||
"declarationMap": false,
|
||||
"sourceMap": false
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
"extends": "../../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"declarationMap": false,
|
||||
"outDir": "../lib/esm/third_party",
|
||||
"outDir": "../lib/third_party",
|
||||
"sourceMap": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
import {execSync} from 'child_process';
|
||||
|
||||
import packageJson from '../package.json' with {type: 'json'};
|
||||
import {PUPPETEER_REVISIONS} from '../lib/esm/puppeteer/revisions.js';
|
||||
import {PUPPETEER_REVISIONS} from '../lib/puppeteer/revisions.js';
|
||||
|
||||
async function main() {
|
||||
const currentProtocolPackageInstalledVersion =
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"files": [],
|
||||
"references": [
|
||||
{"path": "./src/tsconfig.esm.json"},
|
||||
{"path": "./src/tsconfig.cjs.json"}
|
||||
]
|
||||
"compilerOptions": {
|
||||
"outDir": "./lib/puppeteer",
|
||||
"rootDir": "./src"
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"references": [{"path": "./third_party/tsconfig.json"}]
|
||||
}
|
||||
|
||||
@@ -1,15 +1,5 @@
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
|
||||
|
||||
"extends": ["@microsoft/api-extractor/extends/tsdoc-base.json"],
|
||||
"tagDefinitions": [
|
||||
{
|
||||
"tagName": "@license",
|
||||
"syntaxKind": "modifier",
|
||||
"allowMultiple": false
|
||||
}
|
||||
],
|
||||
"supportForTags": {
|
||||
"@license": true
|
||||
}
|
||||
"extends": ["../../tsdoc.json"]
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
||||
"mainEntryPointFilePath": "<projectFolder>/lib/esm/puppeteer/puppeteer.docs.d.ts",
|
||||
"mainEntryPointFilePath": "<projectFolder>/lib/puppeteer/puppeteer.docs.d.ts",
|
||||
"bundledPackages": ["puppeteer-core"],
|
||||
|
||||
"extends": "./api-extractor.json",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
||||
"mainEntryPointFilePath": "<projectFolder>/lib/esm/puppeteer/puppeteer.d.ts",
|
||||
"mainEntryPointFilePath": "<projectFolder>/lib/puppeteer/puppeteer.d.ts",
|
||||
"bundledPackages": [],
|
||||
|
||||
"apiReport": {
|
||||
|
||||
@@ -8,20 +8,20 @@
|
||||
"headless",
|
||||
"automation"
|
||||
],
|
||||
"type": "commonjs",
|
||||
"bin": "./lib/cjs/puppeteer/node/cli.js",
|
||||
"main": "./lib/cjs/puppeteer/puppeteer.js",
|
||||
"module": "./lib/esm/puppeteer/puppeteer.js",
|
||||
"type": "module",
|
||||
"bin": "./lib/puppeteer/node/cli.js",
|
||||
"main": "./lib/puppeteer/puppeteer.js",
|
||||
"module": "./lib/puppeteer/puppeteer.js",
|
||||
"types": "./lib/types.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./lib/types.d.ts",
|
||||
"import": "./lib/esm/puppeteer/puppeteer.js",
|
||||
"require": "./lib/cjs/puppeteer/puppeteer.js"
|
||||
"import": "./lib/puppeteer/puppeteer.js",
|
||||
"require": "./lib/puppeteer/puppeteer.js"
|
||||
},
|
||||
"./internal/*": {
|
||||
"import": "./lib/esm/puppeteer/*",
|
||||
"require": "./lib/cjs/puppeteer/*"
|
||||
"import": "./lib/puppeteer/*",
|
||||
"require": "./lib/puppeteer/*"
|
||||
},
|
||||
"./*": {
|
||||
"import": "./*",
|
||||
@@ -55,27 +55,14 @@
|
||||
"build": {
|
||||
"dependencies": [
|
||||
"build:tsc",
|
||||
"build:types",
|
||||
"generate:package-json"
|
||||
]
|
||||
},
|
||||
"generate:package-json": {
|
||||
"command": "node --experimental-strip-types ../../tools/generate_module_package_json.ts lib/esm/package.json",
|
||||
"files": [
|
||||
"../../tools/generate_module_package_json.ts"
|
||||
],
|
||||
"dependencies": [
|
||||
"build:tsc"
|
||||
],
|
||||
"output": [
|
||||
"lib/esm/package.json"
|
||||
"build:types"
|
||||
]
|
||||
},
|
||||
"build:docs": {
|
||||
"command": "api-extractor run --local --config \"./api-extractor.docs.json\"",
|
||||
"files": [
|
||||
"api-extractor.docs.json",
|
||||
"lib/esm/puppeteer/puppeteer.docs.d.ts",
|
||||
"lib/puppeteer/puppeteer.docs.d.ts",
|
||||
"tsconfig.json"
|
||||
],
|
||||
"dependencies": [
|
||||
@@ -83,7 +70,7 @@
|
||||
]
|
||||
},
|
||||
"build:tsc": {
|
||||
"command": "tsc -b && node --experimental-strip-types ../../tools/chmod.ts 755 lib/cjs/puppeteer/node/cli.js lib/esm/puppeteer/node/cli.js",
|
||||
"command": "tsc -b && node --experimental-strip-types ../../tools/chmod.ts 755 lib/puppeteer/node/cli.js",
|
||||
"clean": "if-file-deleted",
|
||||
"dependencies": [
|
||||
"../puppeteer-core:build",
|
||||
@@ -93,15 +80,15 @@
|
||||
"src/**"
|
||||
],
|
||||
"output": [
|
||||
"lib/{cjs,esm}/**",
|
||||
"!lib/esm/package.json"
|
||||
"lib/**",
|
||||
"!lib/package.json"
|
||||
]
|
||||
},
|
||||
"build:types": {
|
||||
"command": "api-extractor run --local && eslint --fix lib/types.d.ts --no-ignore",
|
||||
"files": [
|
||||
"api-extractor.json",
|
||||
"lib/esm/puppeteer/types.d.ts",
|
||||
"lib/puppeteer/types.d.ts",
|
||||
"tsconfig.json"
|
||||
],
|
||||
"output": [
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"extends": "../../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"outDir": "../lib/cjs/puppeteer"
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"extends": "../../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../lib/esm/puppeteer"
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,15 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"files": [],
|
||||
"compilerOptions": {
|
||||
"outDir": "./lib/puppeteer",
|
||||
"rootDir": "./src",
|
||||
|
||||
// API extractor doesn't work well with NodeNext module resolution, so we
|
||||
// just stick with ol'fashion path resolution.
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"puppeteer-core/internal/*": ["../puppeteer-core/lib/esm/puppeteer/*"]
|
||||
"puppeteer-core/internal/*": ["../puppeteer-core/lib/puppeteer/*"]
|
||||
}
|
||||
},
|
||||
"references": [
|
||||
{"path": "./src/tsconfig.esm.json"},
|
||||
{"path": "./src/tsconfig.cjs.json"}
|
||||
]
|
||||
"include": ["src/**/*"]
|
||||
}
|
||||
|
||||
@@ -1,15 +1,5 @@
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
|
||||
|
||||
"extends": ["@microsoft/api-extractor/extends/tsdoc-base.json"],
|
||||
"tagDefinitions": [
|
||||
{
|
||||
"tagName": "@license",
|
||||
"syntaxKind": "modifier",
|
||||
"allowMultiple": false
|
||||
}
|
||||
],
|
||||
"supportForTags": {
|
||||
"@license": true
|
||||
}
|
||||
"extends": ["../../tsdoc.json"]
|
||||
}
|
||||
|
||||
@@ -1,15 +1,5 @@
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
|
||||
|
||||
"extends": ["@microsoft/api-extractor/extends/tsdoc-base.json"],
|
||||
"tagDefinitions": [
|
||||
{
|
||||
"tagName": "@license",
|
||||
"syntaxKind": "modifier",
|
||||
"allowMultiple": false
|
||||
}
|
||||
],
|
||||
"supportForTags": {
|
||||
"@license": true
|
||||
}
|
||||
"extends": ["../../tsdoc.json"]
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/**
|
||||
* @type {import('prettier').Config}
|
||||
*/
|
||||
module.exports = {
|
||||
export default {
|
||||
bracketSpacing: false,
|
||||
singleQuote: true,
|
||||
trailingComma: 'all',
|
||||
@@ -7,7 +7,7 @@
|
||||
/**
|
||||
* @type {import("puppeteer").Configuration}
|
||||
*/
|
||||
module.exports = {
|
||||
export default {
|
||||
chrome: {
|
||||
skipDownload: false,
|
||||
},
|
||||
@@ -6,5 +6,5 @@
|
||||
|
||||
import 'puppeteer-core';
|
||||
import 'puppeteer-core/internal/revisions.js';
|
||||
import 'puppeteer-core/lib/esm/puppeteer/revisions.js';
|
||||
import 'puppeteer-core/lib/esm/puppeteer/bidi/BidiOverCdp.js';
|
||||
import 'puppeteer-core/lib/puppeteer/revisions.js';
|
||||
import 'puppeteer-core/lib/puppeteer/bidi/BidiOverCdp.js';
|
||||
|
||||
@@ -6,4 +6,4 @@
|
||||
|
||||
import 'puppeteer-core';
|
||||
import 'puppeteer-core/internal/revisions.js';
|
||||
import 'puppeteer-core/lib/esm/puppeteer/revisions.js';
|
||||
import 'puppeteer-core/lib/puppeteer/revisions.js';
|
||||
|
||||
@@ -6,5 +6,5 @@
|
||||
|
||||
require('puppeteer-core');
|
||||
require('puppeteer-core/internal/revisions.js');
|
||||
require('puppeteer-core/lib/esm/puppeteer/revisions.js');
|
||||
require('puppeteer-core/lib/esm/puppeteer/bidi/BidiOverCdp.js');
|
||||
require('puppeteer-core/lib/puppeteer/revisions.js');
|
||||
require('puppeteer-core/lib/puppeteer/bidi/BidiOverCdp.js');
|
||||
|
||||
@@ -6,4 +6,4 @@
|
||||
|
||||
require('puppeteer-core');
|
||||
require('puppeteer-core/internal/revisions.js');
|
||||
require('puppeteer-core/lib/esm/puppeteer/revisions.js');
|
||||
require('puppeteer-core/lib/puppeteer/revisions.js');
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
const puppeteer = require('puppeteer');
|
||||
(async () => {
|
||||
const browser = await puppeteer.launch();
|
||||
const page = await browser.newPage();
|
||||
await page.goto('http://example.com');
|
||||
await page.$('aria/example');
|
||||
await page.screenshot({path: 'example.png'});
|
||||
await browser.close();
|
||||
})();
|
||||
@@ -17,7 +17,7 @@ import {execFile, readAsset} from './util.js';
|
||||
() => {
|
||||
configureSandbox({
|
||||
dependencies: ['@puppeteer/browsers', 'puppeteer-core', 'puppeteer'],
|
||||
devDependencies: ['typescript@4.7.4', '@types/node@18.17.15'],
|
||||
devDependencies: ['typescript@5.0.2', '@types/node@20.19.23'],
|
||||
env: cwd => {
|
||||
return {
|
||||
PUPPETEER_CACHE_DIR: join(cwd, '.cache', 'puppeteer'),
|
||||
@@ -25,7 +25,27 @@ import {execFile, readAsset} from './util.js';
|
||||
},
|
||||
});
|
||||
|
||||
it('should work', async function () {
|
||||
it('should work with ESM', async function () {
|
||||
// Write a Webpack configuration.
|
||||
await writeFile(
|
||||
join(this.sandbox, 'tsconfig.json'),
|
||||
await readAsset('puppeteer', 'tsconfig.json'),
|
||||
);
|
||||
|
||||
// Write the source code.
|
||||
await writeFile(
|
||||
join(this.sandbox, 'index.mts'),
|
||||
await readAsset('puppeteer', 'basic.ts'),
|
||||
);
|
||||
|
||||
// Compile.
|
||||
await execFile('npx', ['tsc'], {cwd: this.sandbox, shell: true});
|
||||
|
||||
const script = await readFile(join(this.sandbox, 'index.mjs'), 'utf-8');
|
||||
|
||||
await this.runScript(script, 'mjs');
|
||||
});
|
||||
it('should work with CJS', async function () {
|
||||
// Write a Webpack configuration.
|
||||
await writeFile(
|
||||
join(this.sandbox, 'tsconfig.json'),
|
||||
@@ -35,7 +55,7 @@ import {execFile, readAsset} from './util.js';
|
||||
// Write the source code.
|
||||
await writeFile(
|
||||
join(this.sandbox, 'index.ts'),
|
||||
await readAsset('puppeteer', 'basic.ts'),
|
||||
await readAsset('puppeteer', 'basic-cjs.ts'),
|
||||
);
|
||||
|
||||
// Compile.
|
||||
|
||||
@@ -1,15 +1,5 @@
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
|
||||
|
||||
"extends": ["@microsoft/api-extractor/extends/tsdoc-base.json"],
|
||||
"tagDefinitions": [
|
||||
{
|
||||
"tagName": "@license",
|
||||
"syntaxKind": "modifier",
|
||||
"allowMultiple": false
|
||||
}
|
||||
],
|
||||
"supportForTags": {
|
||||
"@license": true
|
||||
}
|
||||
"extends": ["../../tsdoc.json"]
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ describe('acceptInsecureCerts', async () => {
|
||||
it('should work with mixed content', async () => {
|
||||
const {server, httpsServer, page} = state;
|
||||
|
||||
httpsServer.setRoute('/mixedcontent.html', (_req, res) => {
|
||||
httpsServer.setRoute('/mixedcontent.html', (_req: any, res: any) => {
|
||||
res.end(`<iframe src=${server.EMPTY_PAGE}></iframe>`);
|
||||
});
|
||||
await page.goto(httpsServer.PREFIX + '/mixedcontent.html', {
|
||||
|
||||
@@ -415,7 +415,6 @@ export const mochaHooks: Mocha.RootHookObject = {
|
||||
'packages',
|
||||
'puppeteer',
|
||||
'lib',
|
||||
'esm',
|
||||
'puppeteer',
|
||||
'puppeteer.js',
|
||||
),
|
||||
|
||||
+1
-11
@@ -1,15 +1,5 @@
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
|
||||
|
||||
"extends": ["@microsoft/api-extractor/extends/tsdoc-base.json"],
|
||||
"tagDefinitions": [
|
||||
{
|
||||
"tagName": "@license",
|
||||
"syntaxKind": "modifier",
|
||||
"allowMultiple": false
|
||||
}
|
||||
],
|
||||
"supportForTags": {
|
||||
"@license": true
|
||||
}
|
||||
"extends": ["../tsdoc.json"]
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import prettier from '@prettier/sync';
|
||||
import {ESLintUtils} from '@typescript-eslint/utils';
|
||||
|
||||
const prettierConfigFile = prettier.resolveConfigFile(
|
||||
'../../../.prettierrc.cjs',
|
||||
'../../../prettier.config.js',
|
||||
);
|
||||
const prettierConfig = prettier.resolveConfig(prettierConfigFile ?? '');
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2022 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import {mkdirSync, writeFileSync} from 'node:fs';
|
||||
import {dirname} from 'node:path';
|
||||
|
||||
/**
|
||||
* Outputs the dummy package.json file to the path specified
|
||||
* by the first argument.
|
||||
*/
|
||||
mkdirSync(dirname(process.argv[2]), {recursive: true});
|
||||
writeFileSync(process.argv[2], `{"type": "module"}`);
|
||||
@@ -231,6 +231,7 @@ async function main() {
|
||||
} else {
|
||||
args.push(...specs);
|
||||
}
|
||||
|
||||
const mochaCommand = [
|
||||
...(useCoverage
|
||||
? ['c8', '--check-coverage', '--lines', '90', 'npx']
|
||||
@@ -239,6 +240,7 @@ async function main() {
|
||||
...mochaArgs.map(String),
|
||||
...args,
|
||||
];
|
||||
|
||||
const handle = spawn('npx', mochaCommand, {
|
||||
shell: true,
|
||||
cwd: process.cwd(),
|
||||
|
||||
@@ -1,15 +1,5 @@
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
|
||||
|
||||
"extends": ["@microsoft/api-extractor/extends/tsdoc-base.json"],
|
||||
"tagDefinitions": [
|
||||
{
|
||||
"tagName": "@license",
|
||||
"syntaxKind": "modifier",
|
||||
"allowMultiple": false
|
||||
}
|
||||
],
|
||||
"supportForTags": {
|
||||
"@license": true
|
||||
}
|
||||
"extends": ["../tsdoc.json"]
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ function testIdMatchesExpectationPattern(title, pattern) {
|
||||
}
|
||||
|
||||
const prettierConfig = await import(
|
||||
path.join(import.meta.dirname, '..', '.prettierrc.cjs')
|
||||
path.join(import.meta.dirname, '..', 'prettier.config.js')
|
||||
);
|
||||
|
||||
function getSpecificity(item) {
|
||||
|
||||
+1
-11
@@ -1,15 +1,5 @@
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
|
||||
|
||||
"extends": ["@microsoft/api-extractor/extends/tsdoc-base.json"],
|
||||
"tagDefinitions": [
|
||||
{
|
||||
"tagName": "@license",
|
||||
"syntaxKind": "modifier",
|
||||
"allowMultiple": false
|
||||
}
|
||||
],
|
||||
"supportForTags": {
|
||||
"@license": true
|
||||
}
|
||||
"extends": ["../tsdoc.json"]
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
"tagDefinitions": [
|
||||
{
|
||||
"tagName": "@license",
|
||||
"syntaxKind": "modifier",
|
||||
"syntaxKind": "block",
|
||||
"allowMultiple": false
|
||||
}
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user