【问题标题】:How to limit certain components from being used (imported) outside of their Nx lib?如何限制某些组件在其 Nx lib 之外使用(导入)?
【发布时间】:2020-07-30 09:41:11
【问题描述】:

想象一下这个典型的 Nx 文件结构代表我的项目。是否可以限制组件在其库之外被引用?

例如,我希望横幅组件在 ui 库中可用,但不能在数据库中导入。有很多“导入出血”正在发生,我想知道这是否可以限制并包含在他们自己的库中?

myorg/
    ├── apps/
    │   ├── todos/
    │   ├── todos-e2e/
    │   └── api/
    ├── libs/
    │   ├── data/
    │   └── ui/
    │       ├── src/
    │       │   ├── lib/
    │       │   │   ├─ banner/
    │       │   │   │      ├── banner.template.html
    │       │   │   │      ├── banner.component.ts
    │       │   │   └── ui.module.ts
    │       │   └── index.ts
    │       ├── jest.conf.js
    │       ├── tsconfig.app.json
    │       ├── tsconfig.json
    │       ├── tsconfig.spec.json
    │       └── tslint.json
    ├── nx.json
    ├── package.json
    ├── tools/
    ├── tsconfig.json
    └── tslint.json

【问题讨论】:

    标签: angular nrwl-nx nomachine-nx


    【解决方案1】:

    libs/ui/src/index.ts 文件中,您可以指定要导出的内容。选择您要导出的内容,而不是 export * from './lib/banner/banner

    【讨论】:

      猜你喜欢
      • 2019-06-09
      • 1970-01-01
      • 1970-01-01
      • 2019-11-10
      • 2021-11-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-09
      相关资源
      最近更新 更多