Skip to content

Commit cbcf948

Browse files
committed
Merge remote-tracking branch 'origin/next' into compiler-compile-program
# Conflicts: # packages/compiler/README.md # packages/compiler/src/lib.rs
2 parents ac12a6b + 838b74b commit cbcf948

27 files changed

Lines changed: 423 additions & 130 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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solidjs/signals": patch
3+
---
4+
5+
A re-armed `Loading` boundary (`on`) whose fallback reads pending data through a render effect — any compiled JSX fallback, such as `<p>Meta {meta()}</p>` — no longer holds the new content's reveal when the content lands first: a fallback the screen never showed is disposed as soon as the content replaces it, so the content shows as soon as it lands and the fallback is never seen, as it already did when the fallback read the data directly (#4268).
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
@@ -212,6 +212,28 @@ let program = my_frontend::lower(&allocator, authored_source)?; // oxc_ast::ast:
212212
let output = compile_program(&allocator, program, authored_source, &CompileOptions::default())?;
213213
```
214214

215+
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.
216+
217+
```rust
218+
use solidjs_compiler::style::{compile_style, Element, ElementKind, StyleInput, StyleKind, StyleLocation};
219+
220+
let elements = [Element {
221+
id: 1,
222+
kind: ElementKind::Native("div".into()),
223+
attributes: Vec::new(),
224+
has_spread: false,
225+
children: Vec::new(),
226+
}];
227+
let output = compile_style(StyleInput {
228+
css: "div { color: red }",
229+
location: StyleLocation { filename: "view.rx", line: 3, column: 4 },
230+
elements: &elements,
231+
kind: StyleKind::Block,
232+
minify: false,
233+
})?;
234+
// output.css, output.hash, output.class_map, output.scoped_elements
235+
```
236+
215237
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.
216238

217239
> **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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
//!
99
//! # Stability
1010
//!
11-
//! The Rust API (`compile`, `compile_program`, [`CompileOptions`], [`CompileOutput`],
12-
//! [`CompileError`]) is **unstable**. The compiler is pre-1.0 and under
11+
//! The Rust API (`compile`, `compile_program`, [`style`], [`CompileOptions`],
12+
//! [`CompileOutput`], [`CompileError`]) is **unstable**. The compiler is pre-1.0 and under
1313
//! active development; this surface carries no semver commitment and may
1414
//! change shape in any release while the compiler churns. Pin an exact
1515
//! revision when embedding it. The Node `transform()` interface remains the
@@ -32,6 +32,7 @@ mod shared;
3232
#[cfg(feature = "node")]
3333
mod source_names;
3434
mod ssr;
35+
pub mod style;
3536
#[cfg(feature = "tsrx")]
3637
mod tsrx;
3738
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)