Coder Social home page Coder Social logo

kady's Introduction

monorepo 模式开发步骤

1.安装 pnpm,初始化并修改 package.json

{
  // 只允许使用pnpm进行开发
  // preinstall:在install之前(首次)执行
  // postinstall:在install之后(首次)执行
  "scripts": {
    "preinstall": "npx only-allow pnpm"
  },
  // 私有化包
  "private": true,
  // 定义服务启动版本
  "engines": {
    "node": ">=16"
  }
}

2.创建 pnpm.workspace.yaml

# 文章介绍,pnpm version 8.x
# 原文链接 https://pnpm.io/zh/workspaces
# 示例代码
packages:
  - "packages/**"

3.创建子包,初始化并且修改 package.json

{
  // 发布配置,因为主包设置了private私有化,子包想正常发布需要改为公共化
  "publishConfig": {
    "access": "public"
  }
}

4.子包命名规范,子包互相依赖

命名规范

{
  // 建议@主包名称/子包名称
  "name": "@kady/test"
}

互相依赖

# pnpm -F 是添加本地的包为依赖项
# 下面解释为:向@kady/test包里添加@kady/core包为生产依赖
pnpm -F @kady/test add @kady/core

kady's People

Contributors

jackandydo avatar

Watchers

Kady avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.