japgolly / scalajs-react

Facebook's React on Scala.JS
https://japgolly.github.io/scalajs-react/
Apache License 2.0
1.64k stars 231 forks source link

Document a brief note in the Usage & Getting Started > Setup about scalajs-bundler flavors #1056

Closed nsubordin81 closed 2 years ago

nsubordin81 commented 2 years ago

@japgolly this library is phenomenal and so are you for creating/maintaining it it. I'm not very active on OSS at least not yet so idk if addressing the issue to you or a general contributor makes sense but here goes:

Summary

As someone who is brand new to scalajs and is not great at RTFM sometimes, I think someone else like me might find it helpful if there is a note that scalajs-bundler as a dependency has both node platform and web platform variants to choose from.

what happened I am building a simple test page with scalajs-react and ran into the console error Uncaught ReferenceError: require is not defined when trying to import react into my compiled main.js because I just grabbed the first set of plugin instructions off of the linked scalajs-bundler page and didn't read to the bottom where they point out the web version is available for the js script output to run on the browser. It took me a few of my work sessions to figure out , just kind of doing this for fun/edification so I am working on it in short bursts but yeah even as I write this I feel like it is a prerequisite to be familiar with how scalajs works with node vs. browser side and if I was my error would have been immediately apparent.

suggestion So up to you, I totally get expecting users to come prepared and not muddying up your docs to cater to a relative neophyte in this space like myself, but just wanted to be a data point of someone who had a small sticking point on the setup docs. My take or leave suggestion I guess would be something like a 'be advised there are 2 versions of sbt-bundler and be sure to pick the version that is appropriate to your platform (node vs. web)'

Thank you and keep up the amazing work!

nsubordin81 commented 2 years ago

closing this, I believe I had a different issue so the documentation I was asking to add isn't helpful. Sorry for the spam

nsubordin81 commented 2 years ago

yeah it wasn't the version of bundler I was using, that whole lib is for using npm packages in a browser with webpack.. My issue, at least I think, was that I was running fastLinkJS and I had the Compile / instruction for the react and react dom dependencies in my build.sbt and I was expecting the webpack task of the bundler plugin to execute, but I've only been able to trigger the webpack compilation with an explicit Compile / fastOptJS / webpack in sbt