Commit e9b0394
committed
Introduce
This PR introduces `@codama/fragments`, a public package for composing generated source code. A `Fragment` is a snippet of code paired with the imports it depends on; fragments compose through tagged templates that propagate both content and imports, so generators can build code top-down without threading imports manually. The package consolidates what the existing renderers (`@codama/renderers-js`, `@codama/renderers-rust`, `@codama/renderers-rust-cpi`, `@codama/renderers-demo`) have each been duplicating in their own `src/utils/`.
Three subpaths are exposed: the root entrypoint ships only the language-agnostic primitives (`BaseFragment`, `createFragmentTemplate`, `mapFragmentContent`, `setFragmentContent`); `@codama/fragments/javascript` and `@codama/fragments/rust` each layer on a concrete `Fragment` type, an `ImportMap` shape suited to the language, and the helpers needed to build, merge, resolve, and stringify imports. Both flavors are immutable, frozen, and free-function-based. As part of this change, `@codama/renderers-core` gets a patch bump: its `src/fragment.ts` becomes a named re-export from `@codama/fragments`, so existing importers see the same names at the same path with no behavior change. Sister renderers keep their own `importMap.ts` and `fragment.ts` for now and can migrate to `@codama/fragments` in subsequent PRs.@codama/fragments with JavaScript and Rust subpaths1 parent a753939 commit e9b0394
69 files changed
Lines changed: 3789 additions & 246 deletions
File tree
- .changeset
- packages
- fragments
- src
- core
- javascript
- rust
- types
- test
- core
- javascript
- rust
- types
- renderers-core
- src
- test
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
0 commit comments