Skip to content

Commit a6af933

Browse files
committed
compiler: publishable as @reactivescript/compiler, .rx in Vite with plain solid()
- The crate's Node-API build (`--features node`, src/node.rs) over `app`, now a library function (src/app.rs) that `rxc app` also calls; a missing entry is an error instead of an empty program. - package.json for @reactivescript/compiler: one binary per platform (npm/*, as @solidjs/compiler ships), the napi loader, and the Vite front end at `/vite` (moved from vite-plugin-rx/, now calling the binding instead of spawning rxc). Solid's plugin loads it on its own (solidjs/solid-vite-plugin#471), so the examples build with `solid()`. - .github/workflows/compiler.yml: build and test each platform; on main, publish a new version by trusted publishing and tag compiler-v<version>. - spec/11: the Vite paragraph, and decision 7 (taken by default). Tests: npm test (binding, every target); compiler/test/vite.mjs 14 pass on plain solid(); crate conformance 280/280. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0117BoWMdD4K7882vob4J9vq
1 parent 943a651 commit a6af933

31 files changed

Lines changed: 3525 additions & 135 deletions

‎.github/workflows/compiler.yml‎

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# The compiler's npm package, @reactivescript/compiler (compiler/): the crate's Node-API build for each platform,
2+
# each tested on its own runner, then published as one package per platform (@reactivescript/compiler-<platform>)
3+
# beside the main package, which loads the one that fits and carries the Vite front end (`/vite`).
4+
#
5+
# A release is a version bump merged to main (compiler/README.md, Releasing), once the repository variable RELEASES
6+
# is `on`: a version npm does not have is published by trusted publishing (OIDC, no token) and tagged
7+
# `compiler-v<version>`.
8+
name: compiler
9+
10+
on:
11+
push:
12+
branches: [main]
13+
paths: ["compiler/**", ".github/workflows/compiler.yml"]
14+
pull_request:
15+
paths: ["compiler/**", ".github/workflows/compiler.yml"]
16+
workflow_dispatch:
17+
18+
jobs:
19+
build:
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
include:
24+
- { os: ubuntu-latest, target: x86_64-unknown-linux-gnu, test: true }
25+
- { os: ubuntu-24.04-arm, target: aarch64-unknown-linux-gnu, test: true }
26+
- { os: macos-latest, target: aarch64-apple-darwin, test: true }
27+
- { os: macos-latest, target: x86_64-apple-darwin, test: false } # cross-built on Apple silicon
28+
- { os: windows-latest, target: x86_64-pc-windows-msvc, test: true }
29+
runs-on: ${{ matrix.os }}
30+
defaults:
31+
run:
32+
working-directory: compiler
33+
shell: bash
34+
steps:
35+
- uses: actions/checkout@v5
36+
- uses: dtolnay/rust-toolchain@stable
37+
with:
38+
targets: ${{ matrix.target }}
39+
- uses: Swatinem/rust-cache@v2
40+
with:
41+
workspaces: compiler
42+
key: ${{ matrix.target }}
43+
- uses: actions/setup-node@v5
44+
with:
45+
node-version: 22
46+
- run: npm ci
47+
- name: Node-API build
48+
run: npx napi build --platform --release --strip --features node --target ${{ matrix.target }} --manifest-path ./Cargo.toml -- --lib
49+
- name: Test
50+
if: matrix.test
51+
run: npm test
52+
- uses: actions/upload-artifact@v4
53+
with:
54+
name: binding-${{ matrix.target }}
55+
path: compiler/*.node
56+
if-no-files-found: error
57+
58+
# which version is new: on main only, after every platform built
59+
version:
60+
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && vars.RELEASES == 'on'
61+
needs: build
62+
runs-on: ubuntu-latest
63+
outputs:
64+
version: ${{ steps.v.outputs.version }}
65+
steps:
66+
- uses: actions/checkout@v5
67+
- id: v
68+
run: |
69+
v=$(node -p 'require("./compiler/package.json").version')
70+
if [ -z "$(npm view "@reactivescript/compiler@$v" version 2>/dev/null)" ]; then echo "version=$v" >> "$GITHUB_OUTPUT"; fi
71+
72+
publish:
73+
needs: version
74+
if: needs.version.outputs.version != ''
75+
runs-on: ubuntu-latest
76+
environment: release
77+
permissions:
78+
id-token: write # trusted publishing: npm takes the job's OIDC token, and adds provenance
79+
contents: write # the tag
80+
defaults:
81+
run:
82+
working-directory: compiler
83+
steps:
84+
- uses: actions/checkout@v5
85+
- uses: actions/download-artifact@v4
86+
with:
87+
pattern: binding-*
88+
path: compiler/artifacts
89+
merge-multiple: true
90+
- uses: actions/setup-node@v5
91+
with:
92+
node-version: 22
93+
registry-url: https://registry.npmjs.org
94+
- run: npm install -g npm@latest # trusted publishing needs npm 11.5.1 or later
95+
- run: npm ci
96+
- name: Platform packages
97+
run: |
98+
node scripts/sync-optional-deps.mjs
99+
npx napi artifacts --output-dir artifacts --npm-dir npm
100+
for d in npm/*/; do npm publish "$d" --access public; done
101+
- run: npm publish --access public
102+
- name: Tag
103+
working-directory: .
104+
run: git tag "compiler-v$V" && git push origin "compiler-v$V"
105+
env:
106+
V: ${{ needs.version.outputs.version }}

‎.gitignore‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
node_modules/
22
compiler/target/
3-
vite-plugin-rx/.out/
3+
compiler/*.node
4+
compiler/test/.out/
5+
compiler/artifacts/

‎compiler/Cargo.lock‎

Lines changed: 192 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)