Companion v1.js is approaching 1500 lines — consider a split or bundler step
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 18/100
- Issue type
- Refactor
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- javascript
- Domain
- build-system
Research direction
The file in question is apps/api/src/companion/v1.js, which is an IIFE with section banners for anchors, Mermaid detection and Mermaid rendering. Start by finding where the build or serve step reads that file, since the two options are concatenation at serve time or an esbuild bundle. The issue asks for a decision first, so a newcomer should raise the choice with maintainers before splitting any code. Done means the chosen approach is agreed and the companion still runs unchanged in the sandboxed iframe.
Written by the indexing model from the issue text.
Description
Surfaced by: code review on #15 (Mermaid auto-rendering).
After landing Mermaid rendering, apps/api/src/companion/v1.js is at ~1500 lines. Still readable thanks to the section banners (── Anchor rendering ──, ── Mermaid detection ──, ── Mermaid rendering ──), but the next feature on the companion at this scale would push it into "hard to hold in context" territory.
The companion is plain ES2020 in an IIFE (no imports, no bundler) — intentional, because it runs in a sandboxed opaque-origin iframe and we want to keep the build surface minimal. Two reasonable paths if this becomes painful:
- Concatenation at serve time — keep authoring split across multiple
.jsfiles inapps/api/src/companion/(e.g.,anchors.js,mermaid.js,protocol.js), concatenate at build into a singlev1.js. No runtime change for artifacts. - Adopt an explicit bundler step (esbuild, already a build-time dep) — author as ES modules, output a single IIFE.
Not urgent — file at this size is still maintainable. Open this when the third "I added 200 lines to v1.js" PR appears.
- Dominant language
- TypeScript
- Stars
- 2
- Forks
- 1
- Avg merge
- 13h 38m
- Merged PRs (30d)
- 24
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from 0xPolygon/primer
-
triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Feature: @-mention people and agents in documents and comments; a mention notifies and subscribesOpen
Difficulty 5/5 Over a week Newbie friendliness 18/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
Maintainers usually reply within 1 day
-
Difficulty 3/5 Half a day Newbie friendliness 45/100
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
0xPolygon/primer#185 · 1 comment ·
Maintainers usually reply within 1 day
All issues in 0xPolygon/primer
Similar issues
-
P3
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
bug L3 level 1 needs-review wocs
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
SatyamPandey-07/WorkSphere#10739 · 1 comment ·
Maintainers usually reply within 1 day
-
maintenance
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
assistant-ui/assistant-ui#10946 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:auth-provider issue-rating: 🦞 diamond lobster no-stale P2
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
openclaw/openclaw#206303 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day