Skip to content

Conversation

hi-ogawa
Copy link
Contributor

@hi-ogawa hi-ogawa commented Aug 7, 2025

Description

Related

Since we already have warning for this case #635, we don't lose anything by trying to support this by best effort.

TODO

  • POC "require to import" transform with rolldown (similar to optimizer require external)
  • test (support at least use-sync-external-store)
  • use cjs-module-lexer to find export name and re-exports (no for now)
  • rewrite manually via parse + periscopic + magic string

I confirmed keen-slider/react works without optimizeDeps.include https://stackblitz.com/edit/github-opzbabz7-rd2xstwo?file=vite.config.ts (thought it still warns it)

12:21:19 PM [vite] (ssr) warning: Found non-optimized CJS dependency in 'ssr' environment. It is recommended to add the dependency to 'environments.ssr.optimizeDeps.include'.
  Plugin: cjs-module-runner-transform
  File: /home/projects/github-opzbabz7/node_modules/keen-slider/react.js?v=82455b8e

It looks like react-dom/server even works with this, so we can close that too

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

pkg-pr-new bot commented Aug 8, 2025

Open in StackBlitz

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

commit: f68afea

@hi-ogawa hi-ogawa marked this pull request as ready for review August 8, 2025 03:23
@hi-ogawa hi-ogawa merged commit 7a92083 into main Aug 8, 2025
20 of 21 checks passed
@hi-ogawa hi-ogawa deleted the 08-07-fix_rsc_support_cjs_on_module_runner branch August 8, 2025 05:09
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.

1 participant