Skip to content

fix(md): tolerate trailing comma in markdown island imports - #223

Merged
Brooooooklyn merged 2 commits into
mainfrom
fix/md-island-trailing-comma
Jun 30, 2026
Merged

Brooooooklyn merged 2 commits into
mainfrom
fix/md-island-trailing-comma

Conversation

@hyfdev

@hyfdev hyfdev commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Markdown island pages now hydrate correctly when the island import uses a trailing comma (or a $/_-prefixed component name) — instead of silently rendering static and leaking an orphan import into the client bundle.

The bug

The markdown compiler's island-import regexes in packages/md/src/extract-script.ts didn't tolerate a trailing comma in the import attributes and only matched \w+ component names:

<script>
import Counter from "./Counter.vue" with { island: "load", }
</script>

When the regex failed to match, extractScript returned no islandImports, so plugin.ts took the non-island branch (emit*Component) — the component rendered as static markup with no client hydration — and the un-stripped import line leaked into the client bundle as an orphan import. This affects all four adapters, since packages/md is the shared markdown parser for .md pages.

Expected-correct behavior

A trailing comma is valid syntax (and routinely auto-inserted by formatters like Prettier), and $/_-prefixed names are valid identifiers (the islands docs themselves use a _Counter example). Both should be parsed as islands.

Root cause

The identical island-import fix already landed for all four adapter plugins and void/pages/islands-plugin.ts in commit 3307e6fc ("fix: Island import attributes with trailing commas"), but the parallel markdown parser was missed. This change mirrors that fix on the one file it didn't reach.

The fix

In both ISLAND_IMPORT_RE (extraction) and ISLAND_IMPORT_LINE_RE (line-strip): allow an optional trailing comma (,?\s* before }) and widen the component name to [$_A-Za-z][$_\w]*, byte-identical to the merged adapter regex.

Tests

Regression tests added in extract-script.test.ts: a trailing-comma island import and a $-prefixed name — both fail on origin/main and pass after; existing cases unchanged (and with { island: "x", } only tolerates a single trailing comma, not a second attribute). Local gate: extract-script.test.ts 13/13; full --project unit zero-collateral vs a clean origin/main baseline; lint + fmt clean. (packages/md typecheck hits a pre-existing void/pages build-artifact resolution error unrelated to this regex change; CI's build:all resolves it.)

Verified extract-script.ts is the only remaining island-import regex without the trailing-comma fix.

Prepared with AI assistance.

The island-import regexes in the markdown compiler did not allow a
trailing comma in the import attributes (`with { island: "load", }`)
and only matched component names of the form \w+. A markdown page using
either form silently fell through to the non-island branch: the
component rendered as static markup with no client hydration, and the
un-stripped import leaked into the client bundle as an orphan import.

The same island-import fix already landed for all four adapter plugins
and void/pages/islands-plugin.ts (commit 3307e6f), but the parallel
markdown parser (shared by every adapter for .md pages) was missed.
Mirror it here: allow an optional trailing comma and a $/_-leading
component name in both the extraction and line-strip regexes.
@netlify

netlify Bot commented Jun 18, 2026 •

Copy link
Copy Markdown

❌ Deploy Preview for staging-void-cloud failed.

Name Link
🔨 Latest commit 86aef7a
🔍 Latest deploy log https://app.netlify.com/projects/staging-void-cloud/deploys/6a33ef0c02575400085cbea8

@hyfdev
hyfdev marked this pull request as ready for review June 18, 2026 13:21
@Brooooooklyn
Brooooooklyn merged commit bf7f5d9 into main Jun 30, 2026
6 checks passed
@Brooooooklyn
Brooooooklyn deleted the fix/md-island-trailing-comma branch June 30, 2026 03:40
cpojer pushed a commit that referenced this pull request Sep 11, 2026
)

The lint-and-check CI job failed at `vp run check`: the platform root
resolved hono@4.12.27 while the framework submodule pins ^4.12.18, so the
dashboard's CloudContext (typed against 4.12.18) was no longer assignable
to the platform's 4.12.27 Context (TS2345 — 4.12.27's HonoRequest adds
`bytes`/`[GET_MATCH_RESULT]`).

This is a recurring renovate regression: #200 first bumped it, #204
pinned it back with a warning comment, and #218 bumped it again past the
comment. Comments don't stop renovate, so:

- re-pin catalog hono to 4.12.18 (lockstep with the submodule) + lockfile
- disable renovate for hono in .github/renovate.json — it's now manually
  managed to track the framework submodule's hono

Verified locally: `vp run check`, `vp lint`, `vp fmt --check` all pass.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

2 participants