Skip to content

fix: lazy-load Playwright to prevent it leaking into check-trigger bu…#31

Merged
DeDuckProject merged 1 commit intomainfrom
fix/lazy-playwright-import
Mar 14, 2026
Merged

fix: lazy-load Playwright to prevent it leaking into check-trigger bu…#31
DeDuckProject merged 1 commit intomainfrom
fix/lazy-playwright-import

Conversation

@DeDuckProject
Copy link
Copy Markdown
Owner

@DeDuckProject DeDuckProject commented Mar 14, 2026

Problem

check-trigger was pulling in require("@playwright/test") even though it never uses Playwright. The root cause was a barrel file chain:

check.ts
  → @git-glimpse/core (barrel index.ts)
    → pipeline.ts
      → playwright-runner.ts  ← static import { chromium } from '@playwright/test'
    → fallback.ts             ← static import { chromium } from '@playwright/test'

esbuild marks @playwright/test as --external, so dist/check.js ended up with a dangling require("@playwright/test") that fails at runtime when Playwright isn't installed. Consumers hit either a runtime error or (worse) an ERESOLVE peer dependency conflict when trying to install Playwright as a workaround.

Fix

Changed static imports of chromium in playwright-runner.ts and fallback.ts to await import('@playwright/test') inside the function body — matching the existing pattern already used for esbuild in config/loader.ts.

Type-only imports (import type) remain static since TypeScript/esbuild erases them entirely.

Verification

dist/check.js now has zero references to @playwright/test:

grep 'playwright' packages/action/dist/check.js → 0 matches ✅

Why this is the right design

check-trigger's whole purpose is to be a cheap pre-check that skips heavy dependency installation. Requiring Playwright at load time defeats that entirely.

🤖 Generated with Claude Code

…ndle

Static imports of chromium from @playwright/test in playwright-runner.ts
and fallback.ts caused esbuild to emit require("@playwright/test") in
dist/check.js, even though check-trigger never uses Playwright.

Consumers running check-trigger without Playwright installed would hit
an ERESOLVE peer dependency conflict or runtime require failure.

Changed both imports to dynamic await import() inside the function body,
matching the existing pattern used for esbuild in config/loader.ts.
The type-only imports remain as import type (erased at compile time).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@DeDuckProject DeDuckProject merged commit 0f88b1e into main Mar 14, 2026
3 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.

1 participant