From bb1795de7656b38253be7ac2d29e2422200a87d6 Mon Sep 17 00:00:00 2001 From: AlphaX Date: Wed, 24 Sep 2025 11:07:27 +0000 Subject: [PATCH 1/2] chore: replace tsup with esbuild for builds --- package.json | 20 +- pnpm-lock.yaml | 386 +------------------------------------ scripts/build-cli.mjs | 82 ++++++++ scripts/build-e2e.mjs | 147 ++++++++++++++ scripts/build-lib.mjs | 40 ++++ scripts/run-playwright.mjs | 23 +++ tsconfig.build.json | 21 ++ 7 files changed, 326 insertions(+), 393 deletions(-) create mode 100644 scripts/build-cli.mjs create mode 100644 scripts/build-e2e.mjs create mode 100644 scripts/build-lib.mjs create mode 100644 scripts/run-playwright.mjs create mode 100644 tsconfig.build.json diff --git a/package.json b/package.json index 226b708a3..16468a5e9 100644 --- a/package.json +++ b/package.json @@ -18,19 +18,19 @@ "docs": "pnpm --filter @browserbasehq/stagehand-docs run dev", "evals": "tsx scripts/run-evals.ts", "evals:legacy": "tsx scripts/run-evals.ts", - "e2e": "pnpm run build && cd evals/deterministic && playwright test --config=e2e.playwright.config.ts", - "e2e:bb": "pnpm run build && cd evals/deterministic && playwright test --config=bb.playwright.config.ts", - "e2e:local": "pnpm run build && cd evals/deterministic && playwright test --config=local.playwright.config.ts", + "e2e": "pnpm run build && node scripts/build-e2e.mjs && node scripts/run-playwright.mjs --config=dist/playwright/evals/deterministic/e2e.playwright.config.js", + "e2e:bb": "pnpm run build && node scripts/build-e2e.mjs && node scripts/run-playwright.mjs --config=dist/playwright/evals/deterministic/bb.playwright.config.js", + "e2e:local": "pnpm run build && node scripts/build-e2e.mjs && node scripts/run-playwright.mjs --config=dist/playwright/evals/deterministic/local.playwright.config.js", "build-dom-scripts": "tsx lib/dom/genDomScripts.ts", - "build-types": "tsc --emitDeclarationOnly --outDir dist", - "build-js": "tsup lib/index.ts --dts", - "build:cli": "tsup evals/cli.ts --outDir dist/evals --format cjs && cp evals/evals.config.json dist/evals/ && chmod +x dist/evals/cli.js && npm link", - "build": "pnpm run lint && pnpm run gen-version && pnpm run build-dom-scripts && pnpm run build-js && pnpm run build-types", + "build-types": "tsc --project tsconfig.build.json", + "build:cli": "node scripts/build-cli.mjs", + "build": "pnpm run lint && pnpm run gen-version && pnpm run build-dom-scripts && pnpm run build:lib && pnpm run build-types", "gen-version": "tsx scripts/gen-version.ts", "prepare": "pnpm run build", "lint": "pnpm run prettier:fix && pnpm run eslint", "release": "pnpm run build && changeset publish", - "release-canary": "pnpm run build && changeset version --snapshot && changeset publish --tag alpha" + "release-canary": "pnpm run build && changeset version --snapshot && changeset publish --tag alpha", + "build:lib": "node scripts/build-lib.mjs" }, "files": [ "dist/**" @@ -63,7 +63,6 @@ "multer": "^1.4.5-lts.1", "prettier": "^3.2.5", "string-comparison": "^1.3.0", - "tsup": "^8.2.1", "tsx": "^4.10.5", "typescript": "^5.2.2", "typescript-eslint": "^8.17.0" @@ -86,7 +85,8 @@ "pino-pretty": "^13.0.0", "playwright": "^1.52.0", "ws": "^8.18.0", - "zod-to-json-schema": "^3.23.5" + "zod-to-json-schema": "^3.23.5", + "playwright-core": "^1.52.0" }, "optionalDependencies": { "@ai-sdk/anthropic": "^1.2.6", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9f9864d8f..ddb76968a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -47,6 +47,9 @@ importers: playwright: specifier: ^1.52.0 version: 1.52.0 + playwright-core: + specifier: ^1.52.0 + version: 1.52.0 ws: specifier: ^8.18.0 version: 8.18.1 @@ -166,9 +169,6 @@ importers: string-comparison: specifier: ^1.3.0 version: 1.3.0 - tsup: - specifier: ^8.2.1 - version: 8.4.0(jiti@1.21.7)(postcss@8.5.6)(tsx@4.19.4)(typescript@5.8.3)(yaml@2.7.1) tsx: specifier: ^4.10.5 version: 4.19.4 @@ -1392,106 +1392,6 @@ packages: engines: {node: '>=18'} hasBin: true - '@rollup/rollup-android-arm-eabi@4.40.1': - resolution: {integrity: sha512-kxz0YeeCrRUHz3zyqvd7n+TVRlNyTifBsmnmNPtk3hQURUyG9eAB+usz6DAwagMusjx/zb3AjvDUvhFGDAexGw==} - cpu: [arm] - os: [android] - - '@rollup/rollup-android-arm64@4.40.1': - resolution: {integrity: sha512-PPkxTOisoNC6TpnDKatjKkjRMsdaWIhyuMkA4UsBXT9WEZY4uHezBTjs6Vl4PbqQQeu6oION1w2voYZv9yquCw==} - cpu: [arm64] - os: [android] - - '@rollup/rollup-darwin-arm64@4.40.1': - resolution: {integrity: sha512-VWXGISWFY18v/0JyNUy4A46KCFCb9NVsH+1100XP31lud+TzlezBbz24CYzbnA4x6w4hx+NYCXDfnvDVO6lcAA==} - cpu: [arm64] - os: [darwin] - - '@rollup/rollup-darwin-x64@4.40.1': - resolution: {integrity: sha512-nIwkXafAI1/QCS7pxSpv/ZtFW6TXcNUEHAIA9EIyw5OzxJZQ1YDrX+CL6JAIQgZ33CInl1R6mHet9Y/UZTg2Bw==} - cpu: [x64] - os: [darwin] - - '@rollup/rollup-freebsd-arm64@4.40.1': - resolution: {integrity: sha512-BdrLJ2mHTrIYdaS2I99mriyJfGGenSaP+UwGi1kB9BLOCu9SR8ZpbkmmalKIALnRw24kM7qCN0IOm6L0S44iWw==} - cpu: [arm64] - os: [freebsd] - - '@rollup/rollup-freebsd-x64@4.40.1': - resolution: {integrity: sha512-VXeo/puqvCG8JBPNZXZf5Dqq7BzElNJzHRRw3vjBE27WujdzuOPecDPc/+1DcdcTptNBep3861jNq0mYkT8Z6Q==} - cpu: [x64] - os: [freebsd] - - '@rollup/rollup-linux-arm-gnueabihf@4.40.1': - resolution: {integrity: sha512-ehSKrewwsESPt1TgSE/na9nIhWCosfGSFqv7vwEtjyAqZcvbGIg4JAcV7ZEh2tfj/IlfBeZjgOXm35iOOjadcg==} - cpu: [arm] - os: [linux] - - '@rollup/rollup-linux-arm-musleabihf@4.40.1': - resolution: {integrity: sha512-m39iO/aaurh5FVIu/F4/Zsl8xppd76S4qoID8E+dSRQvTyZTOI2gVk3T4oqzfq1PtcvOfAVlwLMK3KRQMaR8lg==} - cpu: [arm] - os: [linux] - - '@rollup/rollup-linux-arm64-gnu@4.40.1': - resolution: {integrity: sha512-Y+GHnGaku4aVLSgrT0uWe2o2Rq8te9hi+MwqGF9r9ORgXhmHK5Q71N757u0F8yU1OIwUIFy6YiJtKjtyktk5hg==} - cpu: [arm64] - os: [linux] - - '@rollup/rollup-linux-arm64-musl@4.40.1': - resolution: {integrity: sha512-jEwjn3jCA+tQGswK3aEWcD09/7M5wGwc6+flhva7dsQNRZZTe30vkalgIzV4tjkopsTS9Jd7Y1Bsj6a4lzz8gQ==} - cpu: [arm64] - os: [linux] - - '@rollup/rollup-linux-loongarch64-gnu@4.40.1': - resolution: {integrity: sha512-ySyWikVhNzv+BV/IDCsrraOAZ3UaC8SZB67FZlqVwXwnFhPihOso9rPOxzZbjp81suB1O2Topw+6Ug3JNegejQ==} - cpu: [loong64] - os: [linux] - - '@rollup/rollup-linux-powerpc64le-gnu@4.40.1': - resolution: {integrity: sha512-BvvA64QxZlh7WZWqDPPdt0GH4bznuL6uOO1pmgPnnv86rpUpc8ZxgZwcEgXvo02GRIZX1hQ0j0pAnhwkhwPqWg==} - cpu: [ppc64] - os: [linux] - - '@rollup/rollup-linux-riscv64-gnu@4.40.1': - resolution: {integrity: sha512-EQSP+8+1VuSulm9RKSMKitTav89fKbHymTf25n5+Yr6gAPZxYWpj3DzAsQqoaHAk9YX2lwEyAf9S4W8F4l3VBQ==} - cpu: [riscv64] - os: [linux] - - '@rollup/rollup-linux-riscv64-musl@4.40.1': - resolution: {integrity: sha512-n/vQ4xRZXKuIpqukkMXZt9RWdl+2zgGNx7Uda8NtmLJ06NL8jiHxUawbwC+hdSq1rrw/9CghCpEONor+l1e2gA==} - cpu: [riscv64] - os: [linux] - - '@rollup/rollup-linux-s390x-gnu@4.40.1': - resolution: {integrity: sha512-h8d28xzYb98fMQKUz0w2fMc1XuGzLLjdyxVIbhbil4ELfk5/orZlSTpF/xdI9C8K0I8lCkq+1En2RJsawZekkg==} - cpu: [s390x] - os: [linux] - - '@rollup/rollup-linux-x64-gnu@4.40.1': - resolution: {integrity: sha512-XiK5z70PEFEFqcNj3/zRSz/qX4bp4QIraTy9QjwJAb/Z8GM7kVUsD0Uk8maIPeTyPCP03ChdI+VVmJriKYbRHQ==} - cpu: [x64] - os: [linux] - - '@rollup/rollup-linux-x64-musl@4.40.1': - resolution: {integrity: sha512-2BRORitq5rQ4Da9blVovzNCMaUlyKrzMSvkVR0D4qPuOy/+pMCrh1d7o01RATwVy+6Fa1WBw+da7QPeLWU/1mQ==} - cpu: [x64] - os: [linux] - - '@rollup/rollup-win32-arm64-msvc@4.40.1': - resolution: {integrity: sha512-b2bcNm9Kbde03H+q+Jjw9tSfhYkzrDUf2d5MAd1bOJuVplXvFhWz7tRtWvD8/ORZi7qSCy0idW6tf2HgxSXQSg==} - cpu: [arm64] - os: [win32] - - '@rollup/rollup-win32-ia32-msvc@4.40.1': - resolution: {integrity: sha512-DfcogW8N7Zg7llVEfpqWMZcaErKfsj9VvmfSyRjCyo4BI3wPEfrzTtJkZG6gKP/Z92wFm6rz2aDO7/JfiR/whA==} - cpu: [ia32] - os: [win32] - - '@rollup/rollup-win32-x64-msvc@4.40.1': - resolution: {integrity: sha512-ECyOuDeH3C1I8jH2MK1RtBJW+YPMvSfT0a5NN0nHfQYnDSJ6tUiZH3gzwVP5/Kfh/+Tt7tpWVF9LXNTnhTJ3kA==} - cpu: [x64] - os: [win32] - '@shikijs/core@3.11.0': resolution: {integrity: sha512-oJwU+DxGqp6lUZpvtQgVOXNZcVsirN76tihOLBmwILkKuRuwHteApP8oTXmL4tF5vS5FbOY0+8seXmiCoslk4g==} @@ -2160,12 +2060,6 @@ packages: buffer@5.7.1: resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==} - bundle-require@5.1.0: - resolution: {integrity: sha512-3WrrOuZiyaaZPWiEt4G3+IffISVC9HYlWueJEBWED4ZH4aIAC2PnkdnuRrR94M+w6yGWn4AglWtJtBI8YqvgoA==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - peerDependencies: - esbuild: '>=0.18' - busboy@1.6.0: resolution: {integrity: sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==} engines: {node: '>=10.16.0'} @@ -2174,10 +2068,6 @@ packages: resolution: {integrity: sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==} engines: {node: '>= 0.8'} - cac@6.7.14: - resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==} - engines: {node: '>=8'} - cacheable-lookup@7.0.0: resolution: {integrity: sha512-+qJyx4xiKra8mZrcwhjMRMUhD5NR1R8esPkzIYxX96JiecFoxAXFuz/GpR3+ev4PE1WamHip78wV0vcmPQtp8w==} engines: {node: '>=14.16'} @@ -2253,10 +2143,6 @@ packages: resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==} engines: {node: '>= 8.10.0'} - chokidar@4.0.3: - resolution: {integrity: sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==} - engines: {node: '>= 14.16.0'} - chownr@2.0.0: resolution: {integrity: sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==} engines: {node: '>=10'} @@ -2366,10 +2252,6 @@ packages: resolution: {integrity: sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==} engines: {'0': node >= 0.8} - consola@3.4.2: - resolution: {integrity: sha512-5IKcdX0nnYavi6G7TtOhwkYzyjfJlatbjMjuLSfE2kYT5pMDOilZ4OvMhi637CcDICTmz3wARPoyhqyX1Y+XvA==} - engines: {node: ^14.18.0 || >=16.10.0} - console-table-printer@2.12.1: resolution: {integrity: sha512-wKGOQRRvdnd89pCeH96e2Fn4wkbenSP6LMHfjfyNLMbGuHEFbMqQNuxXqd0oXG9caIOQ1FTvc5Uijp9/4jujnQ==} @@ -2936,14 +2818,6 @@ packages: fd-slicer@1.1.0: resolution: {integrity: sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==} - fdir@6.4.4: - resolution: {integrity: sha512-1NZP+GK4GfuAv3PqKvxQRDMjdSRZjnkq7KfhlNrCNNlZ0ygQFpebfrnfnq/W7fpUnAv9aGWmY1zKx7FYL3gwhg==} - peerDependencies: - picomatch: ^3 || ^4 - peerDependenciesMeta: - picomatch: - optional: true - fetch-cookie@3.1.0: resolution: {integrity: sha512-s/XhhreJpqH0ftkGVcQt8JE9bqk+zRn4jF5mPJXWZeQMCI5odV9K+wEWYbnzFPHgQZlvPSMjS4n4yawWE8RINw==} @@ -3709,10 +3583,6 @@ packages: lines-and-columns@1.2.4: resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} - load-tsconfig@0.2.5: - resolution: {integrity: sha512-IXO6OCs9yg8tMKzfPZ1YmheJbZCiEsnBdcB03l0OcfK9prKnJb96siuHCr5Fl37/yo9DnKU+TLpxzTUspw9shg==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - locate-character@3.0.0: resolution: {integrity: sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==} @@ -3727,9 +3597,6 @@ packages: lodash.merge@4.6.2: resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==} - lodash.sortby@4.7.0: - resolution: {integrity: sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==} - lodash.startcase@4.4.0: resolution: {integrity: sha512-+WKqsK294HMSc2jEbNgpHpd0JfIBhp7rEV4aqXWqFr6AlXov+SlcgB1Fv01y2kGe3Gc8nMW7VA0SrGuSkRfIEg==} @@ -4403,10 +4270,6 @@ packages: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} engines: {node: '>=8.6'} - picomatch@4.0.2: - resolution: {integrity: sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==} - engines: {node: '>=12'} - pify@2.3.0: resolution: {integrity: sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==} engines: {node: '>=0.10.0'} @@ -4483,24 +4346,6 @@ packages: ts-node: optional: true - postcss-load-config@6.0.1: - resolution: {integrity: sha512-oPtTM4oerL+UXmx+93ytZVN82RrlY/wPUV8IeDxFrzIjXOLF1pN+EmKPLbubvKHT2HC20xXsCAH2Z+CKV6Oz/g==} - engines: {node: '>= 18'} - peerDependencies: - jiti: '>=1.21.0' - postcss: '>=8.0.9' - tsx: ^4.8.1 - yaml: ^2.4.2 - peerDependenciesMeta: - jiti: - optional: true - postcss: - optional: true - tsx: - optional: true - yaml: - optional: true - postcss-nested@6.2.0: resolution: {integrity: sha512-HQbt28KulC5AJzG+cZtj9kvKB93CFCdLvog1WFLf1D+xmMvPGlBstkpTEZfK5+AN9hfJocyBFCNiqyS48bpgzQ==} engines: {node: '>=12.0'} @@ -4643,10 +4488,6 @@ packages: resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==} engines: {node: '>=8.10.0'} - readdirp@4.1.2: - resolution: {integrity: sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==} - engines: {node: '>= 14.18.0'} - real-require@0.2.0: resolution: {integrity: sha512-57frrGM/OCTLqLOAh0mhVA9VBMHd+9U7Zb2THMGdBUoZVOtGbJzjxsYGDJ3A9AYYCP4hn6y1TVbaOfzWtm5GFg==} engines: {node: '>= 12.13.0'} @@ -4778,11 +4619,6 @@ packages: resolution: {integrity: sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==} engines: {iojs: '>=1.0.0', node: '>=0.10.0'} - rollup@4.40.1: - resolution: {integrity: sha512-C5VvvgCCyfyotVITIAv+4efVytl5F7wt+/I2i9q9GZcEXW9BP52YYOXC58igUi+LFZVHukErIIqQSWwv/M3WRw==} - engines: {node: '>=18.0.0', npm: '>=8.0.0'} - hasBin: true - router@2.2.0: resolution: {integrity: sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==} engines: {node: '>= 18'} @@ -4994,11 +4830,6 @@ packages: resolution: {integrity: sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==} engines: {node: '>= 8'} - source-map@0.8.0-beta.0: - resolution: {integrity: sha512-2ymg6oRBpebeZi9UUNsgQ89bhx01TcTkmNTGnNO88imTmbSgy4nfujrgVEFKWpMTEGA11EDkTt7mqObTPdigIA==} - engines: {node: '>= 8'} - deprecated: The work that was done in this beta branch won't be included in future versions - space-separated-tokens@2.0.2: resolution: {integrity: sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==} @@ -5164,13 +4995,6 @@ packages: through@2.3.8: resolution: {integrity: sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==} - tinyexec@0.3.2: - resolution: {integrity: sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==} - - tinyglobby@0.2.13: - resolution: {integrity: sha512-mEwzpUgrLySlveBwEVDMKk5B57bhLPYovRfPAXD5gA/98Opn0rCDj3GtLwFvCvH5RK9uPCExUROW5NjDwvqkxw==} - engines: {node: '>=12.0.0'} - tldts-core@6.1.86: resolution: {integrity: sha512-Je6p7pkk+KMzMv2XXKmAE3McmolOQFdxkKw0R8EYNr7sELW46JqnNeTX8ybPiQgvg1ymCoF8LXs5fzFaZvJPTA==} @@ -5197,13 +5021,6 @@ packages: tr46@0.0.3: resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} - tr46@1.0.1: - resolution: {integrity: sha512-dTpowEjclQ7Kgx5SdBkqRzVhERQXov8/l9Ft9dVM9fmg0W0KQSVaXX9T4i6twCPNtYiZM53lpSSUAwJbFPOHxA==} - - tree-kill@1.2.2: - resolution: {integrity: sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==} - hasBin: true - trim-lines@3.0.1: resolution: {integrity: sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg==} @@ -5228,25 +5045,6 @@ packages: tslib@2.8.1: resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} - tsup@8.4.0: - resolution: {integrity: sha512-b+eZbPCjz10fRryaAA7C8xlIHnf8VnsaRqydheLIqwG/Mcpfk8Z5zp3HayX7GaTygkigHl5cBUs+IhcySiIexQ==} - engines: {node: '>=18'} - hasBin: true - peerDependencies: - '@microsoft/api-extractor': ^7.36.0 - '@swc/core': ^1 - postcss: ^8.4.12 - typescript: '>=4.5.0' - peerDependenciesMeta: - '@microsoft/api-extractor': - optional: true - '@swc/core': - optional: true - postcss: - optional: true - typescript: - optional: true - tsx@4.19.4: resolution: {integrity: sha512-gK5GVzDkJK1SI1zwHf32Mqxf2tSJkNx+eYcNly5+nHvWqXUJYUkWBQtKauoESz3ymezAI++ZwT855x5p5eop+Q==} engines: {node: '>=18.0.0'} @@ -5460,9 +5258,6 @@ packages: webidl-conversions@3.0.1: resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} - webidl-conversions@4.0.2: - resolution: {integrity: sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==} - whatwg-encoding@3.1.1: resolution: {integrity: sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==} engines: {node: '>=18'} @@ -5474,9 +5269,6 @@ packages: whatwg-url@5.0.0: resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==} - whatwg-url@7.1.0: - resolution: {integrity: sha512-WUu7Rg1DroM7oQvGWfOiAK21n74Gg+T4elXEQYkOhtyLeWiJFoOGLXPKI/9gzIie9CtwVLm8wtw6YJdKyxSjeg==} - which-boxed-primitive@1.1.1: resolution: {integrity: sha512-TbX3mj8n0odCBFVlY8AxkqcHASw3L60jIuF8jFP78az3C2YhmGvqbHBpAjTRH2/xqYunrJ9g1jSyjCjpoWzIAA==} engines: {node: '>= 0.4'} @@ -6985,66 +6777,6 @@ snapshots: - bare-buffer - supports-color - '@rollup/rollup-android-arm-eabi@4.40.1': - optional: true - - '@rollup/rollup-android-arm64@4.40.1': - optional: true - - '@rollup/rollup-darwin-arm64@4.40.1': - optional: true - - '@rollup/rollup-darwin-x64@4.40.1': - optional: true - - '@rollup/rollup-freebsd-arm64@4.40.1': - optional: true - - '@rollup/rollup-freebsd-x64@4.40.1': - optional: true - - '@rollup/rollup-linux-arm-gnueabihf@4.40.1': - optional: true - - '@rollup/rollup-linux-arm-musleabihf@4.40.1': - optional: true - - '@rollup/rollup-linux-arm64-gnu@4.40.1': - optional: true - - '@rollup/rollup-linux-arm64-musl@4.40.1': - optional: true - - '@rollup/rollup-linux-loongarch64-gnu@4.40.1': - optional: true - - '@rollup/rollup-linux-powerpc64le-gnu@4.40.1': - optional: true - - '@rollup/rollup-linux-riscv64-gnu@4.40.1': - optional: true - - '@rollup/rollup-linux-riscv64-musl@4.40.1': - optional: true - - '@rollup/rollup-linux-s390x-gnu@4.40.1': - optional: true - - '@rollup/rollup-linux-x64-gnu@4.40.1': - optional: true - - '@rollup/rollup-linux-x64-musl@4.40.1': - optional: true - - '@rollup/rollup-win32-arm64-msvc@4.40.1': - optional: true - - '@rollup/rollup-win32-ia32-msvc@4.40.1': - optional: true - - '@rollup/rollup-win32-x64-msvc@4.40.1': - optional: true - '@shikijs/core@3.11.0': dependencies: '@shikijs/types': 3.11.0 @@ -7882,19 +7614,12 @@ snapshots: base64-js: 1.5.1 ieee754: 1.2.1 - bundle-require@5.1.0(esbuild@0.25.3): - dependencies: - esbuild: 0.25.3 - load-tsconfig: 0.2.5 - busboy@1.6.0: dependencies: streamsearch: 1.1.0 bytes@3.1.2: {} - cac@6.7.14: {} - cacheable-lookup@7.0.0: {} cacheable-request@10.2.14: @@ -7988,10 +7713,6 @@ snapshots: optionalDependencies: fsevents: 2.3.3 - chokidar@4.0.3: - dependencies: - readdirp: 4.1.2 - chownr@2.0.0: {} chromium-bidi@0.10.2(devtools-protocol@0.0.1464554): @@ -8100,8 +7821,6 @@ snapshots: readable-stream: 2.3.8 typedarray: 0.0.6 - consola@3.4.2: {} - console-table-printer@2.12.1: dependencies: simple-wcswidth: 1.0.1 @@ -8843,10 +8562,6 @@ snapshots: dependencies: pend: 1.2.0 - fdir@6.4.4(picomatch@4.0.2): - optionalDependencies: - picomatch: 4.0.2 - fetch-cookie@3.1.0: dependencies: set-cookie-parser: 2.7.1 @@ -9794,8 +9509,6 @@ snapshots: lines-and-columns@1.2.4: {} - load-tsconfig@0.2.5: {} - locate-character@3.0.0: {} locate-path@5.0.0: @@ -9808,8 +9521,6 @@ snapshots: lodash.merge@4.6.2: {} - lodash.sortby@4.7.0: {} - lodash.startcase@4.4.0: {} lodash.topath@4.5.2: {} @@ -10792,8 +10503,6 @@ snapshots: picomatch@2.3.1: {} - picomatch@4.0.2: {} - pify@2.3.0: {} pify@4.0.1: {} @@ -10871,15 +10580,6 @@ snapshots: optionalDependencies: postcss: 8.5.6 - postcss-load-config@6.0.1(jiti@1.21.7)(postcss@8.5.6)(tsx@4.19.4)(yaml@2.7.1): - dependencies: - lilconfig: 3.1.3 - optionalDependencies: - jiti: 1.21.7 - postcss: 8.5.6 - tsx: 4.19.4 - yaml: 2.7.1 - postcss-nested@6.2.0(postcss@8.5.6): dependencies: postcss: 8.5.6 @@ -11046,8 +10746,6 @@ snapshots: dependencies: picomatch: 2.3.1 - readdirp@4.1.2: {} - real-require@0.2.0: {} recma-build-jsx@1.0.0: @@ -11278,32 +10976,6 @@ snapshots: reusify@1.1.0: {} - rollup@4.40.1: - dependencies: - '@types/estree': 1.0.7 - optionalDependencies: - '@rollup/rollup-android-arm-eabi': 4.40.1 - '@rollup/rollup-android-arm64': 4.40.1 - '@rollup/rollup-darwin-arm64': 4.40.1 - '@rollup/rollup-darwin-x64': 4.40.1 - '@rollup/rollup-freebsd-arm64': 4.40.1 - '@rollup/rollup-freebsd-x64': 4.40.1 - '@rollup/rollup-linux-arm-gnueabihf': 4.40.1 - '@rollup/rollup-linux-arm-musleabihf': 4.40.1 - '@rollup/rollup-linux-arm64-gnu': 4.40.1 - '@rollup/rollup-linux-arm64-musl': 4.40.1 - '@rollup/rollup-linux-loongarch64-gnu': 4.40.1 - '@rollup/rollup-linux-powerpc64le-gnu': 4.40.1 - '@rollup/rollup-linux-riscv64-gnu': 4.40.1 - '@rollup/rollup-linux-riscv64-musl': 4.40.1 - '@rollup/rollup-linux-s390x-gnu': 4.40.1 - '@rollup/rollup-linux-x64-gnu': 4.40.1 - '@rollup/rollup-linux-x64-musl': 4.40.1 - '@rollup/rollup-win32-arm64-msvc': 4.40.1 - '@rollup/rollup-win32-ia32-msvc': 4.40.1 - '@rollup/rollup-win32-x64-msvc': 4.40.1 - fsevents: 2.3.3 - router@2.2.0: dependencies: debug: 4.4.0 @@ -11617,10 +11289,6 @@ snapshots: source-map@0.7.4: {} - source-map@0.8.0-beta.0: - dependencies: - whatwg-url: 7.1.0 - space-separated-tokens@2.0.2: {} spawndamnit@3.0.1: @@ -11847,13 +11515,6 @@ snapshots: through@2.3.8: {} - tinyexec@0.3.2: {} - - tinyglobby@0.2.13: - dependencies: - fdir: 6.4.4(picomatch@4.0.2) - picomatch: 4.0.2 - tldts-core@6.1.86: {} tldts@6.1.86: @@ -11876,12 +11537,6 @@ snapshots: tr46@0.0.3: {} - tr46@1.0.1: - dependencies: - punycode: 2.3.1 - - tree-kill@1.2.2: {} - trim-lines@3.0.1: {} trim-trailing-lines@2.1.0: {} @@ -11898,33 +11553,6 @@ snapshots: tslib@2.8.1: {} - tsup@8.4.0(jiti@1.21.7)(postcss@8.5.6)(tsx@4.19.4)(typescript@5.8.3)(yaml@2.7.1): - dependencies: - bundle-require: 5.1.0(esbuild@0.25.3) - cac: 6.7.14 - chokidar: 4.0.3 - consola: 3.4.2 - debug: 4.4.0 - esbuild: 0.25.3 - joycon: 3.1.1 - picocolors: 1.1.1 - postcss-load-config: 6.0.1(jiti@1.21.7)(postcss@8.5.6)(tsx@4.19.4)(yaml@2.7.1) - resolve-from: 5.0.0 - rollup: 4.40.1 - source-map: 0.8.0-beta.0 - sucrase: 3.35.0 - tinyexec: 0.3.2 - tinyglobby: 0.2.13 - tree-kill: 1.2.2 - optionalDependencies: - postcss: 8.5.6 - typescript: 5.8.3 - transitivePeerDependencies: - - jiti - - supports-color - - tsx - - yaml - tsx@4.19.4: dependencies: esbuild: 0.25.3 @@ -12173,8 +11801,6 @@ snapshots: webidl-conversions@3.0.1: {} - webidl-conversions@4.0.2: {} - whatwg-encoding@3.1.1: dependencies: iconv-lite: 0.6.3 @@ -12186,12 +11812,6 @@ snapshots: tr46: 0.0.3 webidl-conversions: 3.0.1 - whatwg-url@7.1.0: - dependencies: - lodash.sortby: 4.7.0 - tr46: 1.0.1 - webidl-conversions: 4.0.2 - which-boxed-primitive@1.1.1: dependencies: is-bigint: 1.1.0 diff --git a/scripts/build-cli.mjs b/scripts/build-cli.mjs new file mode 100644 index 000000000..d7b1e43fb --- /dev/null +++ b/scripts/build-cli.mjs @@ -0,0 +1,82 @@ +import process from "node:process"; +import { build } from "esbuild"; +import { chmodSync, copyFileSync, mkdirSync, readFileSync } from "node:fs"; +import { spawnSync } from "node:child_process"; +import path from "node:path"; + +const pkgJson = JSON.parse( + readFileSync(new URL("../package.json", import.meta.url)), +); +const externalDeps = Array.from( + new Set([ + ...Object.keys(pkgJson.dependencies ?? {}), + ...Object.keys(pkgJson.peerDependencies ?? {}), + ...Object.keys(pkgJson.optionalDependencies ?? {}), + ]), +); + +const distDir = path.join("dist", "evals"); +const cliOutfile = path.join(distDir, "cli.js"); +const configSource = path.join("evals", "evals.config.json"); +const configDestination = path.join(distDir, "evals.config.json"); + +const commonOptions = { + bundle: true, + platform: "node", + target: "es2022", + sourcemap: true, + packages: "external", + external: externalDeps, +}; + +const shouldLink = (() => { + const flag = process.env.STAGEHAND_SKIP_NPM_LINK ?? ""; + return flag !== "1" && flag.toLowerCase() !== "true"; +})(); + +async function main() { + mkdirSync(distDir, { recursive: true }); + + await build({ + entryPoints: ["evals/cli.ts"], + format: "cjs", + outfile: cliOutfile, + banner: { js: "#!/usr/bin/env node" }, + ...commonOptions, + }); + + copyFileSync(configSource, configDestination); + + try { + chmodSync(cliOutfile, 0o755); + } catch (error) { + const maybeSystemError = error; + if ( + !maybeSystemError || + typeof maybeSystemError !== "object" || + !("code" in maybeSystemError) || + (maybeSystemError.code !== "ENOSYS" && maybeSystemError.code !== "EPERM") + ) { + throw error; + } + } + + if (!shouldLink) { + console.warn("Skipping npm link because STAGEHAND_SKIP_NPM_LINK is set."); + return; + } + + const linkResult = spawnSync("npm", ["link"], { + stdio: "inherit", + shell: process.platform === "win32", + }); + + if (linkResult.status !== 0) { + process.exit(linkResult.status ?? 1); + } +} + +main().catch((error) => { + console.error(error); + process.exit(1); +}); diff --git a/scripts/build-e2e.mjs b/scripts/build-e2e.mjs new file mode 100644 index 000000000..9c84bb387 --- /dev/null +++ b/scripts/build-e2e.mjs @@ -0,0 +1,147 @@ +import fs from "node:fs"; +import path from "node:path"; +import process from "node:process"; +import { spawnSync } from "node:child_process"; +import { fileURLToPath } from "node:url"; +import { build } from "esbuild"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const ROOT = path.resolve(__dirname, ".."); +const SRC_DIR = path.join(ROOT, "evals", "deterministic"); +const OUT_BASE = path.join(ROOT, "dist", "playwright"); +const OUT_DIR = path.join(OUT_BASE, "evals", "deterministic"); +const STAGEHAND_ENTRY = path.join(ROOT, "dist", "index.js"); +const IMPORT_META_DECL = + 'var import_meta = { url: require("node:url").pathToFileURL(__filename).href };'; + +const shouldLink = (() => { + const flag = process.env.STAGEHAND_SKIP_NPM_LINK ?? ""; + return flag !== "1" && flag.toLowerCase() !== "true"; +})(); + +function ensureDir(dir) { + fs.mkdirSync(dir, { recursive: true }); +} + +function copyDir(src, dest) { + if (!fs.existsSync(src)) return; + ensureDir(dest); + for (const entry of fs.readdirSync(src, { withFileTypes: true })) { + const source = path.join(src, entry.name); + const target = path.join(dest, entry.name); + if (entry.isDirectory()) copyDir(source, target); + else fs.copyFileSync(source, target); + } +} + +function patchImportMeta(filePath) { + let content = fs.readFileSync(filePath, "utf8"); + if (!content.includes("var import_meta = {}")) { + return; + } + + content = content.replace("var import_meta = {};", IMPORT_META_DECL); + content = content.replaceAll('"globalSetup.ts"', '"globalSetup.js"'); + fs.writeFileSync(filePath, content, "utf8"); +} + +function rewriteStagehandImports(filePath) { + let content = fs.readFileSync(filePath, "utf8"); + if (!content.includes("@browserbasehq/stagehand")) { + return; + } + + const relative = path.relative(path.dirname(filePath), STAGEHAND_ENTRY); + const basePath = relative.startsWith(".") ? relative : "./" + relative; + const importPath = basePath.split(path.sep).join("/"); + + content = content.replaceAll( + 'require("@browserbasehq/stagehand")', + 'require("' + importPath + '")', + ); + content = content.replaceAll( + 'from "@browserbasehq/stagehand"', + 'from "' + importPath + '"', + ); + + fs.writeFileSync(filePath, content, "utf8"); +} + +function traverseOutputs(dir) { + for (const entry of fs.readdirSync(dir, { withFileTypes: true })) { + const entryPath = path.join(dir, entry.name); + if (entry.isDirectory()) { + traverseOutputs(entryPath); + } else if (entry.isFile() && entry.name.endsWith(".js")) { + patchImportMeta(entryPath); + rewriteStagehandImports(entryPath); + } + } +} + +async function main() { + ensureDir(OUT_DIR); + + const entryPoints = []; + const collectEntryPoints = (dir) => { + for (const entry of fs.readdirSync(dir, { withFileTypes: true })) { + const entryPath = path.join(dir, entry.name); + if (entry.isDirectory()) collectEntryPoints(entryPath); + else if (entry.isFile() && entryPath.endsWith(".ts")) { + entryPoints.push(entryPath); + } + } + }; + collectEntryPoints(SRC_DIR); + + const pkgJson = JSON.parse( + fs.readFileSync(path.join(ROOT, "package.json"), "utf8"), + ); + const externalDeps = Array.from( + new Set([ + ...Object.keys(pkgJson.dependencies ?? {}), + ...Object.keys(pkgJson.peerDependencies ?? {}), + ...Object.keys(pkgJson.optionalDependencies ?? {}), + "@playwright/test", + "playwright", + ]), + ); + + await build({ + entryPoints, + outbase: ROOT, + outdir: OUT_BASE, + platform: "node", + target: "es2022", + format: "cjs", + bundle: true, + sourcemap: true, + tsconfig: path.join(SRC_DIR, "tsconfig.playwright.json"), + packages: "external", + external: externalDeps, + banner: { + js: "var __name = (target, value) => { try { Object.defineProperty(target, 'name', { value, configurable: true }); } catch {} return target; };", + }, + logLevel: "silent", + }); + + traverseOutputs(OUT_BASE); + + copyDir(path.join(SRC_DIR, "auxiliary"), path.join(OUT_DIR, "auxiliary")); + + if (shouldLink) { + const linkResult = spawnSync("npm", ["link"], { + stdio: "inherit", + shell: process.platform === "win32", + }); + + if ((linkResult.status ?? 0) !== 0) { + process.exit(linkResult.status ?? 1); + } + } +} + +main().catch((err) => { + console.error(err); + process.exit(1); +}); diff --git a/scripts/build-lib.mjs b/scripts/build-lib.mjs new file mode 100644 index 000000000..72f29035d --- /dev/null +++ b/scripts/build-lib.mjs @@ -0,0 +1,40 @@ +import fs from "node:fs"; +import process from "node:process"; +import { build } from "esbuild"; + +const pkgJson = JSON.parse( + fs.readFileSync(new URL("../package.json", import.meta.url)), +); +const externalDeps = Array.from( + new Set([ + ...Object.keys(pkgJson.dependencies ?? {}), + ...Object.keys(pkgJson.peerDependencies ?? {}), + ...Object.keys(pkgJson.optionalDependencies ?? {}), + ]), +); + +const commonOptions = { + bundle: true, + platform: "node", + target: "es2022", + sourcemap: true, + banner: { + js: "var __name = (target, value) => { try { Object.defineProperty(target, 'name', { value, configurable: true }); } catch {} return target; };", + }, + packages: "external", + external: externalDeps, +}; + +async function main() { + await build({ + entryPoints: ["lib/index.ts"], + format: "esm", + outfile: "dist/index.js", + ...commonOptions, + }); +} + +main().catch((error) => { + console.error(error); + process.exit(1); +}); diff --git a/scripts/run-playwright.mjs b/scripts/run-playwright.mjs new file mode 100644 index 000000000..10566db8f --- /dev/null +++ b/scripts/run-playwright.mjs @@ -0,0 +1,23 @@ +import { spawnSync } from "node:child_process"; +import { createRequire } from "node:module"; +import process from "node:process"; + +// Pass-through runner that executes the compiled Playwright config. +// We intentionally avoid tsx/ts-node to sidestep worker loader timing issues. + +const args = process.argv.slice(2); +const cliArgs = args[0] === "test" ? args : ["test", ...args]; +const require = createRequire(import.meta.url); +const playwrightCli = require.resolve("@playwright/test/cli"); + +const result = spawnSync(process.execPath, [playwrightCli, ...cliArgs], { + stdio: "inherit", + env: { ...process.env }, +}); + +if (result.error) { + console.error(result.error); + process.exit(1); +} + +process.exit(result.status ?? 0); diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 000000000..ff5b5220f --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,21 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "declaration": true, + "emitDeclarationOnly": true, + "outDir": "dist", + "noEmit": false, + "stripInternal": false + }, + "include": [ + "lib/**/*.ts", + "lib/**/*.tsx", + "types/**/*.ts" + ], + "exclude": [ + "node_modules", + "dist", + "types/evals.ts", + "evals/**" + ] +} From af7dd0c3f406ad84a984fa2f801a79f260667d36 Mon Sep 17 00:00:00 2001 From: TR-3B <144127816+MagellaX@users.noreply.github.com> Date: Wed, 24 Sep 2025 16:51:15 +0530 Subject: [PATCH 2/2] Update scripts/build-e2e.mjs Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --- scripts/build-e2e.mjs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/build-e2e.mjs b/scripts/build-e2e.mjs index 9c84bb387..4c2899781 100644 --- a/scripts/build-e2e.mjs +++ b/scripts/build-e2e.mjs @@ -40,8 +40,10 @@ function patchImportMeta(filePath) { return; } - content = content.replace("var import_meta = {};", IMPORT_META_DECL); - content = content.replaceAll('"globalSetup.ts"', '"globalSetup.js"'); + const importMetaPattern = /var import_meta = \{\};/g; + if (importMetaPattern.test(content)) { + content = content.replace(importMetaPattern, IMPORT_META_DECL); + } fs.writeFileSync(filePath, content, "utf8"); }