I'm building an Angular library with ng-packagr.
使用打包的库提供我的应用程序时,我收到此警告: 。此外,在为应用程序提供服务时,我收到此错误消息:
core_1与顶部的其他模块一起导入:
import core_1, { Component, Inject, Injectable, InjectionToken, NgModule } from '@angular/core';
UPDATE !! 配置如下: 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
}
}
答案 0 :(得分:0)
通过在库和Angular项目中同时使用tsconfig进行修复:
{
"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"
]
}
并在目标项目中:
{
"compilerOptions": {
"module": "esnext"
}
}
{
"compilerOptions": {
"module": "esnext"
}
}