react.dev icon indicating copy to clipboard operation
react.dev copied to clipboard

[Bug]: viewTransition Page example codes doesn't working correctly "Bun"

Open mrtcmn opened this issue 2 months ago • 7 comments

Summary

All example codes preview is broken. Probably bun missing package error. According to https://bun.com/docs/runtime/nodejs-compat#node%3Acrypto has crypto compabilt on it. Maybe not using correct version of Bun.

Page

https://react.dev/reference/react/ViewTransition

Details

Image

mrtcmn avatar Nov 02 '25 11:11 mrtcmn

We are now getting a new error with the stream package: Cannot find module 'stream' from '/node_modules/react-dom/cjs/react-dom-server.bun.development.js'

Image

brmendez avatar Nov 04 '25 16:11 brmendez

It shouldn't be using the bun version at all?

Works when you fork the sandbox, seems like it's probably another codesandbox versioning issue @CompuIves?

rickhanlonii avatar Nov 05 '25 21:11 rickhanlonii

Yes, could be a resolver problem. Taking a look.

CompuIves avatar Nov 05 '25 22:11 CompuIves

Okay, I have a theory and a fix. Deploying the fix now.

CompuIves avatar Nov 05 '25 22:11 CompuIves

@CompuIves you rock

rickhanlonii avatar Nov 05 '25 22:11 rickhanlonii

So the dependency resolver that we use for React Docs was not aware of bun at all in handling exports, so it included it in the bundle, which was then transpiled in the frontend. Since the transpiler couldn't determine where stream or crypto came from (regardless of whether we would execute the file), it threw early. I have now updated our resolver to not include these versions in the bundle, only the browser version. We have a pretty heavy cache, and I cannot cache bust unfortunately because I don't have direct access to the domain, but it should automatically work when a new canary version of react-dom comes up.

CompuIves avatar Nov 05 '25 23:11 CompuIves

Ok perfect, I'll check tomorrow after the nightly and close this!

rickhanlonii avatar Nov 05 '25 23:11 rickhanlonii