Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Fast Refresh support #3449

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

ArnaudBarre
Copy link

I know this was previously considered as out of scope, but after the implementation of JSX dev runtime, this is the last piece required to make esbuild the perfect tool for building React SPAs.

It would allow to get an instant dev-server start without the overhead of an external plugin & with HMR support (what I will work on it this lands!)

This is my first time writing go, I can iterate on it in the coming weeks!

}

func (p *parser) reactRefreshRegisterHandle(target ast.Ref, id string) js_ast.Stmt {
var handleName = "_c"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be good to handle scope collisions (like the SWC transform):

const _c = 'collision';
const _c1 = 'collision1';
export function Component() {
  return <div></div>;
}

// becomes:

import { jsxDEV as o } from "react/jsx-dev-runtime";
const _c = 'collision';
const _c1 = 'collision1';
export function Component() {
    return /*#__PURE__*/ o("div", {}, void 0, false, {
        fileName: "input.jsx",
        lineNumber: 4,
        columnNumber: 10
    }, this);
}
_c2 = Component;
var _c2;
$RefreshReg$(_c2, "Component");

In the case of SWC, the integer suffix is incremented until a unique identifier is found in scope.

Choose a reason for hiding this comment

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

@ArnaudBarre any update?

Copy link
Author

Choose a reason for hiding this comment

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

Nothing plan for the moment until I get more positive feedback on this from either maintainers or the community. 16 reactions for something that would allow instant dev server for SPA in dev (because not other tools can do bundling with fast refresh without plugin overhead) feels not worth it publishing this as a fork

@ZinoKader
Copy link

Really interested in using this if it lands. What's the maintainers' stance on adding fast refresh support?

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.

None yet

4 participants