小编coo*_*kun的帖子

如何将 Turborepo 用于使用 Create React App 创建的现有 React 应用程序,以使其成为单一存储库?

我有一个用 create React app 制作的有趣项目。我想将同一应用程序转换为浏览器扩展。这个想法迫使我将该项目设为单一存储库。因为在这两个应用程序中,我将使用相同的组件、钩子、提供程序等。

我不想使用 Lerna 或 Yarn 工作区。而且,这将是我的第一个单一仓库。我想开始使用 Turborepo。但是,我无法想象如何让它以良好的方式工作。

我的目标文件夹结构如下

  • 应用/
    • 应用程序1/
    • 应用2/
  • 包/
    • 成分/
    • 钩子/
    • 提供商/
    • 款式/
  • 包.json
  • 包锁.json

我会将包文件夹中的 monorepo 依赖项导入到 apps 文件夹中存在的 apps 中。

例如;

import { useExampleHook } from '@projectname/hooks'
import { ExampleComponent } from '@projectname/components'
Run Code Online (Sandbox Code Playgroud)

如果您除了 Turborepo 之外还有其他解决方案,请随时告诉我。NPM 工作区也是一个可以接受的解决方案。但是,turborepo 由于性能更好而具有优先权。

预先感谢您的时间和答复

reactjs create-react-app monorepo npm-workspaces turborepo

11
推荐指数
1
解决办法
8317
查看次数

为什么 @testing-library/user-event 上不存在清除方法

我正在开发一个 CMS 项目,刚刚遇到一个问题。_userEvent.default.clear is not a function

\n\n
import user from \'@testing-library/user-event\'\n\ntest(\'can edit label\', async () => {\n    createArticleMock()\n    await renderRootAndInitStore(rightNowTeasers, globalInitialState)\n\n    const index = 1\n    const input = screen.getByDisplayValue(labels[index])\n    const newLabel = \'V\xc3\x84RLDEN\'\n    user.clear(input)\n    user.type(input, newLabel)\n\n    expect(await screen.findByDisplayValue(newLabel))\n    user.click(screen.getByTestId(\'settings-form-save\'))\n    await screen.findByText(newLabel)\n})\n
Run Code Online (Sandbox Code Playgroud)\n\n

当我访问时@testing-library/user-event,我看到那些线条

\n\n
// Definitions by: Wu Haotian <https://github.com/whtsky>\nexport interface IUserOptions {\n    allAtOnce?: boolean;\n    delay?: number;\n}\n\nexport interface ITabUserOptions {\n    shift?: boolean;\n    focusTrap?: Document | Element;\n}\n\nexport type TargetElement = Element | Window;\n\ndeclare const userEvent: {\n …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-testing-library user-event

6
推荐指数
1
解决办法
1万
查看次数