由于外部库而构建时出现角度错误 - 意外值“BannerModule...”

2024-06-28

我使用 ng-packagr 模块创建了一个库,以便在两个不同的项目之间共享一些组件。

The structure of the lib is enter image description here

在我的图书馆里

src/package.json :

{
  "name": "my-ng-library",
  "version": "0.0.0",
  "license": "MIT",
  "ngPackage": {
    "$schema": "./node_modules/ng-packagr/ng-package.schema.json",
    "lib": {
      "entryFile": "index.ts"
    },
    "dest": "../dist"
  },
  "private": false,
  "dependencies": {},
  "peerDependencies": {
    "@angular/platform-browser": "^5.2.0",
    "@angular/platform-browser-dynamic": "^5.2.0",
    "@angular/core": "^5.2.0",
    "@angular/compiler": "^5.2.0",
    "@angular/forms": "^5.2.0",
    "@angular/http": "^5.2.0",
    "@angular/router": "^5.2.0",
    "@angular/common": "^5.2.0",
    "core-js": "^2.4.1",
    "rxjs": "^5.5.6",
    "zone.js": "^0.8.19",
    "compass-mixins": "^0.12.10"
  }
}

src/components/banner/banner.module.ts:

import { BannerComponent } from './banner.component';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

@NgModule({
  imports: [CommonModule],
  declarations: [BannerComponent],
  exports: [BannerComponent],
  providers: []
})
export class BannerModule { }

src/index.ts:

export { BannerModule } from './components/banner/banner.module';
export { BannerComponent } from './components/banner/banner.component';

在客户端应用程序中

应用程序模块.ts:

import { BannerModule } from 'my-ng-library/dist';
@NgModule({
  declarations:[
    BannerComponent
  ],
  imports: [
    BannerModule  
  ]
})

一切工作正常,在本地提供应用程序,但是当我尝试构建产品时,出现以下错误:

错误:由导入的意外值“/Users/username/Dev/Work/app-mobile-network-site/node_modules/my-ng-library/dist/components/banner/banner.module.d.ts”中的 BannerModule模块“/Users/username/Dev/Work/Essence/app-mobile-network-site/src/app/app.module.ts 中的 AppModule”。请添加@NgModule注释。


None

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

由于外部库而构建时出现角度错误 - 意外值“BannerModule...” 的相关文章

随机推荐