@solidjs/compiler 2.0.0-rc.18 → 2.0.0-rc.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +33 -0
  2. package/package.json +7 -7
package/README.md CHANGED
@@ -201,6 +201,39 @@ let virtual_tsx =
201
201
 
202
202
  `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.
203
203
 
204
+ A frontend that builds its own Oxc AST instead of source text hands the program to `compile_program`, which runs the same back ends `compile` reaches after parsing. The program must be allocated in the allocator passed beside it, and `source` must be its `source_text`: the authored text its spans index, so source maps and diagnostics land on authored positions (keep authored spans on carried-over nodes and leave synthesized nodes at `SPAN`). The caller must build against the same Oxc release as this crate.
205
+
206
+ ```rust
207
+ use oxc_allocator::Allocator;
208
+ use solidjs_compiler::{compile_program, CompileOptions};
209
+
210
+ let allocator = Allocator::default();
211
+ let program = my_frontend::lower(&allocator, authored_source)?; // oxc_ast::ast::Program
212
+ let output = compile_program(&allocator, program, authored_source, &CompileOptions::default())?;
213
+ ```
214
+
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
+
204
237
  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.
205
238
 
206
239
  > **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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@solidjs/compiler",
3
3
  "description": "Solid's native Oxc JSX compiler",
4
- "version": "2.0.0-rc.18",
4
+ "version": "2.0.0-rc.19",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -62,11 +62,11 @@
62
62
  "emnapi": "^1.11.3"
63
63
  },
64
64
  "optionalDependencies": {
65
- "@solidjs/compiler-darwin-x64": "2.0.0-rc.18",
66
- "@solidjs/compiler-darwin-arm64": "2.0.0-rc.18",
67
- "@solidjs/compiler-linux-x64-gnu": "2.0.0-rc.18",
68
- "@solidjs/compiler-linux-arm64-gnu": "2.0.0-rc.18",
69
- "@solidjs/compiler-win32-x64-msvc": "2.0.0-rc.18",
70
- "@solidjs/compiler-wasm32-wasi": "2.0.0-rc.18"
65
+ "@solidjs/compiler-darwin-x64": "2.0.0-rc.19",
66
+ "@solidjs/compiler-darwin-arm64": "2.0.0-rc.19",
67
+ "@solidjs/compiler-linux-x64-gnu": "2.0.0-rc.19",
68
+ "@solidjs/compiler-linux-arm64-gnu": "2.0.0-rc.19",
69
+ "@solidjs/compiler-win32-x64-msvc": "2.0.0-rc.19",
70
+ "@solidjs/compiler-wasm32-wasi": "2.0.0-rc.19"
71
71
  }
72
72
  }