简体   繁体   English

Angualar 10:手动将描述(*d.ts)文件添加到编译

[英]Angualar 10 : Add descritpion (*d.ts) file manually to compilation

I have a angular library which has the description files *.d.ts.我有一个 angular 库,其中包含描述文件 *.d.ts。 in a below structure在下面的结构中

├ src
│  ├ my-lib
│  │   ├ my-typedef.d.ts
│  │      
│  │
│  └public_apit.ts
│  
└ tsconfig.lib.json

On tsconfig.lib.json i have include it like below:在 tsconfig.lib.json 上,我将其包含如下:

"include": [
    "src/lib/typedefs"
  ],

Edit编辑

Before upgrading to 10 it was set to angular 8. This files were compiled in the final build package, but after Angular 10. I am facing this issue.在升级到 10 之前,它被设置为 angular 8。这个文件是在最终版本 package 中编译的,但是在 Angular 10 之后。我面临这个问题。 though other folders are there but typedefs.虽然还有其他文件夹,但 typedefs。

I see on angular upgrade guidelines that we need to add manually but not sure what is the correct way.我在 angular 上看到我们需要手动添加的升级指南,但不确定什么是正确的方法。

We have updated the tsconfig.app.json to limit the files compiled.我们更新了 tsconfig.app.json 以限制编译的文件。 If you rely on other files being included in the compilation, such as a typings.d.ts file, you need to manually add it to the compilation.如果您依赖于编译中包含的其他文件,例如 typings.d.ts 文件,则需要手动将其添加到编译中。

https://update.angular.io/?l=3&v=8.0-9.0 https://update.angular.io/?l=3&v=8.0-9.0

repo to the issue: https://github.com/amirgc/angular10-ng-build.git回购问题: https://github.com/amirgc/angular10-ng-build.git

  • Download the repo.下载回购协议。
  • npm install npm 安装
  • ng build构建

I found out that this is the expected behavior as type definitions are not emitted with the upgdrade of ng-packagr .我发现这是预期的行为,因为类型定义不会随着ng-packagr的升级而发出。 If we want to emit type description.如果我们想发出类型描述。 To emit the.d.ts we can use the assets option, or alternatively change the file to a.ts extensions.要发出 .d.ts,我们可以使用 assets 选项,或者将文件更改为 a.ts 扩展名。 we can add below section on ng-package.json file.我们可以在 ng-package.json 文件中添加以下部分。

{
  "ngPackage": {
    "assets": [
      "CHANGELOG.md",
      "./typedefs/**/*.d.ts"
    ],
    "lib": {
      ...
    }
  }
}

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM