gilamran / fullstack-typescript

FAST FullStack React with TypeScript starter kit.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

all server libs will be included in client dist?

d668 opened this issue · comments

commented

I don't get it, the idea usually is to separate libs for server and client. Let's say I use cities list (which is heavy) in my API. Will it be then shipped with the client?

Also how do I debug both client, server and shared lib? Will debugger go to shared lib if I set a breakpoint in client or API.

I mean all those things are obvious for a guy with .NET background, but I am amazed that they are not resolved in Node/Typescript community

Thanks for the comment!
Using the same library on the client and on the server is up to you. Same as you, I wouldn't want to use heavy libraries on the client.

This repo. gives you the ability to share your own code between the client and the server.
An obvious example would be is a Validation library that you wrote (Specific to your project), you can use the same library on the client and the server.
The code will get compiled and bundled (Using Webpack) for the client. On the other hand it will get compiled and served by node for the server code.

Note that the code is compiled twice!
Because it's the same exact code, you can assume that the types are correct for both the server and the client, add TypeScript to that, and you can be 100% sure that DTOs that move from the client to the server are valid!

Debugging the server will surly break on shared code, same for the client code.

You have to remember that .NET/Java/Scala developers who came from "higher" languages are very much used to "out of the box" environments, JavaScript came from the browser...

Hope that this helps, and I would love to elaborate if needed.

commented

Thanks for your reply :)
What I mean if I install a library via npm install cities-list --save but I import it only for the server, will it be included in client production webpack bundle (which I don't want)?

Nop, only the modules that you require / import will be included in the code.