I followed this tutorial to add lazy loading to my app. Everything works fine on local server but when I publish my app I get error module cannot be found.I am using Angular Compiler Plugin.Here is my package.json
"dependencies": {
"@angular/animations": "^5.0.0",
"@angular/cdk": "^5.0.0",
"@angular/common": "^5.0.0",
"@angular/compiler": "^5.0.0",
"@angular/compiler-cli": "^5.0.0",
"@angular/core": "^5.0.0",
"@angular/forms": "^5.0.0",
"@angular/http": "^5.0.0",
"@angular/material": "^5.0.0",
"@angular/material-moment-adapter": "^5.0.0",
"@angular/platform-browser": "^5.0.0",
"@angular/platform-browser-dynamic": "^5.0.0",
"@angular/platform-server": "^5.0.0",
"@angular/router": "^5.0.0",
"@ngtools/webpack": "^1.9.0",
"@types/webpack-env": "1.13.0",
"angular-router-loader": "^0.8.0",
"angular2-infinite-scroll": "^0.3.5",
"angular2-template-loader": "0.6.2",
"aspnet-prerendering": "^3.0.1",
"aspnet-webpack": "^2.0.1",
"awesome-typescript-loader": "3.2.1",
"bootstrap": "^3.3.7",
"bootstrap-select": "^1.12.4",
"css": "2.2.1",
"css-loader": "0.28.4",
"es6-shim": "0.35.3",
"event-source-polyfill": "0.0.9",
"expose-loader": "0.7.3",
"extract-text-webpack-plugin": "2.1.2",
"file-loader": "0.11.2",
"font-awesome": "^4.7.0",
"hammerjs": "^2.0.8",
"html-loader": "0.4.5",
"isomorphic-fetch": "2.2.1",
"jquery": "^3.2.1",
"json-loader": "0.5.4",
"moment": "^2.19.4",
"ng2-auto-complete": "^0.12.0",
"ngx-bootstrap": "^1.9.3",
"preboot": "4.5.2",
"raw-loader": "0.5.1",
"reflect-metadata": "0.1.10",
"rxjs": "^5.5.2",
"select2": "^4.0.4",
"style-loader": "0.18.2",
"to-string-loader": "1.1.5",
"typescript": "2.4.2",
"url-loader": "0.5.9",
"webpack": "2.5.1",
"webpack-hot-middleware": "2.18.2",
"webpack-merge": "4.1.0",
"zone.js": "0.8.12"
}
I also tried to load my components with a difrent approach like this:
path: 'hero', loadChildren: () => {
return Promise.resolve(require('./components/hero/hero.module')['HeroModule']);
}
but then I get error Index signature of object type implicitly has an 'any' type.