As question states, would it be possible to build a simple html5 game and make it reusable as a npm/yarn package? IE take a html5 game and make it into a single React/Angular component and allow it to be included in angular/react/js projects? Are there any useful guides about how this is done? Thanks for any advice.
Asked
Active
Viewed 86 times
1
-
Does this answer your question? [Use npm package on client side](https://stackoverflow.com/questions/35071937/use-npm-package-on-client-side) – Christian Fritz Nov 02 '20 at 00:36
-
also see http://stackoverflow.com/questions/12893046/how-to-manage-client-side-javascript-dependencies – Christian Fritz Nov 02 '20 at 00:37
1 Answers
1
NPM packages are simply modules of code that are being downloaded and used, so you can put essentially anything you want into an NPM package and import it into any other project. I would look at NPM's documentation for publishing your own packages to get started, and here's a pretty good guide for React specifically from LogRocket.
Note that if you're using React or another framework, the project you're importing it into would have to support that framework, but apart from that there are no real limitations besides creating the actual package/game.

Chris B.
- 5,477
- 1
- 12
- 30
-
Hey thanks for the comment. With regards to your second point about how a package written in React (ie react component) can only be used in a React project, would it be better then to generally stick to making your packages pure js when you can? That way its "cross-tech stack" in the sense that you could use it in a pure js project, angular project, or react project? Thanks for your thoughts – Matt Nov 02 '20 at 00:50