Skip to content

Fix production JS builds compiling JSX in development mode - #8150

Merged
david-yz-liu merged 2 commits into
masterfrom
fix_production_jsx_runtime
Sep 4, 2026
Merged

Fix production JS builds compiling JSX in development mode#8150
david-yz-liu merged 2 commits into
masterfrom
fix_production_jsx_runtime

Conversation

@Naragod

@Naragod Naragod commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Proposed Changes

Production webpack builds compile JSX in development mode. #8042 moved JSX to the automatic runtime. In development mode, that emits jsxDEV calls. Production React drops that function. The bundle then crashes on its first component. Every page loses its JavaScript after that ("Routes is not defined", empty admin Courses and Users tables). Deployed v2.10.2 instances hit this. Dev servers and Jest kept working.

Cause: Babel picks its mode from the build shell's BABEL_ENV or NODE_ENV. Webpack's mode plays no part. Deploy hosts leave both unset, so Babel ran in development mode.

Two changes:

  • webpack.production.js sets BABEL_ENV plus NODE_ENV to production at the top. A production build now compiles right on any host.
  • babel.config.js gives @babel/preset-react an explicit development flag. Dev and test keep jsxDEV.

Verification:

  • Before: a production bundle contains jsxDEV. A headless Chromium login crashes with (0, fF.jsxDEV) is not a function and shows zero tables.
  • After: the bundle has zero jsxDEV. The same headless login renders the course list with a clean console. window.Routes works.
  • Jest passes (the test env keeps the development runtime).

Type of Change

Type Applies?
🚨 Breaking change (fix or feature that would cause existing functionality to change)
New feature (non-breaking change that adds functionality)
🐛 Bug fix (non-breaking change that fixes an issue) X
🎨 User interface change (change to user interface; provide screenshots)
♻️ Refactoring (internal change to codebase, without changing functionality)
🚦 Test update (change that only adds or modifies tests)
📦 Dependency update (change that updates a dependency)
📖 Documentation update (change that updates documentation)
🔧 Internal (change that only affects developers or continuous integration) X

Checklist

Before opening your pull request:

  • I have performed a self-review of my changes.
    • Check that all changed files included in this pull request are intentional changes.
    • Check that all changes are relevant to the purpose of this pull request, as described above.
  • I have added tests for my changes, if applicable.
    • This is required for all bug fixes and new features.
  • I have updated the project documentation, if applicable.
    • This is required for new features.
  • If this is my first contribution, I have added myself to the list of contributors.

After opening your pull request:

  • I have updated the project Changelog (this is required for all changes).
  • I have verified that the pre-commit.ci checks have passed.
  • I have verified that the CI tests have passed.
  • I have reviewed the test coverage changes reported by Coveralls.
  • I have requested a review from a project maintainer.

Questions and Comments

This change is build config, so the checks above are hand-run build checks in place of unit tests. The Jest suite covers the test side of the Babel change.

@Naragod
Naragod requested a review from donny-wong September 3, 2026 19:57
@coveralls

coveralls commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 33798899206

Warning

No base build found for commit 2c24124 on master.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 90.693%

Details

  • Patch coverage: No coverable lines changed in this PR.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 52371
Covered Lines: 48520
Line Coverage: 92.65%
Relevant Branches: 2499
Covered Branches: 1243
Branch Coverage: 49.74%
Branches in Coverage %: Yes
Coverage Strength: 128.82 hits per line

💛 - Coveralls

@david-yz-liu david-yz-liu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Naragod!

@david-yz-liu
david-yz-liu merged commit ec4bf2b into master Sep 4, 2026
13 checks passed
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.

4 participants