简体   繁体   中英

How many times a TypeScript file compiles?

I want to study typescript and start to build my idea by using MEAN technology stack but I am afraid that typescript needs to be run every time a user enters the website or it is only one time?

Typescript compiles to JavaScript when you run the ng build and it also optimizes codes. After build completes you will have an index.html plus .js files that each one is generated based on one of your lazy loaded modules.

You build your project once using the TypeScript compiler and that produces.js files that can be run directly in nodejs or the browser (depending upon which environment they were designed for).

This is one-time process. From then on, the only code that actually "runs" is the compiled output.js files.

So, NO TypeScript code does not need to be re-compiled every time a user enters a web-site.

Your code would typically be recompiled only when you modify it and wish to "build" the newer version of your code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM