Dynamic loading javascript using systemjs as not to load all the files at once?

There is a main file app.js where there is import {Router} from "./router". Router - this is a class which depending on the current url of the page creates an instance of the handler class of this village, for example, for the url /home/account-page it will create the handler return new AccountPageHandler(params). It turns out that the router importovana all the handlers of all pages (and sooo much). And when I do System.import('js/app.js'); I have loaded all scripts there, including and not needed - because they are all imported into the router, and the router is in app.js.

So how can you make so that were not imported all at once, and only what we want to use? I'm sure such a task has been informed many, but how to solve it - I have no idea because face it for the first time.

p.s. My generated js from ts (if it affects the solution of the problem).
July 4th 19 at 23:38
0 answer

Find more questions by tags JavaScript