fix(rsc): fix internal import to allow stable react vendor chunk#824
Merged
Conversation
Owner
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
78213b0 to
439d66d
Compare
3 tasks
439d66d to
a529eaa
Compare
hi-ogawa
commented
Jun 12, 2025
| const name = this.environment.name === "client" ? "browser" : "ssr"; | ||
| output.prepend( | ||
| `import * as $$ReactClient from "${PKG_NAME}/${name}";\n`, | ||
| `import * as $$ReactClient from "${PKG_NAME}/react/${name}";\n`, |
Owner
Author
There was a problem hiding this comment.
This is crucial to have createServerReference etc... to be included in react vendor chunk e.g.
import { g as createServerReference, h as callServer, i as findSourceMapURL, j as jsxRuntimeExports, R as React } from "./lib-react-Ck-kPwtf.js";
const testAction = /* @__PURE__ */ createServerReference("fc50c6581262#testAction", callServer, void 0, findSourceMapURL, "testAction");
const testAction2 = /* @__PURE__ */ createServerReference("fc50c6581262#testAction2", callServer, void 0, findSourceMapURL, "testAction2");
const testActionState = /* @__PURE__ */ createServerReference("fc50c6581262#testActionState", callServer, void 0, findSourceMapURL, "testActionState");
function TestActionFromClient() {
return /* @__PURE__ */ jsxRuntimeExports.jsxs("form", { action: testAction, children: [
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { children: "test-action-from-client" }),
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { formAction: testAction2, children: "test-action-from-client-2" })
] });
}
function TestUseActionState() {
const [state, formAction] = React.useActionState(testActionState, 0);
return /* @__PURE__ */ jsxRuntimeExports.jsx("form", { action: formAction, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("button", { "data-testid": "use-action-state", children: [
"test-useActionState: ",
state
] }) });
}
export {
TestActionFromClient,
TestUseActionState
};We cannot put @hiogawa/vite-rsc/browser in vendor chunk because that includes whole virtual modules etc... internals.
a529eaa to
9119d00
Compare
Merged
9119d00 to
7ce3017
Compare
d2d8a0e to
e5a7f8a
Compare
e5a7f8a to
2eab0c8
Compare
Owner
Author
2eab0c8 to
a0fa557
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Just curiosity. I was wondering what would be a Vite equivalent of https://github.com/web-infra-dev/rsbuild/blob/main/packages/plugin-react/src/splitChunks.ts
Testing
manualChunksis postponed for #940 for now since that's going to be tricky for rolldown-vite ci.