After Angular update all lazy-loaded modules return warning:
Error: [path/to/module/module-name.ts] is missing from the TypeScript
compilation. Please make sure it is in your tsconfig via the 'files'
or 'include' property.
My function which returns modules array:
export function manifests(prefix = '') {
return [
{
loadChildren: () => import(prefix + '/path/to/a.module').then(m => m.AModule),
path: 'a',
},
{
loadChildren: () => import(prefix + '/path/to/b.module').then(m => m.BModule),
path: 'b',
},
]
}
If I replace that function with static array everything seems to be fine, though. Why?
My tsconfig.app.json:
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": []
},
"files": [
"src/main.ts",
"src/polyfills.ts",
"src/zone-flags.ts",
],
"include": [
"src/**/*.d.ts",
]
}
In my case, for some reason, the file name in the import statements were capatilized.
For instance, let's say I had the following.ts file: companySearchModel.ts
export class CompanySearchModel {
//some properties
}
The import statement in another file, where the companySearchModel
is used, looked like this:
import { CompanySearchModel } from './models/CompanySearchModel.ts'
When it should have looked, like this:
import { CompanySearchModel } from './models/companySearchModel.ts'
Not sure why this happened, but hopefully this will help you.
you can add this path to exclude in tsconfig below include property
"exclude": [
"path/to/module"
]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.