Explorar el Código

Update package.json, pnpm-lock.yaml, and pnpm-workspace.yaml to restructure the monorepo. Changed project name to @monorepo/root, added workspace configuration, and defined dependencies for React, React Router, and Ant Design. Enhanced scripts for building and cleaning packages, and updated package manager settings for pnpm.

xbx hace 11 meses
padre
commit
4e28995628
Se han modificado 7 ficheros con 1631 adiciones y 5 borrados
  1. 8 0
      .npmrc
  2. 37 4
      package.json
  3. 34 0
      packages/ui/index.js
  4. 23 0
      packages/ui/package.json
  5. 1482 1
      pnpm-lock.yaml
  6. 17 0
      pnpm-workspace.yaml
  7. 30 0
      turbo.json

+ 8 - 0
.npmrc

@@ -0,0 +1,8 @@
+shared-workspace-lockfile=true
+node-linker=hoisted
+shamefully-hoist=true
+link-workspace-packages=true
+prefer-workspace-packages=true
+save-workspace-protocol=false
+public-hoist-pattern=*
+hoist-pattern=* 

+ 37 - 4
package.json

@@ -1,16 +1,49 @@
 {
-  "name": "monorepo_react",
+  "name": "@monorepo/root",
   "version": "1.0.0",
   "description": "",
   "main": "index.js",
   "scripts": {
-    "test": "echo \"Error: no test specified\" && exit 1"
+    "test": "echo \"Error: no test specified\" && exit 1",
+    "preinstall": "npx only-allow pnpm",
+    "postinstall": "pnpm run build",
+    "build": "echo \"Building packages...\" && pnpm -r build",
+    "clean": "rimraf node_modules **/node_modules",
+    "init": "pnpm clean && pnpm install"
   },
   "keywords": [],
+  "private": true,
+  "workspaces": [
+    "packages/*"
+  ],
   "author": "",
   "license": "ISC",
   "packageManager": "pnpm@10.12.1",
+  "engines": {
+    "node": ">=20.0.0",
+    "pnpm": ">=9.0.0"
+  },
+  "dependencies": {},
   "devDependencies": {
-    "turbo": "^2.5.4"
-  }
+    "antd": "catalog:",
+    "axios": "catalog:",
+    "dayjs": "catalog:",
+    "react": "catalog:",
+    "react-dom": "catalog:",
+    "rimraf": "catalog:",
+    "turbo": "catalog:",
+    "react-router": "catalog:",
+    "react-router-dom": "catalog:"
+  },
+  "pnpm": {
+    "peerDependencyRules": {
+      "allowedVersions": {
+        "eslint": "*"
+      }
+    }
+  },
+  "neverBuiltDependencies": [
+    "canvas",
+    "node-gyp"
+  ]
 }

+ 34 - 0
packages/ui/index.js

@@ -0,0 +1,34 @@
+// 从antd导出组件
+export {
+  Button,
+  Input,
+  Select,
+  Table,
+  Form,
+  Layout,
+  Menu,
+  Pagination,
+  Modal,
+  notification,
+  message,
+  DatePicker,
+  ConfigProvider,
+  Space,
+  Typography,
+  Spin,
+  Card,
+  Tabs,
+  Popconfirm,
+  Drawer,
+  Avatar
+} from 'antd';
+
+// 导出antd样式
+import 'antd/dist/reset.css';
+
+// 示例:如何在组件中使用共享依赖
+// const React = require('@monorepo/shared/react');
+// const _ = require('@monorepo/shared/lodash');
+
+// 你可以在这里添加自定义组件
+// export { default as CustomComponent } from './components/CustomComponent'; 

+ 23 - 0
packages/ui/package.json

@@ -0,0 +1,23 @@
+{
+  "name": "@monorepo/ui",
+  "version": "1.0.0",
+  "description": "共享UI组件库",
+  "main": "index.js",
+  "scripts": {
+    "test": "echo \"Error: no test specified\" && exit 1",
+    "build": "echo \"Building UI package...\""
+  },
+  "keywords": [],
+  "author": "",
+  "license": "ISC",
+  "dependencies": {
+    "antd": "catalog:",
+    "react": "catalog:",
+    "react-dom": "catalog:"
+  },
+  "peerDependencies": {
+    "react": "^19.0.0",
+    "react-dom": "^19.0.0"
+  },
+  "devDependencies": {}
+}

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 1482 - 1
pnpm-lock.yaml


+ 17 - 0
pnpm-workspace.yaml

@@ -0,0 +1,17 @@
+packages:
+  - packages/*
+  - app/*
+  - .
+
+catalog:
+  react: ^19.1.0
+  react-dom: ^19.1.0
+  react-router: ^6.16.0
+  react-router-dom: ^6.16.0
+  dayjs: ^1.11.10
+  axios: ^1.6.7
+  antd: ^5.26.3
+  turbo: ^2.5.4
+  rimraf: ^5.0.5
+
+shared-workspace-lockfile: true

+ 30 - 0
turbo.json

@@ -0,0 +1,30 @@
+{
+    "$schema": "https://turbo.build/schema.json",
+    "tasks": {
+      "build": {
+        "dependsOn": ["^build"],
+        "outputs": ["dist/**", "build/**","dist.zip"]
+      },
+      "dev": {
+        "cache": false,
+        "persistent": true
+      },
+      "lint": {
+        "outputs": []
+      },
+      "build:analyze": {
+      "dependsOn": ["^build"],
+      "outputs": ["dist/**"]
+    },
+      "test": {
+        "dependsOn": ["build"],
+        "outputs": []
+      },
+      "clean": {
+        "cache": false
+      },
+      "remoteCache": {
+        
+      }
+    }
+  }