0
I'm building an Angular library with ng-packagr. 

使用使用的打包库为我的应用程序提供服务时,我收到以下警告: 在此处输入图像描述 . 此外,在提供应用程序时,我收到以下错误消息: 在此处输入图像描述 在此处输入图像描述

core_1 与顶部的其他模块一起导入: import core_1, { Component, Inject, Injectable, InjectionToken, NgModule } from '@angular/core';

更新!! 配置如下:ng-package.json

{
  "$schema": "./node_modules/ng-packagr/ng-package.schema.json",
  "src": "lib",
  "dest": "dist/auth",
  "workingDirectory": ".ng_build",
  "lib": {
    "entryFile": "public_api.ts",
    "externals": {
      "oidc-client": "./node_modules/oidc-client/dist/oidc-client.min.js",
      "rxjs/add/operator/let": "Rx.Observable.prototype"
    }
  }
}

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "module": "es2015",
    "lib": [
      "es6",
      "dom"
    ],
    "moduleResolution": "node",
    "declaration": true,
    "experimentalDecorators": true,
    "baseUrl": ".",
    "stripInternal": true,
    "outDir": "./dist",
    "sourceMap": true,
    "inlineSources": true,
    "skipLibCheck": true
  },
  "exclude": [
    "node_modules",
    "dist",
    "demo",
    "config",
    "coverage",
    "src/**/*.spec.ts"
  ],
  "angularCompilerOptions": {
    "strictMetadataEmit": true,
    "skipTemplateCodegen": true,
    "trace": true
  }
}
4

1 回答 1

0

尤里卡

通过在库和角度项目中使用 tsconfig 进行修复:

  • tsconfig.lib.json
{
  "extends": "../../tsconfig.json",
  "compilerOptions": {
    //  these two lines
    "target": "es2015",
    "module": "esnext",
  },
  "angularCompilerOptions": {
    "annotateForClosureCompiler": true,
    "skipTemplateCodegen": true,
    "strictMetadataEmit": true,
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true,
    "enableResourceInlining": true
  },
  "exclude": [
    "src/test.ts",
    "**/*.spec.ts"
  ]
}

在目标项目中:

  • tsconfig.json
{
   "compilerOptions": {
       "module": "esnext"
    }
}
  • tsconfig.app.json
{
   "compilerOptions": {
       "module": "esnext"
    }
}
于 2019-09-16T08:16:03.957 回答