playwrightLoader: adapt to playwright-core 1.60 restructure#81
Merged
Conversation
playwright-core 1.60 removed the internal subpaths we were importing:
- ./lib/server/registry/index (provided the Registry instance)
- ./lib/zipBundle (provided the extract function)
Those file paths no longer exist AND aren't in package.json's exports
map. Any import that names them throws ERR_PACKAGE_PATH_NOT_EXPORTED.
Our caller surfaces the throw as BrowserFeaturesUnavailableError so the
user sees 'Browser-based features are not available in the standalone
latchkey binary' — misleading, since playwright and playwright-core
both resolve fine, only the deep paths are gone.
The same symbols live inside ./lib/coreBundle (which IS in the exports
map):
- coreBundle.default.registry.registry → the Registry instance
- coreBundle.default.utils.extractZip → the zip extract function
Load coreBundle once and adapt its namespace to the original
{ registry } / { extract } shape that playwrightDownload.ts
destructures. Empirically verified that registry.findExecutable('chromium')
returns a real Executable with executablePath/installType in
playwright-core 1.60.0.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Problem: src/playwrightLoader.ts ended with stray '</content>' and '</invoke>' lines left over from a code-generation transcript, causing TypeScript compile errors (TS1110, TS1161) that broke tsc for the whole project. Fix: Delete the two trailing artifact lines so the file ends cleanly after loadPlaywrightZipBundle. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Problem: loadPlaywrightRegistry returned { registry: unknown }, so callers
in playwrightDownload.ts that use registry.findExecutable(...) and the
returned executable's directory/executablePath/downloadURLs/name failed to
typecheck (TS18046 'registry is of type unknown').
Fix: Add minimal PlaywrightExecutable and PlaywrightRegistry interfaces
reflecting the coreBundle registry shape (verified against playwright-core
1.60) and return { registry: PlaywrightRegistry }.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Problem: playwright-core ships no type declarations for the internal 'lib/coreBundle' subpath, so tsc failed with TS2307 'Cannot find module' on the dynamic import introduced by this change, breaking typecheck. Fix: Add a @ts-expect-error directive on the import, mirroring the existing pattern used for untyped dynamic imports in skillMd.ts. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Problem: playwrightLoader.ts imports playwright-core/lib/coreBundle, which
only exists in playwright-core >=1.60.0; 1.58.2/1.59.x still ship the old
lib/zipBundle and lib/server/registry/index layout. package.json declared
playwright ^1.58.2 and the lockfile pinned 1.58.2, so under the declared
floor the new code throws ERR_PACKAGE_PATH_NOT_EXPORTED at runtime and
vitest fails to load tests/playwrightDownload.test.ts ('Missing
./lib/coreBundle specifier in playwright-core').
Fix: Bump playwright to ^1.60.0 and update the lockfile to playwright-core
1.60.0. Also export the PlaywrightExecutable/PlaywrightRegistry interfaces
so getChromiumExecutable's inferred return type can be named across the
module boundary (TS4058).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Problem: the playwright-core 1.60 refactor switched playwrightLoader.ts to import 'playwright-core/lib/coreBundle' but left src/playwright-core.d.ts declaring only the removed subpaths 'lib/server/registry/index' and 'lib/zipBundle' (dead code, nothing imports them). To compensate, the loader typed the new import inline with an interface plus '@ts-expect-error' and an 'as unknown as' double cast, duplicating the Executable/Registry interfaces already in the .d.ts and bypassing type checking of the dynamic import. The file-level comment also narrated the migration history. Fix: replace the stale declarations in src/playwright-core.d.ts with a single ambient declaration for 'playwright-core/lib/coreBundle' (Executable, Registry, and the default export shape). playwrightLoader.ts now derives its types from that declaration, dropping the '@ts-expect-error', the unsafe cast, and the duplicated inline interfaces. Trimmed the file comment to the load-bearing exports-map fact. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Problem: The doc comment added to src/playwrightLoader.ts used RST-style double-backtick code spans (``lib/coreBundle`` etc.), inconsistent with the file header and every other comment code span in src/, which use single backticks. Fix: Converted the four double-backtick spans to single backticks to match the dominant comment style. Comment-only change with no behavior impact. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The doc comment narrated the full playwright-core 1.60 migration; that history belongs in the PR description. Trim it to what the code does (read registry/extract from lib/coreBundle) and the one load-bearing fact (it is the only exports-mapped subpath that reaches them). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
playwrightLoader.ts imports playwright-core private internals (lib/coreBundle), which carry no semver guarantee and were restructured in the 1.59->1.60 minor bump. A caret range lets a fresh `npm install -g latchkey` resolve a future minor that moves them again, silently reintroducing ERR_PACKAGE_PATH_NOT_EXPORTED. Tilde allows only 1.60.x patches; minor playwright upgrades become deliberate, re-verified changes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Collaborator
|
Looks good to me. Thanks, @weishi-imbue ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
playwright-core 1.60 dropped the internal subpaths we were importing in playwrightLoader.ts:
./lib/server/registry/index(Registry instance)./lib/zipBundle(extract function)Both files were removed AND not added to
package.json#exports. Imports throwERR_PACKAGE_PATH_NOT_EXPORTED, which our caller wraps asBrowserFeaturesUnavailableError— "Browser-based features are not available in the standalone latchkey binary". Misleading: latchkey isn't standalone, just incompatible with the new playwright-core.This PR loads
lib/coreBundle(which IS in the exports map) once and pulls the same symbols from the new locations:coreBundle.default.registry.registry→ Registry instancecoreBundle.default.utils.extractZip→ extract functionThe returned shape is unchanged so
playwrightDownload.tskeeps working without changes.Empirically verified locally that the new
registryexposesfindExecutable('chromium')and returns a real Executable. Diagnosed against the bundledplaywright-core@1.60.0shipping inside the minds.app, which is the version most users encounter.Dependency bump (required)
lib/coreBundleonly exists in playwright-core ≥ 1.60.0; 1.58.x/1.59.x still ship the oldlib/zipBundle+lib/server/registry/indexlayout. latchkey declaredplaywright ^1.58.2(lockfile pinned 1.58.2), so the new imports would throwERR_PACKAGE_PATH_NOT_EXPORTEDon thenpm install -g latchkeypath even though they resolve fine against the minds.app-bundled 1.60. This PR therefore bumpsplaywrightand regenerates the lockfile so latchkey's own declared dependency matches the layout the code now requires.The range is pinned with a tilde (
~1.60.0), not a caret. We import playwright-core private internals, which carry no semver guarantee and were restructured in the 1.59→1.60 minor bump. A caret would let a freshnpm install -g latchkeyresolve a future minor that moves them again, silently reintroducing this exact failure. Tilde allows only 1.60.x patches; minor playwright upgrades become deliberate, re-verified changes.Typing
playwright-coreships no.d.tsfor these internal subpaths, sosrc/playwright-core.d.tscarries an ambient declaration forlib/coreBundle(Executable,Registry, and thedefaultexport shape).playwrightLoader.tsderives its return types from that declaration — no inline casts or@ts-expect-error.🤖 Generated with Claude Code