SystemJs module loading

SystemJs is a module loader that understands both CommonJs module format, AMD module format, and even the new ES6 module format. It works in both Node and the browser, and as such describes itself as a universal module loader. Before SystemJs came along, Node-based solutions used CommonJs format, and browser-based solutions used AMD format.

Now we can use CommonJs format in the browser, and even mix and match module syntax. In this section, we will take a look at how to configure SystemJS for loading CommonJs modules in the browser.

SystemJs installation

SystemJs can be installed using npm as follows:

npm install systemjs --save

The relevant declaration files can be installed using @types as follows:

npm install @types/systemjs ...

Get Mastering TypeScript - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.