Implementation:Microsoft Playwright CheckDeps
Overview
CheckDeps is a build utility that validates import dependencies across all Playwright packages, ensuring that each package only imports from allowed dependencies and that dependency versions are consistent.
Description
This script performs comprehensive dependency validation:
- Parses TypeScript/JavaScript source files using the TypeScript compiler API to extract import statements
- Validates that each import resolves to an allowed dependency based on the package's
package.json - Checks for version mismatches between
playwright-coreandplaywrightpackage dependencies - Handles special import mappings for internal packages (web, injected, isomorphic, testIsomorphic)
- Recognizes Node.js builtins and peer dependencies (electron, react, zod, etc.)
- Supports path-mapped imports via TypeScript's
tsconfigpaths
The script iterates through all packages including html-reporter, playwright-ct-core, protocol, recorder, trace-viewer, web, injected, playwright-core, and playwright.
Usage
Run as a CI check to ensure dependency hygiene across the monorepo.
Code Reference
Source Location
utils/check_deps.js (274 lines)
Key Functions
async function checkDeps()
async function innerCheckDeps(root)
function listFiles(dir)
Execution
node utils/check_deps.js
I/O Contract
Inputs
- Source files from all packages in the monorepo
package.jsonfiles for dependency declarations
Outputs
- Console warnings for undeclared dependencies
- Exit code 1 if version mismatches are found between packages
Related Pages
- Microsoft_Playwright_Workspace -- Workspace management for the monorepo
- Microsoft_Playwright_Generate_Injected -- Build script for injected scripts