7 Star 34 Fork 3

umijs / umi

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
CONTRIBUTING.md 2.32 KB
一键复制 编辑 原始数据 按行查看 历史
小虎oni 提交于 2021-05-10 17:17 . feat: bootstrap examples (#6535)

Contributing to umi

Set up

Install dev deps after git clone the repo.

# npm is not allowed.
$ yarn

Link umi globally.

$ cd packages/umi
$ yarn link
$ cd -

Try the umi cli.

$ yarn build
$ umi -v
umi@0.0.1-alpha.1@local

Build

Transform with babel and rollup.

$ yarn build

# Build and monitor file changes
$ yarn build --watch

# Build specified package only
$ PACKAGE=core yarn build --watch

Test

$ yarn test

# Test specified file and watch
$ yarn test getMockData.test.js -w

# Test specified package
$ yarn test --package core

# Generate coverage
$ yarn test --coverage

Release

$ npm run release
$ npm run release -- --publish-only
$ npm run release -- --skip-git-status-check
$ npm run release -- --skip-build
$ npm run release -- --otp

Create new package

Such as creating package foo.

$ mkdir -p packages/foo
$ yarn bootstrap

Then you will find the README.md and package.json is generated in packages/foo.

$ tree packages/foo
packages/foo
├── README.md
└── package.json

Upgrade dependencies

$ yarn update:deps

Docs

# add doc
$ yarn docs add docs/routing --title Routing

Examples

Umi 3 examples in examples/* directory

Running the Examples apps

Running examples:

yarn example dev examples/normal

Create new examples

Such as creating example hello-world.

$ mkdir -p examples/hello-world
$ yarn bootstrap:examples

Then you will find the README.md and package.json is generated in examples/hello-world.

$ tree examples/hello-world
examples/hello-world
├── pages/index.tsx
├── README.md
└── package.json

Benchmarks

if you want to add a benchmark, you can add examples/*/benchmark.js like this:

// examples/ssr-normal/benchmark.js
module.exports = (suite) => {
  // add tests
  suite
    // your logic
    .add('ssr#normal /')
    // your logic
    .add('ssr#normal#stream /');
};

and run yarn benchmark to see the result:

$ node scripts/benchmarks.js
☐  pending   building .../examples/ssr-normal
complete  success build .../examples/ssr-normal
ssr#normal / x 2,400 ops/sec ±2.08% (76 runs sampled)
ssr#normal#stream / x 4,026 ops/sec ±1.45% (50 runs sampled)
JavaScript
1
https://gitee.com/umijs/umi.git
git@gitee.com:umijs/umi.git
umijs
umi
umi
master

搜索帮助