web/playground: source BUG examples from @ethdebug/bugc/examples#250
Merged
Conversation
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.
Contributor
|
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.
Both playgrounds showed BUG programs maintained separately from the
canonical
.bugfiles underpackages/bugc/examples— the docsBugPlayground had no example picker, and the standalone playground
loaded sources with a Vite
import.meta.glob(...?raw)that only worksunder Vite. Neither stayed in step with the sources bugc actually tests.
Both now consume the shared
@ethdebug/bugc/examplesmap, which shipsthe 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
stripTestAnnotationsso the editor shows clean source without bugc'sinline
@test/@expectdirectives.owned counter, functions, arrays & loops), shown when the embed hasn't
pinned a program via
initialCode.import.meta.glob; same curated,categorized set, now keyed by canonical example path.
clean, and compile to bytecode.
One deliberate behavior change worth a look in review: the standalone
playground previously rendered raw sources, so
@testannotation blockswere visible in its editor. It now strips them (same as the docs
selector), which is why the playground's
examples.tscallsstripTestAnnotations. Easy to drop that one call if you'd rather itkeep showing raw.
Supersedes the earlier hand-inlined selector (#247).