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

fix(react-server): tree shake unused references by __NO_SIDE_EFFECTS__ #336

Merged
merged 2 commits into from
Jun 3, 2024

Conversation

hi-ogawa
Copy link
Owner

@hi-ogawa hi-ogawa commented Jun 3, 2024

Picking up diff from #331

We could probably add /* @__PURE__ */ $$proxy(...) from transform plugin side, but __NO_SIDE_EFFECTS__ should be also fine for now.

example:

Source

import { Link } from "@hiogawa/react-server/client";
export default function Layout(props: React.PropsWithChildren) {

Build output in packages/react-server/examples/starter/dist/rsc/index.js

  • before
...
const Link = registerClientReference("SGjedgC19ilj85OGI0xm9X7OjaT_pYP5IBJLJN739tk", "Link");
registerClientReference("SGjedgC19ilj85OGI0xm9X7OjaT_pYP5IBJLJN739tk", "LinkForm");
registerClientReference("SGjedgC19ilj85OGI0xm9X7OjaT_pYP5IBJLJN739tk", "routerRevalidate");
registerClientReference("SGjedgC19ilj85OGI0xm9X7OjaT_pYP5IBJLJN739tk", "useRouter");
function Layout(props) { ... }
  • after
...
const Link = /* @__PURE__ */ registerClientReference("SGjedgC19ilj85OGI0xm9X7OjaT_pYP5IBJLJN739tk", "Link");
function Layout(props) { ... }

@hi-ogawa
Copy link
Owner Author

hi-ogawa commented Jun 3, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @hi-ogawa and the rest of your teammates on Graphite Graphite

@hi-ogawa hi-ogawa marked this pull request as ready for review June 3, 2024 05:24
@hi-ogawa hi-ogawa merged commit b9ec275 into main Jun 3, 2024
4 checks passed
@hi-ogawa hi-ogawa deleted the fix-no-side-effect branch June 3, 2024 05:25
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.

1 participant