hmil / RosHTTP

Unified Scala.js + Scala HTTP client API
MIT License
126 stars 24 forks source link

Return None from require if module does not exist #70

Closed Mahoney closed 6 years ago

Mahoney commented 7 years ago

This will change the behaviour of fr.hmil.roshttp.node.Helpers.require to return None if the global require method exists but the required module does not exist.

In a browser environment packaged by scalajs-bundle the require method may be defined in order to allow interop with common js modules, and it returns undefined if the desired module does not exist. The result is that RosHTTP never uses the Browser driver but fails with scala.scalajs.js.JavaScriptException: TypeError: Cannot read property 'request' of undefined.

hmil commented 7 years ago

Hi @Mahoney ,

That seems like a reasonable fix. There's something wrong with the build however and I don't have much time to look into it right now. If you need this merged fast I suggest you look into the problem even though it doesn't seem related to your patch.

Thanks