[PR #5853] Fix React compiler behaviour in dev mode #6165

Closed
opened 2026-02-28 21:24:50 -06:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/actualbudget/actual/pull/5853

State: closed
Merged: Yes


Fix an extremely strange behaviour of the React Compiler plugin in dev mode, which unfortunately I still do not fully understand. Essentially, when the plugin is passed in as an object (rather than a string), and only in that case, the dev server (but not the production build) converts the following snippet (note that the exact whitespace in the snippet is significant):

const Test = () => {
  return (
    <div>
      Space? {1}
    </div>
  );
};

To:

Space?1

Whereas the correct output is:

Space? 1

I think this has something to do with the order that plugins are resolved in dev mattering for source code transformation. If you inspect the generated output Javascript, it looks something like children: ["Space?", 1] without this change and children: ["Space? ", 1] with this change. (In builds, it always looks like children: ["Space? ", 1].)

This likely also relates to https://github.com/facebook/react/issues/29099, although we are running a plugin version with the fix mentioned.

**Original Pull Request:** https://github.com/actualbudget/actual/pull/5853 **State:** closed **Merged:** Yes --- Fix an extremely strange behaviour of the React Compiler plugin in dev mode, which unfortunately I still do not fully understand. Essentially, when the plugin is passed in as an object (rather than a string), and _only_ in that case, the dev server (but not the production build) converts the following snippet (note that the exact whitespace in the snippet is significant): ```tsx const Test = () => { return ( <div> Space? {1} </div> ); }; ``` To: ``` Space?1 ``` Whereas the correct output is: ``` Space? 1 ``` I think this has something to do with the order that plugins are resolved in dev mattering for source code transformation. If you inspect the generated output Javascript, it looks something like `children: ["Space?", 1]` without this change and `children: ["Space? ", 1]` with this change. (In builds, it always looks like `children: ["Space? ", 1]`.) This likely also relates to https://github.com/facebook/react/issues/29099, although we are running a plugin version with the fix mentioned.
GiteaMirror added the pull-request label 2026-02-28 21:24:50 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/actual#6165