Skip to content

Conversation

hi-ogawa
Copy link
Contributor

@hi-ogawa hi-ogawa commented Sep 8, 2025

Description

We already handle unused client reference exports but not the entire module. This causes entire module to not ended up in rsc environment chunk and cause unexpected undefined. In this case, we can just skip tracking this module on client environment entirely.

For example, this can happen when some use client module is imported through barrel exports, but exports are not used.

// app.js
import { TestServer } from "./lib.js"
console.log(TestServer)

// lib.js
export * from "./lib-server.js";
export * from "./lib-client.js"; // unused

// lib-server.js
export function TestServer() {
  return "test-server"
}

// lib-client.js
"use client"
export function TestClient() {
  return "test-client"
}

TODO

  • test

@hi-ogawa hi-ogawa added the trigger: preview Trigger pkg.pr.new label Sep 8, 2025
Copy link

pkg-pr-new bot commented Sep 8, 2025

Open in StackBlitz

npm i https://pkg.pr.new/@vitejs/plugin-react@827
npm i https://pkg.pr.new/@vitejs/plugin-react-oxc@827
npm i https://pkg.pr.new/@vitejs/plugin-rsc@827
npm i https://pkg.pr.new/@vitejs/plugin-react-swc@827

commit: d575986

hi-ogawa added a commit to hi-ogawa/waku that referenced this pull request Sep 8, 2025
@hi-ogawa hi-ogawa changed the title fix(rsc): tree-shake unused client reference module and fix build error fix(rsc): fix build error by unused client reference module Sep 8, 2025
@hi-ogawa hi-ogawa marked this pull request as ready for review September 8, 2025 08:07
@hi-ogawa hi-ogawa changed the title fix(rsc): fix build error by unused client reference module fix(rsc): fix build error by tree-shaken client reference module Sep 8, 2025
@hi-ogawa hi-ogawa changed the title fix(rsc): fix build error by tree-shaken client reference module fix(rsc): fix build error when entire client reference module is tree-shaken Sep 8, 2025
@hi-ogawa hi-ogawa merged commit f515bd8 into main Sep 8, 2025
21 checks passed
@hi-ogawa hi-ogawa deleted the 09-08-fix_rsc_tree-shake_unused_client_reference_module_and_fix_build_error branch September 8, 2025 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
trigger: preview Trigger pkg.pr.new
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build failure in rsc:use-client/build-references
1 participant