nathankellenicki / node-poweredup

A Javascript module to interface with LEGO Powered Up components.
https://nathankellenicki.github.io/node-poweredup/
MIT License
477 stars 59 forks source link

Cannot Be Used In JS Frameworks (React/Vue/etc) #138

Closed adamleemiller closed 2 years ago

adamleemiller commented 2 years ago

Hello! First off I want to say that you've done an great job with this module. As a JS developer for many years now and a 20+ year IT Professional who loves to build with LEGO (along with my kids), I am finally getting into LEGO PoweredUp and came across your module. I verified that it worked using the browser (Chrome ONLY, for those that are curious as FF does not have support for WebBLE, yet) however when I imported the module into Vue 3 so that I could build a small app that would eventually be used for a Science Fair Project, I was unable to actual get the library to work correctly. After some digging and getting some assistance from another developer, we were able to determine that the browser version does not actually export anything and instead, creates a DOM object called "window.PoweredUP". Unfortunately, this will not work in modern JS UI frameworks such as React and Vue. I would like to possibly contribute another option so that we can import the module into a modern JS UI framework. Would this be OK with you?

Thank you.

nathankellenicki commented 2 years ago

Hi Adam, thanks for the kind words!

For modern UI libraries like React its standard practice to use a webpack toolchain in order to package and chunk dependencies into a minimized bundle. If you're using create-react-app that's set up for you automatically.

As such, instead of using the JS library as a Githubissues.

  • Githubissues is a development platform for aggregating issues.