Hacker News new | ask | show | jobs
by tamilvendhank 1082 days ago
Trying to reuse same code as it is written on both server and client is a bad idea.

As a language, JavaScript may support loading from file system or web. But, one of its use cases must not be code reuse on both client and server.

If I am to write a project in this way, how would it look like?

Assume, I write some server code in a server project that I want to use in client as well. How would I access that code from client? I need to make it accessible over internet. But, that is in a project that has other code as well, some of I do not want to be accessed over internet. What do I do? I will write rules in my web server to only allow access to specific files. Here and beyond, this process becomes complex and will get only worse.