Skip to content

refactor(extension): split src/mergify.js into ES modules with esbuild bundle#398

Open
jd wants to merge 1 commit intomainfrom
devs/jd/worktree-leverage-json/split-src-mergify-js-es-modules-esbuild-bundle--0ff58889
Open

refactor(extension): split src/mergify.js into ES modules with esbuild bundle#398
jd wants to merge 1 commit intomainfrom
devs/jd/worktree-leverage-json/split-src-mergify-js-es-modules-esbuild-bundle--0ff58889

Conversation

@jd
Copy link
Copy Markdown
Member

@jd jd commented Apr 30, 2026

Splits the monolithic 2500-line src/mergify.js into focused modules
(logo, debug, dom, cache, timestamps, queue, stacks) and adds an
esbuild step that bundles them back into the single
dev-build/mergify.js the Manifest V3 content script declares. No
behavior change. Tests use Jest with @swc/jest to handle the ESM
imports.

src/mergify.js becomes a small orchestrator that wires the
MutationObserver, the URL-change reset, and the tryInject loop, and
re-exports everything for the test suite (which keeps importing from
"../mergify").

Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com

@jd
Copy link
Copy Markdown
Member Author

jd commented Apr 30, 2026

This pull request is part of a Mergify stack:

# Pull Request Link
1 refactor(extension): split src/mergify.js into ES modules with esbuild bundle #398 👈
2 fix(extension): resolve sticky-offset overlap, Files-tab discovery, and missed PR-feedback fixes #401
3 chore(extension): drop per-tick debug logs that flood console on diff pages #402

@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 30, 2026 08:04 Failure
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Apr 30, 2026

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🔴 Required Reviews

Waiting for:

  • #approved-reviews-by >= 2
This rule is failing.
  • any of:
    • #approved-reviews-by >= 2
    • author = dependabot[bot]

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert|ui)(?:\(.+\))?:

🟢 🔎 Reviews

Wonderful, this rule succeeded.
  • #changes-requested-reviews-by = 0
  • #review-requested = 0
  • #review-threads-unresolved = 0

🟢 📕 PR description

Wonderful, this rule succeeded.
  • body ~= (?ms:.{48,})

@jd jd marked this pull request as ready for review April 30, 2026 08:43
Base automatically changed from devs/jd/worktree-leverage-json/show-mergify-stacks-panel-prev-next-nav-pr-pages--04449ee2 to main April 30, 2026 08:47
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Apr 30, 2026

@jd this pull request is now in conflict 😩

@mergify mergify Bot added the conflict label Apr 30, 2026
@jd jd force-pushed the devs/jd/worktree-leverage-json/split-src-mergify-js-es-modules-esbuild-bundle--0ff58889 branch from 5534e96 to 105e509 Compare April 30, 2026 09:08
@jd
Copy link
Copy Markdown
Member Author

jd commented Apr 30, 2026

Revision history

# Type Changes Reason Date
1 initial 5534e96 2026-04-30 09:08 UTC
2 rebase 5534e96 → 105e509 2026-04-30 09:08 UTC
3 content 105e509 → 815ac3c 2026-05-04 09:37 UTC
4 content 815ac3c → ce65d4f 2026-05-04 11:25 UTC

@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 30, 2026 09:09 Failure
@mergify mergify Bot removed the conflict label Apr 30, 2026
@mergify mergify Bot requested a review from a team April 30, 2026 09:10
JulianMaurin
JulianMaurin previously approved these changes Apr 30, 2026
Copilot AI review requested due to automatic review settings May 4, 2026 09:37
@jd jd force-pushed the devs/jd/worktree-leverage-json/split-src-mergify-js-es-modules-esbuild-bundle--0ff58889 branch from 105e509 to 815ac3c Compare May 4, 2026 09:37
@mergify mergify Bot dismissed JulianMaurin’s stale review May 4, 2026 09:37

Pull request has been modified.

@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 4, 2026 09:37 Failure
@mergify mergify Bot requested a review from a team May 4, 2026 09:38
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the extension content script by splitting the previously monolithic src/mergify.js into focused ES modules and bundling them back into a single MV3-compatible content script via esbuild, while updating Jest to run against the new module structure.

Changes:

  • Split core functionality into dedicated modules (cache, debug, dom, logo, queue, stacks, timestamps) and make src/mergify.js a small orchestrator/re-export hub.
  • Add an esbuild bundling step in the Makefile to produce dev-build/mergify.js / build/mergify.js from the module graph.
  • Update Jest configuration to transform ESM-style modules using @swc/jest, plus dependency updates.

Reviewed changes

Copilot reviewed 12 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/timestamps.js Timestamp conversion extracted into a dedicated module.
src/stacks.js Stack/revision context panel + stack nav logic moved into its own module.
src/queue.js Queue state detection, polling, and merge-box UI extracted into a module.
src/mergify.js New orchestrator wiring page observers/injection; re-exports modules for tests.
src/logo.js Logo SVG constants + parsing helper extracted.
src/dom.js DOM utilities and selectors extracted (PR parsing, status reading, etc.).
src/debug.js Debug flag + logger extracted behind window.__MERGIFY_DEBUG__.
src/cache.js Storage-backed caches extracted (MergifyCache, PrStatusCache).
src/tests/mergify.test.js Adjusted a cache-related test to assert no fetch occurs when cached.
package.json Added esbuild, @swc/core, @swc/jest dev dependencies.
package-lock.json Lockfile updates for new tooling dependencies.
Makefile Build now bundles via esbuild instead of copying src/ wholesale.
jest.config.js Added SWC transform so Jest can execute the refactored module code.
biome.json Narrowed/updated Biome include globs for the new layout/tools.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/mergify.js Outdated
…d bundle

Splits the monolithic 2500-line src/mergify.js into focused modules
(logo, debug, dom, cache, timestamps, queue, stacks) and adds an
esbuild step that bundles them back into the single
dev-build/mergify.js the Manifest V3 content script declares. No
behavior change. Tests use Jest with @swc/jest to handle the ESM
imports.

src/mergify.js becomes a small orchestrator that wires the
MutationObserver, the URL-change reset, and the tryInject loop, and
re-exports everything for the test suite (which keeps importing from
"../mergify").

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Change-Id: I0ff58889ac6d8adcd60d4f9660d3f2dbf8e006ac
@jd jd force-pushed the devs/jd/worktree-leverage-json/split-src-mergify-js-es-modules-esbuild-bundle--0ff58889 branch from 815ac3c to ce65d4f Compare May 4, 2026 11:25
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 4, 2026 11:26 Failure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants