Skip to content

refactor: Remove type-unsafe cast in TreeShaking test normalization - #14

Merged
miccy merged 3 commits into
sync/merge-upstream-03-02-26from
copilot/fix-web-tests-and-flakiness
Feb 3, 2026
Merged

refactor: Remove type-unsafe cast in TreeShaking test normalization#14
miccy merged 3 commits into
sync/merge-upstream-03-02-26from
copilot/fix-web-tests-and-flakiness

Conversation

Copilot AI commented Feb 3, 2026

Copy link
Copy Markdown

Summary

Refactored TreeShaking test to eliminate as any cast that bypassed readonly interface contract during bundle size normalization.

Changes

TreeShaking.test.ts

  • Extracted normalization logic into pure normalizeBundleSize() function
  • Returns new BundleSize object instead of mutating readonly properties
  • Added JSDoc explaining environmental variance rationale (Webpack minifier differences across Node versions)

Before:

// Violates readonly contract
(results["task-example"] as any).gzip = 5650;
(results["task-example"] as any).raw = 15130;

After:

const normalizeBundleSize = (size: BundleSize): BundleSize => {
  let { gzip, raw } = size;
  if (gzip >= 5640 && gzip <= 5650) gzip = 5650;
  if (raw >= 15125 && raw <= 15135) raw = 15130;
  return { gzip, raw };
};

results["task-example"] = normalizeBundleSize(results["task-example"]);

Code Review Documentation

  • Added CODE_REVIEW_SUMMARY.md documenting structured concurrency integration analysis
  • Verified event listener cleanup across all platforms (web, Node.js, React Native)
  • Confirmed @vitest/coverage-v8 alignment at ^4.0.18 across packages
  • No regressions identified in React Native compatibility
Original prompt

Role: Senior Software Engineer & Release Manager
Context:
I am working in the SQLoot/evolu-plan-b monorepo (fork of evoluhq/evolu). We are in the middle of a major migration to Bun (replacing pnpm) and Biome (replacing ESLint/Prettier).
Current State:

  • Source Branch: sync/merge-upstream-03-02-26 (Currently checked out)
  • Target Branch: sync/bun-migration
  • Work Done:
    1. Merged upstream/common-v8 which introduced structured concurrency changes (createRunner).
    2. Resolved conflicts in Task.ts (Web, Node, Common).
    3. Fixed TreeShaking.test.ts flakiness by normalizing bundle size snapshots.
    4. Fixed packages/web tests by properly creating browser-like runners.
    5. Aligned @vitest/coverage-v8 versions across the monorepo to satisfy sherif linting.
    6. Verified that bun verify (build, test, lint, format) passes locally.
      Objective:
      Your goal is to finalize this integration by creating a Pull Request and performing a deep Code Review.
      Instructions:
  1. Verify Local State:
    • Double check that bun verify passes in the current environment.
  2. Create Pull Request:
    • Create a PR merging sync/merge-upstream-03-02-26 into sync/bun-migration.
    • Title: "chore(sync): Merge upstream/common-v8 & Fix Verification"
    • Description: Detail the conflict resolutions, the TreeShaking test normalization strategy, and the platform-specific createRunner implementations. Mention the dependency alignment for sherif.
  3. Perform Code Review (CR):
    • Focus on Task.ts: Verify that the createRunner implementation in packages/web/src/Task.ts correctly handles event listener cleanup (abort signals).
    • Focus on TreeShaking.test.ts: Review the normalization logic. Is casting to any to bypass read-only properties acceptable here, or is there a safer way?
    • Dependencies: Check if the update to @vitest/coverage-v8 to ^4.0.18 introduces any peer dependency warnings we missed.
    • General: Look for any potential regressions in packages/common that could affect the React Native implementation.
  4. Output:
    • If you find issues during the CR, list them as "Critical" (must fix) or "Suggestion" (nice to have).
    • If the PR creation is successful, provide the link.
      Constraint:
      Be critical. Do not assume my changes are perfect just because the build passes.

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@miccy miccy linked an issue Feb 3, 2026 that may be closed by this pull request
@miccy miccy added upstream Needs cherry-pick or merge from upstream feat New feature or request fix Repair any bug labels Feb 3, 2026
Copilot AI and others added 2 commits February 3, 2026 15:50
Co-authored-by: miccy <9729864+miccy@users.noreply.github.com>
Co-authored-by: miccy <9729864+miccy@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix flakiness in TreeShaking tests and resolve web test issues refactor: Remove type-unsafe cast in TreeShaking test normalization Feb 3, 2026
Copilot AI requested a review from miccy February 3, 2026 15:54
@miccy
miccy marked this pull request as ready for review February 3, 2026 15:59
@coderabbitai

coderabbitai Bot commented Feb 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review

Comment @coderabbitai help to get the list of available commands and usage tips.

@miccy
miccy merged commit 358cb8b into sync/merge-upstream-03-02-26 Feb 3, 2026
2 checks passed
@miccy
miccy deleted the copilot/fix-web-tests-and-flakiness branch February 3, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat New feature or request fix Repair any bug upstream Needs cherry-pick or merge from upstream

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sync upstream/common-v8 (new commits)

2 participants