Skip to content

Commit ed565ec

Browse files
authored
Merge branch 'next' into claude/project-thread-nvr82l
2 parents 4dbd036 + 838b74b commit ed565ec

23 files changed

Lines changed: 262 additions & 93 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solidjs/compiler": patch
3+
---
4+
5+
The Rust compiler core exports TSRX's scoped-CSS engine as `solidjs_compiler::style`, moved from `src/tsrx/style/` to `src/style/` so it is available without the `tsrx` feature: `compile_style`, `compile_style_with_class_map_selectors`, and their input and output types (`StyleInput`, `StyleLocation`, `StyleKind`, `Element`, `ElementKind`, `ElementChild`, `Attribute`, `AttributeValue`, `StyleOutput`, `ClassMapEntry`, `StyleError`). The engine already had no dependency on the TSRX frontend; exporting it lets another frontend (one that does not use TSRX at all) scope a `<style>` block over its own elements and get the same stylesheet and hash a `.tsrx` file gets. Additive and Rust-only: the TSRX route and the Node `transform()` are unchanged.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@solidjs/signals": patch
3+
"solid-js": patch
4+
---
5+
6+
Smaller bundles: builds without the optimistic-store, reveal-order or lane hook modules drop their dead branches, and the #4273/#4275 fixes share existing paths.

‎packages/compiler/README.md‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,28 @@ let virtual_tsx =
201201

202202
`CompileOptions::default()` uses `module_name: "@solidjs/web"` and the same control-flow `built_ins` as the Babel plugin. Build with `--no-default-features` when embedding without the Node-API adapter.
203203

204+
TSRX's scoped-CSS engine is exported as `solidjs_compiler::style` for other frontends, in every build (it does not need the `tsrx` feature). It has no dependency on TSRX syntax or Oxc: describe the elements a `<style>` block governs as `Element` values, and `compile_style` returns the scoped stylesheet, its hash, the class map and the ids of the elements to annotate, the same bytes a `.tsrx` file with that stylesheet at that `StyleLocation` gets.
205+
206+
```rust
207+
use solidjs_compiler::style::{compile_style, Element, ElementKind, StyleInput, StyleKind, StyleLocation};
208+
209+
let elements = [Element {
210+
id: 1,
211+
kind: ElementKind::Native("div".into()),
212+
attributes: Vec::new(),
213+
has_spread: false,
214+
children: Vec::new(),
215+
}];
216+
let output = compile_style(StyleInput {
217+
css: "div { color: red }",
218+
location: StyleLocation { filename: "view.rx", line: 3, column: 4 },
219+
elements: &elements,
220+
kind: StyleKind::Block,
221+
minify: false,
222+
})?;
223+
// output.css, output.hash, output.class_map, output.scoped_elements
224+
```
225+
204226
The unstable Rust typecheck projection reports embedded ranges in authored UTF-8 bytes. The N-API adapter converts those ranges to UTF-16 code units for JavaScript tooling.
205227

206228
> **Stability:** the Rust API is unstable while the compiler is pre-1.0. Options, output, and error types may change in any release — pin an exact revision when embedding it.

‎packages/compiler/src/lib.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//!
88
//! # Stability
99
//!
10-
//! The Rust API (`compile`, [`CompileOptions`], [`CompileOutput`],
10+
//! The Rust API (`compile`, [`style`], [`CompileOptions`], [`CompileOutput`],
1111
//! [`CompileError`]) is **unstable**. The compiler is pre-1.0 and under
1212
//! active development; this surface carries no semver commitment and may
1313
//! change shape in any release while the compiler churns. Pin an exact
@@ -31,6 +31,7 @@ mod shared;
3131
#[cfg(feature = "node")]
3232
mod source_names;
3333
mod ssr;
34+
pub mod style;
3435
#[cfg(feature = "tsrx")]
3536
mod tsrx;
3637
mod universal;
File renamed without changes.
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
1-
//! Self-contained TSRX scoped-CSS semantics.
1+
//! Scoped-CSS semantics: TSRX's `<style>` engine, shared by any frontend.
22
//!
3-
//! This module deliberately has no dependency on the TSRX/Oxc frontend. The
4-
//! frontend only needs to translate its template into [`Element`] values.
3+
//! This module deliberately has no dependency on the TSRX/Oxc frontend or on
4+
//! the `tsrx` feature. A frontend describes the elements a `<style>` block
5+
//! governs as [`Element`] values; [`compile_style`] returns the scoped
6+
//! stylesheet, its hash, the class map, and which elements to annotate with
7+
//! the hash: the same bytes a `.tsrx` file with that stylesheet at that
8+
//! [`StyleLocation`] gets.
59
610
use std::collections::{BTreeMap, BTreeSet};
711
use std::fmt;
812

13+
/// Where the `<style>` element starts in its module. Part of the scope hash,
14+
/// so the same stylesheet at the same position hashes the same everywhere.
915
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
1016
pub struct StyleLocation<'a> {
1117
pub filename: &'a str,
18+
/// 1-based line of the `<style` opening tag.
1219
pub line: u32,
20+
/// 0-based column of the `<style` opening tag, in UTF-16 code units.
1321
pub column: u32,
1422
}
1523

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)