我正在制作一个跨平台的 react monorepo,我想单独使用组件,即 import User from 'components/User'
而不是 import { User } from 'components'
这是为了加快构建/重建时间,因为并非我的 monorepo 中的每个应用都需要所有组件。
我该怎么做?
我使用 babel 来转译我的组件库:
// packages/components/package.json
{
"name": "@monorepo/components",
"version": "0.0.1",
"private": true,
"main": "build/index.js",
"scripts": {
"dev": "babel src --out-dir build --watch",
"build": "babel src --out-dir build",
}
}