Repository navigation
fix(md): tolerate trailing comma in markdown island imports - #223
Merged
Merged
Conversation
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.
❌ Deploy Preview for staging-void-cloud failed.
|
hyfdev
marked this pull request as ready for review
June 18, 2026 13:21
Brooooooklyn
approved these changes
Jun 30, 2026
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>
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.
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.tsdidn't tolerate a trailing comma in the import attributes and only matched\w+component names:When the regex failed to match,
extractScriptreturned noislandImports, soplugin.tstook 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, sincepackages/mdis the shared markdown parser for.mdpages.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_Counterexample). 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.tsin commit3307e6fc("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) andISLAND_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 onorigin/mainand pass after; existing cases unchanged (andwith { island: "x", }only tolerates a single trailing comma, not a second attribute). Local gate:extract-script.test.ts13/13; full--project unitzero-collateral vs a cleanorigin/mainbaseline; lint + fmt clean. (packages/mdtypecheck hits a pre-existingvoid/pagesbuild-artifact resolution error unrelated to this regex change; CI'sbuild:allresolves it.)Verified
extract-script.tsis the only remaining island-import regex without the trailing-comma fix.Prepared with AI assistance.