SystemJS introduction

SystemJS loads the files from top to bottom, and thereafter instantiates from bottom to top. What does that mean, though? Well, it means that if you have a file you need to load called Module1 that has a dependency on Module2, then Module1 will be loaded first. So much for loading, then we have the part on executing the code that takes the reverse direction. In this case it will execute Module2, to get an instance of it and pass it to Module1

A typical usage of SystemJS will look like the following:

System.import('./file.js').then( file => // do something )

There are different steps that SystemJS undertakes when processing a script:

  1. Normalizing file paths: Paths can be relative, absolute, and aliased, and SystemJS is turning all those into one format
  2. XHR or serve it up: When a module is asked for them, one of two things can happen; either it is loaded from the internal registry if it's already been preloaded before, or an XHR request is made for it
  3. Ready it for use: In this last step, the module will be executed, added to the registry, and it will resolve its promise
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset