Skip to content

fix(build): compile dist with the production JSX transform - #3930

Merged
ejhammond merged 1 commit into
meta:mainfrom
fatwang2:fix/production-jsx-transform
Jul 15, 2026
Merged

ejhammond merged 1 commit into
meta:mainfrom
fatwang2:fix/production-jsx-transform

Conversation

@fatwang2

Copy link
Copy Markdown
Contributor

Summary

@astryxdesign/[email protected] — the current latest on npm — ships a dist compiled with the development JSX transform. 193 of its 479 dist files import react/jsx-dev-runtime and call jsxDEV, which React's production build does not export (exports.jsxDEV = void 0).

Any consumer that renders an Astryx component in production crashes:

TypeError: (0 , b.jsxDEV) is not a function

dist/AppShell/AppShell.js alone contains 29 jsxDEV calls, so a Next.js app that puts <AppShell> in a layout returns a 500 on every route. That is what happened to us in production — every page of our dashboard went down until we pinned back to 0.1.4:

GET /        500  TypeError: (0 , b.jsxDEV) is not a function
GET /sign-in 500  TypeError: (0 , j.jsxDEV) is not a function

The bug is invisible locally (dev builds load React's development runtime, where jsxDEV exists) and invisible at build time (bundlers happily bundle the import) — it only surfaces when a production render actually executes.

version jsxDEV occurrences in dist
0.1.3 0
0.1.4 0
0.1.5 5696

The UMD bundle (unpkg/jsdelivr) is affected too.

Root cause

@babel/preset-react 8 changed the default for development from a hard-coded false to:

development = api.env(env => env === 'development'),

Babel's env name is BABEL_ENV || NODE_ENV || "development" — so with NODE_ENV unset, which is the normal state of a library build, development becomes true and every JSX call compiles to jsxDEV.

#3839 bumped @babel/preset-react 7.29.7 → 8.0.1 on Jul 11. No config changed; the meaning of the existing config did. 0.1.4 was cut before that bump, 0.1.5 after.

Minimal reproduction (the repo's own preset options, runtime: 'automatic' with no development):

preset-react 8.0.1, NODE_ENV unset       →  import { jsxDEV } from "react/jsx-dev-runtime"   ❌
preset-react 8.0.1, NODE_ENV=production  →  import { jsx }    from "react/jsx-runtime"       ✅
preset-react 8.0.1, development: false   →  import { jsx }    from "react/jsx-runtime"       ✅

Building main today reproduces the broken dist — this is not a one-off CI fluke.

Fix

  1. Pin development: false in the @babel/preset-react options for core, lab, and charts. A published artifact should never depend on an ambient env var; NODE_ENV=production in the release script would also work, but it leaves the same trap armed for anyone who builds by hand.

  2. Add scripts/check-no-dev-jsx.mjs (modeled on check-use-client.mjs): scans the built dist for react/jsx-dev-runtime / jsxDEV and fails the build. Wired into the build script of all three packages, and since prepack runs build, a dev-JSX dist can no longer be published.

lab and charts are private today, but they carry the same config and would ship the same broken artifact the day they are published — fixed here as well.

Verification

check result
pnpm -F @astryxdesign/core build on current main's config ❌ guard fails, exit 1 — 193 dist files flagged
pnpm -F @astryxdesign/core build with this fix ✅ 479 dist files, 0 dev JSX; AppShell.js back to react/jsx-runtime
pnpm -F @astryxdesign/lab build ✅ 107 files clean
pnpm -F @astryxdesign/charts build ✅ 31 files clean
pnpm check:repo, eslint ✅ pass

Suggested follow-up

0.1.5 is still latest on npm and bricks every SSR consumer, so a patch release (or a deprecation of 0.1.5) seems worth doing quickly. Happy to adjust anything here.

@babel/preset-react 8 derives `development` from the Babel env name
(`api.env(env => env === 'development')`), and Babel falls back to
"development" whenever NODE_ENV/BABEL_ENV is unset. Bumping the preset from
7.29.7 to 8.0.1 (meta#3839) therefore flipped the published build to the
development JSX transform with no config change: 193 of 479 dist files in
@astryxdesign/[email protected] import react/jsx-dev-runtime and call jsxDEV, which
React's production build does not export. Any consumer rendering an Astryx
component in production crashes with
`TypeError: (0 , x.jsxDEV) is not a function`.

Pin `development: false` in the core, lab, and charts Babel configs — a
published artifact should never depend on an ambient env var — and add
scripts/check-no-dev-jsx.mjs, which fails the build if development JSX reaches
dist. The guard runs at the end of each package's `build`, and `prepack` runs
`build`, so a dev-JSX dist can no longer be published.
@vercel

vercel Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview, Comment Jul 14, 2026 2:53pm

Request Review

@meta-cla

meta-cla Bot commented Jul 14, 2026

Copy link
Copy Markdown

Hi @fatwang2!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Jul 14, 2026
@meta-cla

meta-cla Bot commented Jul 14, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 14, 2026
yyq1025 added a commit to thinkite/thinkite that referenced this pull request Jul 14, 2026
astryx 0.1.5 shipped its dist compiled with the development JSX
transform (preset-react 8 derives `development` from the Babel env
name, which falls back to "development" when NODE_ENV is unset at
publish time). React's production jsx-dev-runtime exports
jsxDEV = undefined, so every vite build died at module eval with a
blank #root and an empty console; the vite dev server resolves the
development condition and never sees it.

Alias react/jsx-dev-runtime to a shim re-exporting jsx as jsxDEV,
build only — lossless in production, where jsxDEV's extra parameters
feed no validation. Delete the shim and the alias once
meta/astryx#3930 ships in a release.

Co-Authored-By: Claude Fable 5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.6KB 0B

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | View full report

@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Jul 15, 2026
@ejhammond
ejhammond merged commit 93d881b into meta:main Jul 15, 2026
20 checks passed
yyq1025 added a commit to thinkite/thinkite that referenced this pull request Jul 15, 2026
meta/astryx#3930 merged; the 0.1.5-canary.93d881b dist is compiled
with the production JSX transform (verified on the published tarball:
zero react/jsx-dev-runtime imports vs 192 in 0.1.5, 195 files on
react/jsx-runtime). Pin both @astryxdesign packages to that exact
canary — the canary TAG moves with every merge — and delete the whole
workaround: the jsx-dev-runtime-prod-shim, the build-only vite alias,
and the function-form defineConfig that existed only to branch on
`command`.

Verified: built dist has zero jsx-dev-runtime/jsxDEV references and
dev:static boots the real app (the exact scenario that blank-screened
under 0.1.5). Move to stable when 0.1.6 ships.

Co-Authored-By: Claude Fable 5 <[email protected]>
@ejhammond

Copy link
Copy Markdown
Contributor

Thanks for the fix! 0.1.6 should be available now with your code :)

This branch was successfully deployed

1 active deployment
Preview — eb7f6147 Deployed Jul 14, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. community Authored by a community contributor (not on the eng/design team)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants