-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
base: main
Are you sure you want to change the base?
Add Fast Refresh support #3449
Conversation
} | ||
|
||
func (p *parser) reactRefreshRegisterHandle(target ast.Ref, id string) js_ast.Stmt { | ||
var handleName = "_c" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ArnaudBarre any update?
There was a problem hiding this comment.
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
Really interested in using this if it lands. What's the maintainers' stance on adding fast refresh support? |
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!