Skip to content

Add fragment composition support for JS::File#35

Merged
sbsoftware merged 2 commits intoreleases/v1.8.0from
feature/JS-49
Feb 19, 2026
Merged

Add fragment composition support for JS::File#35
sbsoftware merged 2 commits intoreleases/v1.8.0from
feature/JS-49

Conversation

@sbsoftware-agent
Copy link
Collaborator

Summary

Adds fragment composition to JS::File so multiple independent JS contributions can be appended into a single file output in deterministic order, including reopen-style class usage.

Changes

  • Added a new js_fragment macro on JS::File for explicit fragment contribution.
  • Refactored JS::File emission to:
  • keep js_class and js_function output,
  • append registered fragments in declaration order.
  • Kept def_to_js compatible by routing it through the same fragment registration path.
  • Updated JS::Module output wrapping to use super(io) for compatibility with the new file-level composition flow.
  • Added specs in spec/js/file/fragment_composition_spec.cr to cover:
  • deterministic ordering of multiple fragments,
  • reopen-style fragment contribution ordering,
  • compatibility when combining js_function, js_fragment, and def_to_js.

Validation

  • crystal tool format --check src spec
  • CRYSTAL_CACHE_DIR=/tmp/.crystal-cache-js crystal spec (56 examples, 0 failures)

@sbsoftware sbsoftware merged commit 1a7e7cc into releases/v1.8.0 Feb 19, 2026
@sbsoftware sbsoftware deleted the feature/JS-49 branch February 19, 2026 21:48
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.

2 participants