Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nodejs Project Management #2757

Closed
thetutlage opened this issue Apr 14, 2015 · 9 comments
Closed

Nodejs Project Management #2757

thetutlage opened this issue Apr 14, 2015 · 9 comments
Labels
Question An issue which isn't directly actionable in code

Comments

@thetutlage
Copy link

To me Typescript seems to be a better choice for writing code where the code base is huge and requires more consistency.

But the examples and experiences i find around the internet are more on client side , may be coz of the Angular2.0 decision to use AtScript/Typescript.

Though Typescript adds a lot of power to Javascript , there is something that keeps on pissing me off is how to manage codebase with duplicate files. According to my understanding i can have 2 ways to do it.

1st Way

Use a build tool like gulp/grunt , watch for changes and compile Typescript to Javascript in the same folder. which may look something like this.

├── models/
│ ├── User.ts
│ ├── User.js
│ ├── Likes.ts
│ ├── Likes.js

2nd Way

Another way will be the same but of instead of outputting Javascript into the same folder , i can clone the entire workspace.

├── typescript
│ ├── models/
│ │ ├── User.ts
│ │ ├── Likes.ts
├── javascript
│ ├── models/
│ │ ├── User.js
│ │ ├── Likes.js

Where both are not the best solution for me , is there any other way to manage codebase for nodejs. For client it is simple as we have only one output file.

@tinganho
Copy link
Contributor

I must say that this also pisses me off. I recommend the TypeScript team implement something like Browserify's bundling. It outputs everything into one file and you can both run it on the server and client.

@mhegazy
Copy link
Contributor

mhegazy commented Apr 14, 2015

@thetutlage you are looking to bundle all your outputs in one module, e.g. models.js (include both user.ts and likes.ts)?
if so, @tinganho has filed a similar issue (#2743) for bundling.

@thetutlage
Copy link
Author

@mhegazy Does it really make sense to bundle server code into one file ?

@mhegazy
Copy link
Contributor

mhegazy commented Apr 15, 2015

then i did not understand your proposal/request. can you elaborate?

@thetutlage
Copy link
Author

Sure , it is easy on client side to make easy of Typescript as i can easily bundle my entire code into 1 file.

But on server it is a problem as i will have a project structure which is not manageable according to me. So i was keen to know is there any best practice one can follow when using Typescript on Server ( with Node js ).

So in short the question is only related to code base management.

@mhegazy
Copy link
Contributor

mhegazy commented Apr 15, 2015

I do not think i have "best practices" to share per se. we use --out for the compiler code base, and emit only one file for our node package (see https://github.com/Microsoft/TypeScript/blob/master/bin/typescript.js).

In general I think bundling is similar on the server/client (in other words CommonJS/AMD). The same issue persists, you want as a developer to have a many files that represent your component, but want to hide this from your users by distributing a single file representing your component. I think if we end up doing bundling it will work for both AMD and CommonJS.

@thetutlage
Copy link
Author

Okay cool , it makes sense . I was just wondering may be there is a 3rd way.

@danquirk danquirk added the Question An issue which isn't directly actionable in code label Apr 15, 2015
@3nsoft
Copy link

3nsoft commented Apr 17, 2015

@thetutlage I am doing the following, using gulp building.

  1. all files go into logical places, irrespective of type js / ts.
  2. gulp takes a stream of js, and outputs it further down the pipe.
  3. js stream is merge2 (npm it) with gulp-typescript-ed pipe, which takes ts and compiles then to js. Result is a pipe with js in it.
    n) pipe may go into concat, browserify, just copy into dist folder, all depending on target(s).
    Skip (2) if all your sources are in ts.
    Set your IDE not to emit js files. Let gulp do it in a manner controlled by your script. Set names for your destination folders to be logical (dist-node, dist-browser, etc.), since "javascript" says nothing about intention (is it a source, should reader pay attention to it?).

@mhegazy
Copy link
Contributor

mhegazy commented Jun 12, 2015

Looks like there is no more information needed for this issue. closing.

@mhegazy mhegazy closed this as completed Jun 12, 2015
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

4 participants