bugc: expose canonical BUG examples via a subpath export#249
Merged
Conversation
The .bug files under packages/bugc/examples are bugc's canonical example programs and double as its behavioral test fixtures. Rendering them elsewhere meant copying sources by hand or globbing the raw files, which webpack-based bundlers can't do. Expose them through a new @ethdebug/bugc/examples subpath export: - A build step (bin/generate-examples.js) reads the .bug files and emits src/examples/generated.ts, a source-by-path map — the same generated module pattern as @ethdebug/format's schema yamls. The generated file is gitignored and (re)produced by prepare. - src/examples/index.ts surfaces exampleSources, examplePaths, and stripTestAnnotations(), which removes the inline /*@test*/ blocks and // @wip / // @Skip / // @expect-* directives the raw files carry so a source reads cleanly in an editor. - Adds a package exports map (root "." plus "./examples"); the internal #-imports are a separate field and are unaffected. Stripping is purely cosmetic: the tests confirm a stripped example compiles to byte-identical bytecode as its raw counterpart.
Contributor
|
The root build calls tsc --build directly and bypasses each package's prepare script, so add the examples generate step alongside the existing schema-yamls step. This keeps the generated module current on the standalone yarn build / yarn start paths, which don't reinstall.
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.
The
.bugfiles underpackages/bugc/examplesare bugc's canonicalexample programs and double as its behavioral test fixtures. Rendering
them anywhere else meant copying sources by hand or globbing the raw
files — which webpack-based bundlers can't do.
This exposes them through a new
@ethdebug/bugc/examplessubpath export.bin/generate-examples.js) reads the.bugfiles andemits
src/examples/generated.ts, a source-by-path map, using the samegenerated-module pattern as
@ethdebug/format's schemayamls.ts. Thegenerated file is gitignored and (re)produced by
prepare, so it existsafter install and ships in
dist.src/examples/index.tssurfacesexampleSources,examplePaths, andstripTestAnnotations(), which strips the inline/*@test*/blocks and// @wip/// @skip/// @expect-*directives the raw files carry soa source reads cleanly in an editor. Which examples to show, and how to
label them, is left to each consumer.
exportsmap (root.plus./examples). The internal#-imports are a separate field and are unaffected; nothing in the repodeep-imports bugc.
The canonical
.bugfiles remain the single source of truth and thebehavioral tests are unchanged. Stripping is purely cosmetic: the tests
confirm a stripped example compiles to byte-identical bytecode as its raw
counterpart.