Add build system with tsdown bundling and bun compilation#24
Closed
Add build system with tsdown bundling and bun compilation#24
Conversation
Build produces three artifacts: - dist/cli.mjs — bundled JS (node, no node_modules needed except @playwright/test) - dist/bin/visual-regression-linux-x64 — native Linux x64 binary - dist/bin/visual-regression-linux-x64-baseline — native Linux x64-baseline binary All source modules and commander are inlined. Playwright remains external. Run: npm run build (full) or npm run build:bundle (JS only). https://claude.ai/code/session_01A8PnM2zTwEDYPPmiW3gQgk
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
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.
Summary
This PR introduces a complete build system for the visual regression CLI, enabling bundling with tsdown and compilation to native binaries using bun. The changes support both development (TypeScript) and production (bundled/compiled) modes.
Key Changes
Added tsdown bundler configuration (
tsdown.config.ts): Bundles the CLI and Playwright test files into ESM format, with commander bundled inline and Playwright kept external for runtime resolution.Added build script (
scripts/build.sh): Two-step build process:Updated CLI entry point (
src/cli.ts):#!/usr/bin/env tsxto#!/usr/bin/nodefor compiled binary compatibility.mjsfiles and compiled binariesAdded config resolution helpers:
src/generate-visual-baseline.ts: Resolves Playwright generation config in both bundled and dev modessrc/run-visual-tests.ts: Resolves Playwright config dynamically based on execution contextUpdated Playwright configuration (
playwright.config.ts): Made test file matching dynamic to support both.ts(dev) and.mjs(bundled) extensionsUpdated package.json:
tsdownas dev dependencybuild,build:bundle, andtest:buildUpdated init-config template (
src/init-config.ts): Removed type import requirement and simplified config structure for better user experienceImplementation Details
The build system intelligently detects execution context:
.mjsfiles from dist/ directoryConfig file resolution uses a fallback chain to support all three modes, checking bundled paths first, then dev paths, then CWD.
https://claude.ai/code/session_01A8PnM2zTwEDYPPmiW3gQgk