reasonml-q-a icon indicating copy to clipboard operation
reasonml-q-a copied to clipboard

ReasonReact quickstart instructions not working for me

Open vonwao opened this issue 5 years ago • 7 comments

Question

I try the steps listed on the ReasonReact homepage. After I npm run server, and open localhost:8000, I get this error in my browser:

This page isn’t working localhost sent an invalid response. ERR_INVALID_REDIRECT

I'm running this on Windows 10. Unfortunately, I have no idea what the problem could be.

Answer

This question hasn't been answered yet.

Further reading

vonwao avatar Feb 18 '20 18:02 vonwao

Note: the react template project uses moduleserve ./ --port 8000 to run the server. Maybe there's an alternative to this?

Note2: For completeness, the steps I used to generate and run this project were: cd my-react-app npm install && npm start Then open another tab and do: npm run server

vonwao avatar Feb 18 '20 18:02 vonwao

Hey @vonwao ! For starting out, I personally recommend @MargaretKrutikova's excellent minimal starter template: https://github.com/MargaretKrutikova/reason-minimal-template

It's a basic setup with webpack etc, and should "Just Work (tm)".

zth avatar Feb 18 '20 18:02 zth

If you prefer parcel than webpack there is a simple setup with TailwindCSS but you can just remove it: https://github.com/Faliszek/reason-parcel-tailwind

baransu avatar Feb 18 '20 18:02 baransu

If you prefer parcel than webpack there is a simple setup with TailwindCSS but you can just remove it: https://github.com/Faliszek/reason-parcel-tailwind

I had a bit of trouble using parcel myself, namely the hot reloading only worked if you saved the index.html or app.re file referenced in that file. It's not a huge deal, but was a bit annoying over time. Does anyone else have that problem working with reason / parcel and is there a fix?

mrispoli24 avatar Feb 20 '20 15:02 mrispoli24

Hmm, that shouldn't be really. One thing that's very important with webpack/parcel/any other bundler (and this should probably be its own thread) is to always run the BuckleScript compiler yourself, don't use any ReasonML plugins or reference Reason files directly with either Parcel or webpack.

You want the bundler to only see/use the emitted JS files, not do any form of Reason compilation. That way, whatever you do is just JavaScript, and therefore all features that work well with JavaScript should work equally well for you with Reason in this setup. And basically if it doesn't, something's not setup right.

The BuckleScript compiler is light years faster than any bundler out there, so I dare wage you're not going to notice any extra delay from this approach until you get to a size where you can probably dedicate an engineer to working on build performance ;)

zth avatar Feb 20 '20 15:02 zth

@zth this must be it and yes we should definitely make that its own thread since it took me a while to realize that you want to run your web compiler AND your bucklescript compiler. The speed of the bucklescript compiler is indeed insane.

mrispoli24 avatar Feb 20 '20 16:02 mrispoli24

Hey @vonwao ! For starting out, I personally recommend @MargaretKrutikova's excellent minimal starter template: https://github.com/MargaretKrutikova/reason-minimal-template

@zth Actually, this theme has also been merged into BuckleScript, so you can just do

bsb -init myProject -theme react-starter

to use it.

fhammerschmidt avatar Feb 20 '20 20:02 fhammerschmidt