Skip to content

web/playground: source BUG examples from @ethdebug/bugc/examples#250

Merged
gnidan merged 1 commit into
mainfrom
ui-dry-examples
Jul 12, 2026
Merged

web/playground: source BUG examples from @ethdebug/bugc/examples#250
gnidan merged 1 commit into
mainfrom
ui-dry-examples

Conversation

@gnidan

@gnidan gnidan commented Jul 12, 2026

Copy link
Copy Markdown
Member

Both playgrounds showed BUG programs maintained separately from the
canonical .bug files under packages/bugc/examples — the docs
BugPlayground had no example picker, and the standalone playground
loaded sources with a Vite import.meta.glob(...?raw) that only works
under Vite. Neither stayed in step with the sources bugc actually tests.

Both now consume the shared @ethdebug/bugc/examples map, which ships
the canonical sources as inlined string literals so webpack (docs) and
Vite (playground) can import them without a filesystem glob. Curation
stays consumer-side — each keeps a small list picking which examples to
show, their labels, and (playground) their category — and applies
stripTestAnnotations so the editor shows clean source without bugc's
inline @test / @expect directives.

  • docs BugPlayground: adds an example selector (curated trio: an
    owned counter, functions, arrays & loops), shown when the embed hasn't
    pinned a program via initialCode.
  • standalone playground: drops import.meta.glob; same curated,
    categorized set, now keyed by canonical example path.
  • unit coverage that the curated sets resolve to real sources, strip
    clean, and compile to bytecode.

One deliberate behavior change worth a look in review: the standalone
playground previously rendered raw sources, so @test annotation blocks
were visible in its editor. It now strips them (same as the docs
selector), which is why the playground's examples.ts calls
stripTestAnnotations. Easy to drop that one call if you'd rather it
keep showing raw.

Supersedes the earlier hand-inlined selector (#247).

Both playgrounds showed BUG programs that were maintained separately
from the canonical `.bug` files under packages/bugc/examples: the docs
BugPlayground had no example picker at all, and the standalone
playground reached across packages with a Vite `import.meta.glob(...
?raw)` that only works under Vite. Neither stayed in step with the
sources bugc actually tests.

Both now import the shared `@ethdebug/bugc/examples` map, which ships
the canonical sources as inlined string literals so webpack (docs) and
Vite (playground) consume them without a filesystem glob. Each consumer
keeps a small curated list — which examples to show, their labels, and
(for the playground) their category — and applies `stripTestAnnotations`
so the editor shows clean source without bugc's inline `@test`/`@expect`
directives.

- docs BugPlayground: add an example selector (curated trio: an owned
  counter, functions, arrays & loops), shown when the embed hasn't
  pinned a specific program via `initialCode`.
- standalone playground: drop `import.meta.glob`; keep the same curated,
  categorized set, now keyed by canonical example path.
- unit coverage that the curated sets resolve to real sources, strip
  clean, and compile to bytecode.
@github-actions

github-actions Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-07-12 21:18 UTC

@gnidan gnidan merged commit b018789 into main Jul 12, 2026
4 checks passed
@gnidan gnidan deleted the ui-dry-examples branch July 12, 2026 21:14
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.

1 participant