Repository navigation
fix(build): compile dist with the production JSX transform - #3930
Conversation
@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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Hi @fatwang2! Thank you for your pull request and welcome to our community. Action RequiredIn 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. ProcessIn 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 If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
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]>
PR Analysis ReportNo new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | View full report |
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]>
|
Thanks for the fix! 0.1.6 should be available now with your code :) |
Summary
@astryxdesign/[email protected]— the currentlateston npm — ships adistcompiled with the development JSX transform. 193 of its 479distfiles importreact/jsx-dev-runtimeand calljsxDEV, which React's production build does not export (exports.jsxDEV = void 0).Any consumer that renders an Astryx component in production crashes:
dist/AppShell/AppShell.jsalone contains 29jsxDEVcalls, 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:The bug is invisible locally (dev builds load React's development runtime, where
jsxDEVexists) and invisible at build time (bundlers happily bundle the import) — it only surfaces when a production render actually executes.jsxDEVoccurrences indistThe UMD bundle (
unpkg/jsdelivr) is affected too.Root cause
@babel/preset-react8 changed the default fordevelopmentfrom a hard-codedfalseto:Babel's env name is
BABEL_ENV || NODE_ENV || "development"— so withNODE_ENVunset, which is the normal state of a library build,developmentbecomestrueand every JSX call compiles tojsxDEV.#3839 bumped
@babel/preset-react7.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 nodevelopment):Building
maintoday reproduces the brokendist— this is not a one-off CI fluke.Fix
Pin
development: falsein the@babel/preset-reactoptions forcore,lab, andcharts. A published artifact should never depend on an ambient env var;NODE_ENV=productionin the release script would also work, but it leaves the same trap armed for anyone who builds by hand.Add
scripts/check-no-dev-jsx.mjs(modeled oncheck-use-client.mjs): scans the builtdistforreact/jsx-dev-runtime/jsxDEVand fails the build. Wired into thebuildscript of all three packages, and sinceprepackrunsbuild, a dev-JSXdistcan no longer be published.labandchartsare 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
pnpm -F @astryxdesign/core buildon currentmain's configpnpm -F @astryxdesign/core buildwith this fixAppShell.jsback toreact/jsx-runtimepnpm -F @astryxdesign/lab buildpnpm -F @astryxdesign/charts buildpnpm check:repo,eslintSuggested follow-up
0.1.5 is still
lateston 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.