Skip to content
This repository has been archived by the owner on Apr 8, 2020. It is now read-only.

Question about the new main-server file #340

Closed
rbasniak opened this issue Sep 28, 2016 · 2 comments
Closed

Question about the new main-server file #340

rbasniak opened this issue Sep 28, 2016 · 2 comments

Comments

@rbasniak
Copy link

Hi, I just sync with the latest commits and I didn't understand one thing: now the webpack script is publishing main-server.js to the ClientApp folder.

Now when you publish your application you have all ASP files and folders and in the middle of them you have a ClientApp folder which actually contains server code.

This seems very strange to me. Isn't wwwroot folder more suitable for the compiled TypeScript files?

@rbasniak rbasniak changed the title Question about the last update Question about the new main-server file Sep 28, 2016
@SteveSandersonMS
Copy link
Member

SteveSandersonMS commented Sep 29, 2016

Now when you publish your application you have all ASP files and folders and in the middle of them you have a ClientApp folder which actually contains server code.

I see your point! From that perspective, the naming does now seem a little strange.

Maybe it should be renamed to something like ClientApp/dist/main-prerendering.js, since that's what it's for. It really is your client-side app (since that's the primary place it runs and where most of the functionality is), and this is just a file for prerendering it on the server. Server-side execution is very much secondary to client-side execution - it is really just "prerendering" what will be rendered on the client.

But at the same time, calling it main-server.js is helpful because it emphasises that this file is going to run on the server (and isn't being "prerendered" on the client somehow), which influences what sort of things you can do there. For example, you can't pop open alert boxes or reference the DOM.

Isn't wwwroot folder more suitable for the compiled TypeScript files?

In this case, not really, since wwwroot files are served publicly to the whole world, and you wouldn't want to serve your main-server.js file to browsers (partly because there's no point, and partly because you probably have source maps enabled in it, so you'd be exposing your TS source code which not everyone wants to do).

Edit: previously I was thinking about alternative names for ClientApp, such as AngularApp, KnockoutApp, etc., but on reflection that would not be good, as we generally name things for what purpose they serve, rather than what brand of technology they are built with. Hence ClientApp, because the primary purpose is a rich client-side UI.

@SteveSandersonMS
Copy link
Member

I'll close this because, after reflection, it seems like we're already in the right place with this. But it's only a project template and we can always change it in the future if the need becomes clear.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants