2

将 ng-packagr 用于我的 Angular 6 和 AngularCLI 应用程序,它无法识别我的 tsconfig 路径,因为我进行了构建。正常的 ng build --aot --prod 工作正常。

这些是我的路径:

 "paths": {
    "@app/*": ["src/app/*"],
    "@env/*": ["src/environments/*"]
 }

我的 tsconfig.json:

{
  "compileOnSave": true,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "noImplicitAny": false,
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ],
    "paths": {
      "@app/*": ["src/app/*"],
      "@env/*": ["src/environments/*"]
    }
  }
}

我得到的错误往往是找不到模块....例如因为它不知道@app 是什么。

该应用程序在提供例如 npm start 时也可以正常工作。

4

1 回答 1

2

这已经是 ng-packagr 存储库中报告的问题,您可以将 tsconfig 配置复制到 ng-packagr 配置文件,因为 ng-packagr 没有从您的 tsconfig 读取,但它在 tgzing(构建)时具有其特定配置。

您可以在他们的 repo 线程中查看问题:

https://github.com/dherges/ng-packagr/issues/519

于 2018-07-18T13:43:38.637 回答