I've been attempting to configure the Angular 2 router using a JSON file, but no matter what I try, there seems to be an issue.
One failed test is:
let mEx = "../dashboard/dashboard.module#DashboardModule";
let mdEx = mEx.split('#');
let mymod =() => require(mdEx[0])[mdEx[1]];
{ path: 'dashboard', loadChildren:mymod}
When trying to load from a variable, I encounter this problem:
ERROR Error: Uncaught (in promise): Error: Cannot find module "."
EDIT: Another unsuccessful test:
let mymod = "app/dashboard/dashboard.module#DashboardModule";
{ path: 'dashboard', loadChildren:mymod}
In this scenario, the router cannot locate the module.
ERROR Error: Uncaught (in promise): Error: Cannot find module 'app/dashboard/dashboard.module'.
However, it works if I use
loadChildren:'app/dashboard/dashboard.module#DashboardModule'
But when using the module path in a variable, things get confusing... ;)
EDIT 2:
It appears that the issue may be related to the webpack ng-router-loader. I am investigating how to resolve this since my project relies on this library...
Do you have any suggestions on how to fix this? Thank you in advance.