birdofpreyru / react-native-static-server

Embedded HTTP server for React Native
https://dr.pogodin.studio/docs/react-native-static-server
Other
154 stars 22 forks source link

Support of Windows platform is broken since v0.8.0 #49

Closed birdofpreyru closed 1 year ago

birdofpreyru commented 1 year ago

After upgrade of the library and example app to RN@0.72.1 and RNW (React Native Windows) @0.72.1, the example app built for Windows platform does not work. It hangs up on start-up, and errors in React console tell it can't call to some internal RN modules, as they has not been registered. Interestingly, it starts without most of those errors if Server class from this library is not used, or if it is exported/imported via a named export, rather than the default one used now. Thus, my current guess, it is a problem in React Native layer, and it is either me missing some change needed in Metro / TypeScript configuration for RN@0.72.x (especially, considering that the current codebase setup use some trickery in example's Metro config to load the library from parent folder, for development needs, rather than from example's node_modules, as it happens with normal dependencies), or some bug in latest (v0.72.x) RNW releases.

I don't have much time, nor motivation to troubleshoot it further right now; thus, I am going to wait till next RN(W) releases, to see if some fixes in them will magically resolve this issue; or somebody else figures out why it is broken.

exotexot commented 1 year ago

:(

birdofpreyru commented 1 year ago

Hey @exotexot , I was considering to ping you, if you want to have a look at it :) I am even not sure, is it really broken for real projects, or only within the special setup used in this repo.

birdofpreyru commented 1 year ago

For the record — as of the commit referenced above, the debug build of Example App for Windows platform works again. The issue was with the Metro config for the particular setup of app & library used in the repo. Release build still fails — JS engine use in release mode by react-native-windows (Chakra) throws an error while interpreting generated JS bundle; while, I guess, the different JS engine used in debug mode (V8?) works fine with this bundle.

birdofpreyru commented 1 year ago

After some additional testing, it looks to me the problem is with react-native-fs not being compatible with RN v0.72.x on Windows in release mode — I tried it with a fresh RN project, and after adding a simple react-native-fs call to it I get the same behavior — it fails to start in the release mode, and it works fine in debug mode.

birdofpreyru commented 1 year ago

As of 87b23d16f8b4df2847a287c76a51bebc25be54b1 it is confirmed — the Example app works fine again, both in development and release modes, after the replacement of the original (and stale) react-native-fs by my upgraded fork of it, @dr.pogodin/react-native-fs.