Search code examples
javascripttypescriptsystemjs

SystemJS - TypeScript loader use cases


I have a question regarding following TypeScript plugin for SystemJS :

https://github.com/frankwallis/plugin-typescript/

Here is its description

A plugin for SystemJS which enables you to System.import TypeScript files directly. The files are compiled in the browser and compilation errors written to the console.

I wonder what would be the use cases of such plugin.

  • Why would developers import directly ts files and compile them in the browser instead of compiling them during development and import js files ?
  • Won't it reduce performance and load time to do it in browser ?
  • Is it supposed to be used only in development environment ?

Solution

  • plugin-typescript author here. In-browser compilation is strictly a development tool, in production you would use systemjs-builder (in combination with plugin-typescript) to create a single file containing all of the transpiled javascript.

    Since the plugin was originally developed, a number of new workflows have become available when using typescript & systemjs (typescript single-file transpilation, vscode, systemjs hot-reloading, typescript system.register output, to name a few...) - Which one is right for you will depend on the size of your application, the platform/server you are using, and your own personal preferences.