问题
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",
]
}
回答1:
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.
回答2:
you can add this path to exclude in tsconfig below include property
"exclude": [
"path/to/module"
]
来源:https://stackoverflow.com/questions/61951542/lazy-loaded-modules-warnings-after-updating-angular-from-8-to-9