gpt4 book ai didi

Auto create subpath exports for typescript package(为TypeScrip包自动创建子路径导出)

转载 作者:bug小助手 更新时间:2023-10-28 21:20:06 30 4
gpt4 key购买 nike



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,但这是非常手动的,因为必须单独创建它们,我正在寻找一种自动方法来根据包名后面的名称导出所有组件。我不希望在模块解析路径中有输入或按钮文件夹命名。


更多回答
优秀答案推荐
更多回答

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com