Friday, 17 March 2017

How to share code between client and server when using Node.js

So, I guess this question has been asked and answered before, but it seems like most questions seem to be about sharing code between client and server when the client and server code reside in the same project.

I have server code in Node.js (TypeScript), model classes specifically, that I want to re-use on the client, but the client and server code is completely separated. What are my best options for re-using that code?

Possible solution:

  • Publish all model classes as an npm package and install that in the client project

Cons: Have to create a new package every time something changes, feels too complicated.

What other options do I have?



via msk

No comments:

Post a Comment