Skip to content

fix: do not inline package.json into coreBundle#40093

Merged
yury-s merged 1 commit intomicrosoft:mainfrom
yury-s:fix/package-json-bundling-version
Apr 7, 2026
Merged

fix: do not inline package.json into coreBundle#40093
yury-s merged 1 commit intomicrosoft:mainfrom
yury-s:fix/package-json-bundling-version

Conversation

@yury-s
Copy link
Copy Markdown
Member

@yury-s yury-s commented Apr 7, 2026

Summary

packages/playwright-core/src/package.ts does require('../package.json'). esbuild statically resolves this when bundling coreBundle.ts and inlines the JSON contents (with the source 1.x.0-next version) into lib/coreBundle.js. After release tagging the on-disk package.json carries the published version, but the bundle still reports 1.x.0-next.

This breaks playwright-cli's daemon protocol. The daemon (which loads coreBundle.js) writes session files with version: "1.x.0-next", while the client (which loads the standalone lib/package.js) reports the published version like 1.60.0-alpha-2026-04-07. The semver compatibility check in tools/cli-client/session.ts then rejects every command with:

Error: Client is v1.60.0-alpha-2026-04-07, session 'default' is v1.60.0-next.

The bug was introduced in #40074, which was the first change to ship a pre-built coreBundle.js to npm.

Fix

Use a runtime-computed path so esbuild cannot statically analyze the require, matching the pattern already used for api.json and help.json elsewhere in the codebase (require(libPath(...)), require(path.join(packageRoot, ...))).

esbuild was statically resolving `require('../package.json')` in
package.ts and inlining the JSON contents into the bundled
coreBundle.js. This froze the source `1.x.0-next` version into the
bundle, diverging from the published version that the on-disk
package.json carries after release tagging.

The mismatch broke playwright-cli's daemon protocol: the daemon (loaded
from coreBundle.js) wrote sessions with version `1.x.0-next`, while the
client (loaded from the standalone lib/package.js) reported the
published version like `1.60.0-alpha-2026-04-07`. The semver
compatibility check then rejected every command with "Client is vX,
session is v1.x.0-next".

Use a runtime-computed path so esbuild cannot statically analyze the
require, matching the pattern already used for api.json and help.json
elsewhere in the codebase.
@yury-s yury-s force-pushed the fix/package-json-bundling-version branch from 2bfdd34 to 8c8010d Compare April 7, 2026 17:27
@yury-s yury-s merged commit 50b5779 into microsoft:main Apr 7, 2026
36 of 37 checks passed
@yury-s yury-s deleted the fix/package-json-bundling-version branch April 7, 2026 17:58
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Test results for "MCP"

6442 passed, 383 skipped


Merge workflow run.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Test results for "tests 1"

1 failed
❌ [playwright-test] › reporter-html.spec.ts:365 › created › should use different path if attachments base url option is provided @macos-latest-node20

5 flaky ⚠️ [chromium-library] › library/popup.spec.ts:261 › should not throw when click closes popup `@ubuntu-22.04-chromium-tip-of-tree`
⚠️ [chromium-library] › library/browsercontext-reuse.spec.ts:361 › reuse launch › should work with routeWebSocket `@chromium-ubuntu-22.04-arm-node20`
⚠️ [chromium-library] › library/video.spec.ts:118 › screencast › should capture static page `@chromium-ubuntu-22.04-node24`
⚠️ [chromium-library] › library/video.spec.ts:342 › screencast › should work for popups `@chromium-ubuntu-22.04-node22`
⚠️ [firefox-page] › page/page-wait-for-function.spec.ts:104 › should work with strict CSP policy `@firefox-ubuntu-22.04-node20`

39141 passed, 846 skipped


Merge workflow run.

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