Given I have the following typescript package structure, with a src folder containing an inputs folder and a buttons folder (there would be more folders). Example structure below:
我有下面的typescript包结构,src文件夹包含一个inputs文件夹和一个buttons文件夹(还有更多的文件夹)。示例结构如下:
common-package/
src/
inputs/
TextBox.tsx
RadioButton.tsx
index.ts
buttons/
PrimaryButton.tsx
SecondaryButton.tsx
index.ts
index.ts
With a typescript package how can I allow barrel import with the file I want to use in another repo using the built package as well as direct sub paths for each component.
使用TypeScrip包,我如何使用构建的包和每个组件的直接子路径,允许在另一个repo中使用我想要使用的文件的桶导入。
Examples:
例如:
import { TextBox, RadioButton } from 'common-package'
and
和
import TextBox from 'common-package/TextBox'
import RadioButton from 'common-package/RadioButton'
I have looked into exports
and typeVersions
in the package.json
but this is extremely manual to have to create these individually and im looking for an automatic way to export all components by name after the package name. I dont want to have inputs or button folder naming in the module resolution path.
我已经研究了Package.json中的exports和typeVersion,但这是非常手动的,因为必须单独创建它们,我正在寻找一种自动方法来根据包名后面的名称导出所有组件。我不希望在模块解析路径中有输入或按钮文件夹命名。
更多回答
优秀答案推荐
我是一名优秀的程序员,十分优秀!