【问题标题】:Bundling to UMD error could not resolve 'my-service' from dist\fesm5\my-api-name.js捆绑到 UMD 错误无法从 dist\fesm5\my-api-name.js 解析“my-service”
【发布时间】:2019-10-28 16:13:09
【问题描述】:

自本周末以来,来自 swagger open-api 3 规范文件的 angular 8.2.7 typescript 的客户端代码生成停止工作:

------------------------------------------------------------------------------
Building entry point '@my-company/my-api'
------------------------------------------------------------------------------
Compiling TypeScript sources through ngc
Bundling to FESM2015
WARNING: 'HttpResponse', 'HttpEvent' and 'HttpParameterCodec' are imported from external module '@angular/common/http' but never used
Bundling to FESM5
WARNING: 'HttpResponse', 'HttpEvent' and 'HttpParameterCodec' are imported from external module '@angular/common/http' but never used
Bundling to UMD
ERROR: Could not resolve './my.service' from dist\fesm5\my-generated-api-name.js

我尝试将“@openapitools/openapi-generator-cli”的先前版本:“0.0.19-4.1.2”恢复为“0.0.19-4.1.1”版本

我还在 https://petstore.swagger.io/ 尝试了一个虚拟的 open-api 3 规范测试文件,但我得到了同样的错误

调试日志没有说明我一无所知

这是我运行的 npm 命令:

"generate-front": "openapi-generator generate -i http://localhost:22953/swagger/v1/swagger.json -g typescript-angular -o ./code-front -c options-front.json"

这是选项文件:

{
    "npmName": "@my-company/my-api",
    "npmVersion": "0.18.0",
    "ngVersion": "8.2.7",
    "serviceSuffix": "Repository",
    "modelSuffix": "Model"
}

它应该没有错误地构建

【问题讨论】:

    标签: angular typescript openapi-generator


    【解决方案1】:

    问题在于 ng-packagr,它安装了具有重大更改的最新版本

    "ng-packagr": "^5.4.0"
    

    我摘下帽子,一切正常:

    "ng-packagr": "5.4.0"
    
    

    瞧!

    ------------------------------------------------------------------------------
    Building entry point '@my-company/my-api'
    ------------------------------------------------------------------------------
    Compiling TypeScript sources through ngc
    Bundling to FESM2015
    Bundling to FESM5
    Bundling to UMD
    Minifying UMD bundle
    Copying declaration files
    Writing package metadata
    Removing scripts section in package.json as it's considered a potential security vulnerability.
    Built @my-company/my-api
    
    ------------------------------------------------------------------------------
    Built Angular Package!
     - from: D:\my-dev-repo\openapi-codegen\code-front
     - to:   D:\my-dev-repo\openapi-codegen\code-front\dist
    ------------------------------------------------------------------------------
    

    【讨论】:

    猜你喜欢
    • 2021-06-19
    • 2014-01-11
    • 2015-08-31
    • 2019-08-09
    • 1970-01-01
    • 1970-01-01
    • 2020-08-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多