Skip to content

feat: assemble driver from npm instead of CDN#1927

Merged
yury-s merged 1 commit into
microsoft:mainfrom
yury-s:assemble-driver-from-npm
Jun 12, 2026
Merged

feat: assemble driver from npm instead of CDN#1927
yury-s merged 1 commit into
microsoft:mainfrom
yury-s:assemble-driver-from-npm

Conversation

@yury-s

@yury-s yury-s commented Jun 12, 2026

Copy link
Copy Markdown
Member

What

Download the driver from the canonical npm registry rather than cdn.playwright.dev. Each platform's driver is now assembled from the playwright-core npm package plus the matching Node.js binary from nodejs.org, the same way the upstream Playwright build does it — mirroring the approach in microsoft/playwright-dotnet#3322.

The driver version is pinned to the exact upstream commit via npm view playwright@<version> gitHead, and the paired NODE_VERSION is read from that commit's build-playwright-driver.sh.

api.json

The npm package does not contain api.json (it is a build artifact upstream copies into the CDN zip). So generate_api.sh now generates it from the upstream Playwright source at the same commit — via a minimal sparse checkout (utils + docs, no npm install) running generateApiJson.js — instead of relying on the bundled driver's print-api-json. Set PW_SRC_DIR to reuse an existing microsoft/playwright checkout.

Verification

  • All 5 platforms (mac, mac-arm64, linux, linux-arm64, win32_x64) assemble in ~12s with correct per-arch Node.js binaries.
  • The assembled package/ is byte-identical to the official CDN zip's, except the two intentionally-dropped build artifacts (api.json, protocol.yml — the latter unused at runtime).
  • The driver runs via the real runtime path (node package/cli.js --version).
  • The generated api.json is byte-identical to the official CDN-bundled 1.60.0 api.json.

References https://github.com/microsoft/playwright-internal/issues/291

Download the driver from the canonical npm registry rather than
cdn.playwright.dev. Each platform's driver is assembled from the
playwright-core npm package plus the matching Node.js binary from
nodejs.org, the same way the upstream Playwright build does it,
mirroring the approach in playwright-dotnet#3322.

The npm package does not contain api.json, so generate_api.sh now
generates it from the upstream Playwright source at the exact commit
that produced the driver version (resolved via npm gitHead), instead
of relying on the bundled driver's print-api-json command.

References microsoft/playwright-internal#291

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@yury-s yury-s requested review from dcrousso and dgozman June 12, 2026 17:40
fi

# The Node.js version is kept in sync with the driver version in the upstream build script.
NODE_VERSION=$(curl -fsSL "https://raw.githubusercontent.com/microsoft/playwright/$GIT_HEAD/utils/build/build-playwright-driver.sh" \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'll get rid of this script later on, so the node version would be somewhere else (probably hardcoded and updated right here in this script).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm on the fence, we have this auto-updater upstream which could jus bump NODE_VERSION file there. In any case we can update this line later on.

@yury-s yury-s merged commit 7a59a68 into microsoft:main Jun 12, 2026
17 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants