简体   繁体   English

如果组件使用 Material UI 等外部库,Bit build 会引发错误?

[英]Bit build throws an error if a component uses external library like Material UI?

My use case:我的用例:

I have a Button component with Material UI.我有一个带有 Material UI 的 Button 组件。 I want to export that component to bit component, but while compiling the bit build , I get an error on Material UI modules:我想将该组件导出到位组件,但是在编译bit build时,我在 Material UI 模块上遇到错误:

错误截图

How do I isolate a component if it has external library dependencies?如果组件具有外部库依赖项,我如何隔离它?

You can reference dependencies (and peerDependencies) in the "workspace.jsonc" file like this:您可以像这样在“workspace.jsonc”文件中引用依赖项(和 peerDependencies):

"teambit.dependencies/dependency-resolver": {
  "packageManager": "teambit.dependencies/pnpm",
  "policy": {
    "dependencies": {
      "@angular/router": "13.0.3",
      "@ngrx/effects": "13.0.1",
      "@ngrx/store": "13.0.1",
      "@ngx-translate/core": "14.0.0"
    },
    "peerDependencies": {}
  }
},

Here is the documentation. 是文档。

Certain use cases need " Compositions " to use building blocks in isolation, mocking how a component would function in a project.某些用例需要“ 组合”来单独使用构建块,mocking 组件如何在项目中 function。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM