import * as system from 'durandal/system'; import Home from './viewModels/about/about'; import { Dialogs } from './viewModels/dialogs/dialogs'; import { Widgets } from './viewModels/widgets/widgets'; const lazyModules = {}; const handleLazyRoute = (cb, moduleLocation) => { if (!Object.keys(lazyModules).find(a => a === moduleLocation)) { require([moduleLocation], (module) => { lazyModules[moduleLocation] = new module.default(); cb(null, lazyModules[moduleLocation]); }); } else { cb(null, lazyModules[moduleLocation]); } }; export const routes = [ { route: '', title: 'About', moduleId: () => { return Home; }, nav: true }, { route: 'router(/:id)*details', hash: '#router', title: 'Router', moduleId: (cb) => { // Async Route and Chunked handleLazyRoute(cb, './viewModels/router/index'); }, nav: true }, { route: 'dialogs', title: 'Dialogs', moduleId: () => { return Dialogs; }, nav: true }, { route: 'widgets', title: 'Widgets', moduleId: () => { return Widgets; }, nav: true }, { route: 'TenancyHub(/:id)', hash: '#TenancyHub', title: 'TenancyHub', moduleId: (cb) => { // Async Route and Chunked handleLazyRoute(cb, './viewModels/tenancy-hub/tenancy-hub'); }, nav: true } ];