astryx icon indicating copy to clipboard operation
astryx copied to clipboard

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

Open fatwang2 opened this issue 4 months ago • 3 comments

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.

fatwang2 avatar Jul 14 '26 14:07 fatwang2

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

vercel[bot] avatar Jul 14 '26 14:07 vercel[bot]

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!

meta-cla[bot] avatar Jul 14 '26 14:07 meta-cla[bot]

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[bot] avatar Jul 14 '26 15:07 meta-cla[bot]

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[bot] avatar Jul 15 '26 13:07 github-actions[bot]

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

ejhammond avatar Jul 15 '26 15:07 ejhammond