Skip to content

[syntax] Add experimental React JSX in .iris files - #627

Draft
purefunctor wants to merge 5 commits into
mainfrom
experiment/native-react-jsx
Draft

purefunctor wants to merge 5 commits into
mainfrom
experiment/native-react-jsx

Conversation

@purefunctor

@purefunctor purefunctor commented Oct 3, 2026 •

Copy link
Copy Markdown
Owner

Purpose

Explore opt-in JSX for PureScript with compiler-owned React integration, while leaving existing .purs packages unchanged. .iris modules participate in the same module graph and emit executable JavaScript importing react/jsx-runtime, analogous to the existing StyleX integration. No generated Iris.React runtime module or downstream JSX transform is required.

The built-in Iris.React types give custom components ordinary checked record/row props, including open rows and contextual checking. Component definitions enforce stable top-level identity. Builds, Spago source discovery, watch mode, and the language server recognize .iris alongside .purs.

The language server supplies standard semantic tokens for JSX tags, component references, namespace qualifiers, props, text, and delimiters, including unfinished tags. Embedded PureScript keeps its existing classifications. No JSX TextMate grammar is required.

Review order

The first four commits separate compiler support and fixtures, build/LSP discovery, Chromium rendering coverage, and the experiment documentation. Targeted readability cleanup is folded into the owning commits. A fifth commit adds JSX semantic highlighting, its LSP fixture, and editor setup documentation.

See documentation/jsx.md for syntax, types, generated output, and interoperability limits. Intrinsic DOM attributes currently accept open records; hooks, a complete DOM schema, and automatic interoperability with React Basic are not provided.

Verification

The initial compiler implementation retained its tested tree through the commit rewrite:

  • cargo check -p functional -p javascript -p lexing -p iris-build -p iris-lsp-workspace --tests passed.
  • Corresponding crate unit tests passed: 181 tests.
  • Full just t compiler, just t lowering, just t resolving, and just t lsp passed with no pending snapshots.
  • React and package-manager E2E passed: 32 tests, including real CLI/watch behavior and Vitest browser mode in Chromium. Earlier combined verification also passed the StyleX E2E.
  • Release-built package-set comparison against the merge base covered 631 packages / 7,371 files: no introduced errors or warnings; 36 unchanged warnings.

The semantic-highlighting follow-up additionally passed:

  • cargo check -p iris-analysis --tests and all 40 analyzer unit tests.
  • Full just t lsp, with no pending snapshots and no changes to existing .purs reports.
  • A real VS Code 1.98 extension host using the rebuilt CLI: semantic-provider assertions for tags, component references, qualifiers, props, text, keywords, and delimiters. Rendered DOM colors were checked with Dark Modern; the editor reported no problems. Screenshot captured, but image-tool inspection was blocked by the attachment upload quota.
  • just format and just licenses completed before both pushes with no additional changes.

Known draft issues

Oracle review identified two remaining issues, supported by source inspection but not yet reproduced through executed regression sequences:

  • An LSP source-dialect rename with an open unsaved FFI overlay can reject the rename or lose the new source's open event because foreign ownership is retained.
  • A full watch rescan does not perform the duplicate-stem validation used by incremental synchronization and can accept an ambiguous .purs / .iris pair.

These behavior fixes remain separate from the completed readability cleanup. This PR is an experiment, not a release-ready React integration.

purefunctor and others added 4 commits October 3, 2026 05:46
Track the Iris source dialect and elaborate JSX through typed Iris.React helpers. Preserve ordinary PureScript syntax, contextual record checking, component identity, and first-class element helpers.

Emit React automatic-runtime imports and executable JavaScript without a generated Iris.React runtime module. Cover source diagnostics, inferred and checked props, fragments, code generation, and dialect invalidation through compiler fixtures.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a0ffe1-6de2-739b-9076-c4092e90ecae
Discover .iris alongside .purs in Spago packages, watch both extensions, and retain FFI ownership across source dialect renames. Reject ambiguous same-stem source files and preserve open editor overlays.

Exercise source renames and subsequent FFI edits through workspace notifications and the real CLI watcher.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a0ffe1-6de2-739b-9076-c4092e90ecae
Build a mixed PureScript and Iris workspace with the real CLI, then execute fresh output using Vitest browser mode and pinned React 19 tooling.

Verify DOM output, hooks, clicks, rerenders, keyed state preservation, and static versus dynamic fragment key warnings. Keep the React browser tooling separate from compiler snapshot tests.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a0ffe1-6de2-739b-9076-c4092e90ecae
Explain the .iris opt-in, generated React imports, typed component props and children, supported syntax, and existing-binding interoperability limits.

Document executable JavaScript output and the compiler and browser verification commands.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a0ffe1-6de2-739b-9076-c4092e90ecae
@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Compatibility regression report

Package set 81.2.0 for PureScript 0.15.15.

✅ The candidate introduces no compatibility errors.

Diagnostic class Base Candidate Introduced Fixed
Compiler errors 0 0 0 0
Compiler warnings 36 36 0 0
Verifier errors 0 0 0 0

Introduced errors

None.

Fixed errors (0)

None.

Warning changes (0 introduced, 0 fixed)

Introduced

None.

Fixed

None.

Candidate errors (0)

None.

Candidate warnings (36)
  • deno@0.0.5/src/Deno.purs:38:17 — CustomWarning (checking): Data.Map's `Semigroup` instance is now unbiased and differs from the left-biased instance defined in PureScript releases <= 0.13.x.
  • deno@0.0.5/src/Deno/Dotenv.purs:41:20 — CustomWarning (checking) × 2: Data.Map's `Semigroup` instance is now unbiased and differs from the left-biased instance defined in PureScript releases <= 0.13.x.
  • deno@0.0.5/src/Deno/Http/Request.purs:47:25 — CustomWarning (checking): Data.Map's `Semigroup` instance is now unbiased and differs from the left-biased instance defined in PureScript releases <= 0.13.x.
  • literals@1.0.2/src/Literals/Null.purs:11:1 — UnparseableFFIModule (javascript): Oxc could not parse the JavaScript FFI module. Fix the invalid or unsupported JavaScript syntax; Iris treated the module as opaque and skipped export-name validation: Unexpected token
  • react-basic-dom-beta@0.1.1/src/Beta/DOM.purs:33:31 — DuplicateImport (indexing): Import list contains multiple references to 'Proxy'
  • sparse-polynomials@3.0.1/src/Data/Sparse/Polynomial.purs:1048:1 — MissingPatterns (checking) × 2: Pattern match is not exhaustive. Missing: _
  • text-formatting@0.1.0/src/Data/Text/Format/Dodo/Printer.purs:64:25 — CustomWarning (checking) × 23: Debug function usage
  • trivial-unfold@0.5.0/src/Data/Unfoldable1/Trivial1.purs:150:17 — MissingPatterns (checking): Pattern match is not exhaustive. Missing: Right _
  • xterm@1.0.0/src/XTerm/UnicodeHandling.purs:15:1 — UnparseableFFIModule (javascript) × 2: Oxc could not parse the JavaScript FFI module. Fix the invalid or unsupported JavaScript syntax; Iris treated the module as opaque and skipped export-name validation: Expected a semicolon or an implicit semicolon after a statement, but found none
  • yoga-react-dom@2.0.1/src/Yoga/React/DOM.purs:34:31 — DuplicateImport (indexing): Import list contains multiple references to 'Proxy'
  • yoga-tree-utils@1.0.0/src/Yoga/Tree/Extended/Path.purs:20:72 — DuplicateImport (indexing): Import list contains multiple references to 'snoc'

View workflow run

Classify tags, component references, qualified prefixes, props, text, and delimiters using the existing LSP legend. Preserve PureScript classifications inside interpolations and cover Unicode ranges, nested JSX, and incomplete tags with an LSP fixture.

Document the VS Code file association and semantic-highlighting settings.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a0ffe1-6de2-739b-9076-c4092e90ecae

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant