Repository navigation
feat(compiler): export the scoped-CSS engine from the Rust core, independent of TSRX - #4289
Conversation
Expose `solidjs_compiler::style` (behind the default `tsrx` feature): `compile_style`, `compile_style_with_class_map_selectors` and their input and output types. The engine already has no dependency on the TSRX frontend, so another frontend can describe a `<style>` block's elements as `Element` values and get the same stylesheet and hash a `.tsrx` file gets. Documents `StyleLocation`'s line/column bases, since they feed the hash. Additive: the TSRX route and the Node `transform()` are unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01ViozQ3kVSofMUQ3fwpyq5o
🦋 Changeset detectedLatest commit: 4d271cf The changes in this PR will be included in the next version bump. This PR includes changesets to release 15 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Size (brotli, eager entry chunk)
|
|
The Generated by Claude Code |
`src/tsrx/style/` becomes `src/style/`, exported as `solidjs_compiler::style` in every build: the engine never depended on TSRX, and a frontend that does not use TSRX should not need the `tsrx` feature to reach it. The TSRX projection and lowering now import it from `crate::style`. No behaviour change; the engine's unit tests now also run without the `tsrx` feature. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01ViozQ3kVSofMUQ3fwpyq5o
Coverage Report for CI Build 40292136222Warning No base build found for commit Coverage: 77.855%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsRequires a base build to compare against. How to fix this → Coverage Stats
💛 - Coveralls |
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
|
The Generated by Claude Code |
Requested by Ryan · project thread
What
This PR moves TSRX's scoped-CSS engine from
src/tsrx/style/tosrc/style/and exports it as a publicsolidjs_compiler::stylemodule in every build, without needing thetsrxfeature:compile_styleandcompile_style_with_class_map_selectorsStyleInput,StyleLocation,StyleKind,Element,ElementKind,ElementChild,Attribute,AttributeValue,StyleOutput,ClassMapEntryandStyleErrorThe engine already "deliberately has no dependency on the TSRX/Oxc frontend". A frontend describes the elements a
<style>block governs asElementvalues. It gets back the scoped stylesheet, its hash, the class map and the ids of the elements to annotate, which are the same bytes a.tsrxfile gets. TSRX becomes one caller of the engine among others.Why
ReactiveScript's Rust port (spec/11 CP-1d in ryansolid/reactivescript) reuses these style semantics for
.rxviews instead of reimplementing them. The port shouldn't depend on TSRX being present, so the engine moves out of the frontend that happened to host it.Changes
git mv src/tsrx/style src/style.lib.rsgainspub mod style;.tsrx/style_projection.rsandtsrx/lower.rsnow import fromcrate::style. The module doc is updated.StyleLocationnow documents the line and column bases it expects: a 1-based line and a 0-based UTF-16 column of the<styletag. Both feed the hash, so an external frontend has to match them.tests/style_engine.rs, which covers:tsrxenabled, parity: driving the engine directly gives exactly thecssandcss_hashthatcompile()returns for the equivalent.tsrxmodulepreserve_class_map_selectorsStyleError--no-default-featuresbuild too.There is no behaviour change. The TSRX route and the Node
transform()produce the same output.Notes for review
Element::nativeandwith_static_attrare still#[cfg(test)], so callers build anElementwith a struct literal. All of its fields are public.Testing
All of these are green locally:
cargo testin the three feature sets thetest:rustscript runs (default,--no-default-features, and--no-default-features --features tsrx)-D warningsfor each of those feature setscargo fmt --checkThe red
Sizecheck is pre-existing onnextand shows 0 B against base (see the comment below).🤖 Generated with Claude Code
https://claude.ai/code/session_01ViozQ3kVSofMUQ3fwpyq5o