简体   繁体   English

将 Angular 从 8 更新到 9 后延迟加载的模块警告

[英]Lazy-loaded modules warnings after updating Angular from 8 to 9

After Angular update all lazy-loaded modules return warning: Angular 更新所有延迟加载模块后返回警告:

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:我的 function 返回模块数组:

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.如果我用 static 数组替换 function ,那么一切似乎都很好。 Why?为什么?

My tsconfig.app.json:我的 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例如,假设我有以下.ts 文件: companySearchModel.ts

export class CompanySearchModel {
    //some properties
}

The import statement in another file, where the companySearchModel is used, looked like this:使用companySearchModel的另一个文件中的导入语句如下所示:

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您可以在包含属性下面的 tsconfig 中添加此路径以排除

"exclude": [
    "path/to/module"
  ]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 来自延迟加载组件的 Angular 2+ 访问/更改变量 - Angular 2+ Access/Change Variable from Lazy-Loaded component 从延迟加载的文件延迟加载时发生错误-angular.js - Error when lazy-loading from a lazy-loaded file - angular.js 如何从延迟加载的模块访问 AppModule 模块导入? - How do I Access AppModule Module imports from Lazy-loaded Modules? Angular:只有在授权时才从服务器加载延迟加载的模块(使用 JWT) - Angular: Only load lazy-loaded module from server if authorized (using JWT) 在从外部JSON文件构造的模板中使用延迟加载的Angular 2组件 - Consuming lazy-loaded Angular 2 components in a template constructed from an external JSON file 无法使用库中的嵌套延迟加载模块构建 angular 8 应用程序 - Cannot build angular 8 application with nested lazy-loaded module in library 组件无法从延迟加载的模块中找到提供程序 - component can't find provider from lazy-loaded module Vue 路由器如何在页面加载时获取延迟加载模块的当前路由路径? - How can Vue router get current route path of lazy-loaded modules on page load? 带有延迟加载图像的结构化数据? - Structured Data with Lazy-Loaded images? ui路由器的延迟加载状态 - lazy-loaded states with ui-router
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM