I have Googled this a lot and cannot seem to find anything on this topic. I have been working on a Typescript Angular 2 application and have my tooling set up to compile my .ts files into JavaScript locally and the JavaScript files are served to the browser.
I just recently realized that I can include the typescript.js and tweak the System.config a little and avoid having to compile the .ts files locally and allow it to happen in the browser at run time.
My question, is in browser transpilation an issue? Should I be concerned with performance as my app grows larger? Common sense tells me yes but I was looking for some feedback from those that have experience with this set up.
Typescript does transpile into Javascript. In your tsconfig configuration file, you can specify which is the target language you want it transpiled to. That means you can already work with cutting edge ECMAScript features out of the box.
Because browsers and Node. js process only JavaScript, you have to compile your TypeScript code before running or debugging it. Compilation can also produce source maps that set correspondence between your TypeScript code and the JavaScript code that is actually executed.
js and it supports ES6 features, you don't need to transpile your code. Your code only works in the same place, if it is hosted in one place. Transpiler is used, when your code is written in newer versions, there may be users which use browsers with old versions of Javascript.
Hence, the TypeScript code needs to get compiled into JavaScript, and for that, you need the TypeScript compiler. You can install TypeScript globally using the following npm command.
Browser compilation is nice for creating a Plunker or similar but for production definitely go with transpiling before deployment. Performance and download size and time will suffer with in-browser transpilation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With