Skip to content

refactor(mdx): compile providers as Strong templates - #2067

Merged
domgan-oai merged 4 commits into
octanejs:mainfrom
openai-oss-forks:codex/strong-mdx-provider-2059
Oct 14, 2026
Merged

domgan-oai merged 4 commits into
octanejs:mainfrom
openai-oss-forks:codex/strong-mdx-provider-2059

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Convert the client and server MDXProvider boundaries to Strong .tsrx templates. Public imports, component-map merging, parent-context opt-out, and interactive hydration retain their existing behavior. Part of #2059.

Why

Both provider modules previously failed Strong compilation because they called createElement. The new templates forward children directly through their existing contexts. Generated MDX documents remain a separate conversion.

Changes

  • Publish authored .tsrx entries with precise declaration companions and explicit type exports, preserving plain-TypeScript consumers. Build-tool types use MDX’s exported compile-only entry, preserving mutable options without introducing global JSX; remove the old ambient shim.
  • Compile the real server provider through the existing SSR fixture loader in MDX and Docusaurus tests. The packed browser lane checks the client provider; the Node lane checks both providers. Exclude only the exact server source from browser roots, with real-compiler tests proving client-to-server imports still fail.
  • Cover provider updates, nested/function/disabled mappings, context isolation, and interactive hydration with retained DOM/state. Add a plain-TypeScript public API check to CI.
  • Include a patch changeset, scoped status/docs updates, and required generated files.

Validation

  • Scoped formatting and git diff --check (generated JSONL is validated by its generator).
  • MDX and Docusaurus package typechecks; public types in plain TypeScript Bundler and NodeNext; packed-tarball public type consumption.
  • Client/server Strong compilation: no diagnostics or element-descriptor factories in either provider's output.
  • Local owning suites: 100/100 tests across 21 files (71 MDX and 29 Docusaurus), including the CLI test at its unchanged default timeout.
  • Paired browser checks against main 0bb503fc: public provider SSR adoption, mapping/inheritance updates, counter state/DOM identity, events, and cleanup in both development and production modes; real production website SSR and client navigation, tables, code-copy and mobile docs menus at 1280×900 and 390×844. No console/page/recoverable errors. Provider screenshots and stable website captures match; an initial mobile-menu scroll-position difference also reproduced on main; replaying with interactions after opening animations completed produced matching captures.
  • pnpm sync, typecheck coverage, and source-publication checks. All 45 packed-canary tests pass, including real TypeScript 5.9/7.1 Node/browser source-coverage and import-leak controls; freshly packed MDX source passes both environment projects locally.
  • Matching production builds on Node 24.19.0: all 614 emitted public JavaScript files total 4,414,422 → 4,414,325 gzip bytes (−97); raw 19,666,097 → 19,666,298 (+201). Includes copied public runtimes and all client chunks, not a selected sub-bundle.
  • All current-head checks are green on 9d157b9b0, including all three required checks and CI provenance: CI run 38645916658, benchmark run. The four unit-test shards pass 53,936 tests (2 skipped); website integration passes 104/104. Packed-source validation passes on TypeScript 5.9.3, 6.0.3, and 7.1.0-dev.20260921.1, covering 51 bindings and 1,793 authored source checks per lane. React parity, browser integration, typechecks, lint, examples, package publishing, and bundle checks pass. Benchmark work counters, application-bundle bytes, and public-import reachability are unchanged; all 20 timed operations remain within noise. The global-JSX declaration and server/browser root failures found in earlier runs are resolved.
  • perf-review: independent review and scan found no must-fix findings or mechanical flags. Provider render paths add no scheduling, DOM measurement, or children closures. Complete production JS comparison is recorded above; no latency claim.
  • concise-code: authored runtime is 2 lines smaller; declaration companions preserve the public API, and the unused 16-line ambient JSX shim is removed. Two module renames preserve separate client/server contexts. Rejected extra runtime barrels/context modules and a generic provider factory; neither was needed. The two declarations preserve demonstrated plain-TS compatibility, the 2-line SSR fixture reuses existing compilation infrastructure, and the typetest protects all four public export paths, writable compile options, and absence of global JSX. The packed harness has one exact server-root exclusion, reused for file-coverage accounting; its negative controls retain browser import checking.

Production provider parity compares 00b59cf6b with main 0bb503fc, using dev:false, hmr:false, profile:false and NODE_ENV=production throughout. The development provider and production website comparisons used 854550e14; the follow-up changes only declarations, the compile-only typetest, and changeset prose, leaving runtime sources unchanged. Final head 9d157b9b0 adds only the packed-consumer harness fix and its regression tests. Full workspace tests, repository-wide formatting/typecheck, and broader browser/benchmark gates pass in current-head CI.

Risk / follow-ups

  • The website imports useMDXComponents but supplies table/pre mappings through document props; it never mounts MDXProvider. Direct provider lifecycle proof comes from the public-API fixture and package tests, separately from real website QA.
  • Generated MDX document elements still use the descriptor path. This PR does not complete Run the website in Strong mode #2059 or declare the whole application descriptor-free.
  • The unrestricted generated whole-source browser audit includes the server entry and reports 52 existing Node-global diagnostics in Octane server source. The old .ts and new .tsrx providers produce byte-identical diagnostics under the same browser-only settings. Public browser-facing declarations and the environment-correct packed source projects pass locally and in CI; the server remains fully checked with Node types. No global-type shim or core workaround was added.
  • Local checks reused an installed dependency graph, with every workspace link redirected to the correct checkout. CI provides the independent frozen-install check.

Provenance

  • An agent produced this diff (agent-authored)

Codex task · implementation host: com-79386


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.


Note

Medium Risk
Touches the MDX provider boundary used for component mapping across SSR and hydration; behavior is heavily tested but export and typing paths changed for consumers.

Overview
@octanejs/mdx now ships the client and server MDXProvider layers as Strong .tsrx templates instead of plain TypeScript. Providers render context via JSX (<MDXContext … />) rather than createElement, while merge semantics, nested providers, disableParentContext, and useMDXComponents behavior stay aligned with @mdx-js/react.

Package surface: public entries point at index.tsrx / server.tsrx with hand-written .d.ts companions; the global JSX ambient shim is removed. @octanejs/mdx/compile types avoid pulling in global JSX. Root typecheck adds packages/mdx/typetests.

Tests & tooling: SSR/hydration suites load the real server provider through an ?octane-ssr fixture; new cases cover mapping updates without remounting children, nested/function/disabled provider mappings, and post-hydration interactivity. Vitest drops MDX source aliases in favor of octaneServerFixtures. Packed-tarball browser typecheck excludes server.tsrx while still failing on accidental client imports of server code.

Docs, status metadata, CLI catalog, and a patch changeset reflect Strong provider templates and expanded SSR/hydration evidence. Generated MDX documents are unchanged (still value-position rendering).

Reviewed by Cursor Bugbot for commit 9d157b9. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent refactor PR: internal restructuring, no behavior change labels Oct 14, 2026
@domgan-oai
domgan-oai marked this pull request as ready for review October 14, 2026 21:47
@github-actions

Copy link
Copy Markdown
Contributor

Benchmark report

🟢 No byte growth, no added work, and no timing changes beyond ±3%.

Compares 0bb503fc6, the merge commit's first parent with dc87a1d6a on the same runner. Any increase in a js-framework work counter fails this check; byte changes are a report. Wall time is a report: base and head samples alternate in one browser, and an operation is called slower or faster only when the 95% confidence interval of its ratio excludes ±3%. Workflow run

js-framework: 1k/10k row operations

All 20 timed operations (20 without a verdict)
target operation base ms head ms head/base 95% CI
octane-tsrx run 2.942 2.875 −1.5% −6.2% … +1.6% ⚪ within noise
octane-tsrx replace 7.392 6.825 −4.9% −10.0% … −3.0% ⚪ within noise
octane-tsrx add 2.675 2.708 −1.6% −3.7% … +3.6% ⚪ within noise
octane-tsrx update 0.158 0.151 +3.8% −14.0% … +8.3% ⚪ within noise
octane-tsrx select 0.006 0.006 −0.3% −2.6% … +1.7% ⚪ within noise
octane-tsrx swap 0.019 0.018 −1.9% −7.0% … +3.9% ⚪ within noise
octane-tsrx remove 0.017 0.015 −3.0% −9.4% … +2.0% ⚪ within noise
octane-tsrx runlots 28.583 28.367 −0.9% −5.2% … +2.2% ⚪ within noise
octane-tsrx select_lots 0.007 0.007 −0.6% −3.0% … +0.8% ⚪ within noise
octane-tsrx clear 53.233 52.908 +1.6% −4.9% … +5.7% ⚪ within noise
octane-jsx run 3.858 3.983 ±0.0% −2.5% … +2.6% ⚪ within noise
octane-jsx replace 8.208 9.175 ±0.0% −2.8% … +4.1% ⚪ within noise
octane-jsx add 3.817 3.650 +1.2% −2.9% … +8.5% ⚪ within noise
octane-jsx update 0.362 0.370 +2.1% −6.4% … +17.5% ⚪ within noise
octane-jsx select 0.162 0.166 +2.7% −2.1% … +8.0% ⚪ within noise
octane-jsx swap 0.200 0.202 +0.5% −2.7% … +3.1% ⚪ within noise
octane-jsx remove 0.213 0.213 +2.0% −5.1% … +9.4% ⚪ within noise
octane-jsx runlots 34.200 34.900 +1.0% −4.1% … +9.4% ⚪ within noise
octane-jsx select_lots 2.161 2.000 −8.4% −13.6% … +2.3% ⚪ within noise
octane-jsx clear 65.192 64.333 +5.7% −8.7% … +13.2% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

No changes across 93 measured values.

Public-import reachability bundles (bytes)

No changes across 120 measured values.

@domgan-oai
domgan-oai merged commit 6e93959 into octanejs:main Oct 14, 2026
32 checks passed
trueadm added a commit that referenced this pull request Oct 15, 2026
Brings in #2067 (mdx providers as Strong templates), #2068 (479118f,
Strong named render blocks without descriptors), #2070 and Version Packages.
#2068's squash matches its reviewed head 2203905 in runtime and compiler
source; it adds only the MCP benchmark entry and its changeset line.

Conflicts:
- package.json: ci:workflow:test keeps the redesign's check-render-writes
  test in place of check-staged-dom; typecheck takes main's mdx typetests.
- runtime.ts, hostComponent: #2068 drops the stable delegating children
  body; the redesign's commit-time props (state.next, commitHostComponent)
  stay.

Re-expressed (the trial resolution of 4bf8ab0ddd): renderHostTagChildren's
replacement. #2068 journalled the slot and its range, deferred the outgoing
Block (deferRootReplacement, STAGED_DOM) and removed children at render. Here
a different body builds in the slot's frontier over committed DOM, the
outgoing Block and its nodes are queued as the slot's deletion, and
landHostTagChildren swaps the slot's Block at commit; fresh DOM, or no open
root render, replaces at once. scripts/render-writers.mjs classifies
replaceHostTagChildren as fresh.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent refactor PR: internal restructuring, no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant