Angular库导出一些意外类

时间:2019-06-11 15:55:33

标签: angular ng-packagr

在过去的几天里,我试图将类与某个项目分开,以使它们成为独立的库。克服了各种问题之后,我陷入了一些public_api问题。构建之后,我得到了这种library.d.ts文件

export * from './public_api';
export { LoggerToken as ac } from './lib/components/logger/loger.token';
export { SomeService as ae } from './lib/services/some.service';
export { SomeModule as ah } from './lib/sub/some.module';

我已尝试在导入/导出之间切换以使用/不使用桶文件,因为我发现一些信息可能会导致某些问题。还尝试过使用不同的角度版本(从ng6开始迁移到7和8,但总是相同的结果)

这是我的编译器选项

  "compilerOptions": {
    "outDir": "../../../out-tsc/lib",
    "target": "es2015",
    "module": "es2015",
    "moduleResolution": "node",
    "declaration": true,
    "sourceMap": true,
    "inlineSources": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "types": [],
    "lib": [
      "dom",
      "es2018"
    ]
  },
  "angularCompilerOptions": {
    "fullTemplateTypeCheck": true,
    "annotateForClosureCompiler": true,
    "enableResourceInlining": true,
    "skipTemplateCodegen": true,
    "strictMetadataEmit": true,
    "strictInjectionParameters": true
  },

起初,我尝试使用index.ts文件中的桶输出,但在读取可能会导致问题的信息后,我将其还原,要公开的每个类都直接从public_api.ts中导出

我认为这些导出不是必需的,因为它们都是lib的内部类(例如,library.d.ts中的导出模块仅包含来自外部库的某些导入,而且它们与某些导入冲突。尝试在--aot(-prod)项目中使用我的库后,其他库抛出错误,开发人员模式运行正常。

我很确定我在编译器或导出文件中弄乱了东西,但是找不到。

1 个答案:

答案 0 :(得分:0)

  

我很确定我在编译器或导出文件中弄乱了东西,但是找不到。

您没有犯任何错误。

from github import Github
# using username and password
# or using an access token
g = Github("***************************")
for repo in g.get_user().get_repos():
    print(repo.name)

print("**********Get Current Repos**********")
user = g.get_user()
user.login
print(user.login)
repo = g.get_repo("<any-repo>/<any-repo>")
repo.name
print(repo.name)
print("********Get the Repo Topics**************")

repo = g.get_repo("<any-repo>/<any-repo>")
repo.get_topics()
print(repo.get_topics())

print("*****Get the Star Count*************")
repo = g.get_repo("<any-repo>/<any-repo>")
repo.stargazers_count
print(repo.stargazers_count)
print("********Get the Open Issues*********")
repo = g.get_repo("<any-repo>/<any-repo>")
open_issues = repo.get_issues(state='open')
for issue in open_issues:
    print(issue)

print("******Get the Branch Count*******")
repo = g.get_repo("<any-repo>/<any-repo>")
print(list(repo.get_branches()))

以上是所有可注射引用。

虽然它们是您项目的内部。 Angular需要参考才能定义提供者。由于提供者是通过 instance 标识的,因此可以为他们提供 alias (ac,ae,ah),而Angular仍可以使用它们。

您会在webpack捆绑包中找到对(ac,ae,ah)的引用,但是没有其他人会使用它们。

相关问题