You need to install the following tools:
Then, you can clone the repository and install the dependencies:
$ git clone [email protected]:umijs/mako.git
$ cd mako
Install dependencies.
$ cargo install just
$ cargo install cargo-binstall
$ cargo build
$ cargo build --release
Build js packages (include packages/mako).
$ pnpm build
Run mako with examples.
$ cargo run --bin mako examples/normal
# with HMR
$ cargo run --bin mako examples/normal --watch
# in production
$ cargo run --bin mako examples/normal --mode production
# filter logs
$ RUST_LOG=mako=debug,info cargo run --bin mako examples/normal
$ RUST_LOG=mako::parse=debug,info cargo run --bin mako examples/normal
Before you push your code, you should run the following commands to make sure everything is ok.
$ just ready
# without e2e
$ just ready-lite
Run tests.
$ pnpm playwright install # only need to run before the first time you run "jest test"
$ just test
# test specified testcase
$ cargo nextest run transformers::transform_try_resolve::tests
# review snapshot
$ cargo insta review
Run Coverage.
$ cargo codecov
$ cargo codecov --html && open target/llvm-cov/html/index.html
Use just fmt
to format the code.
Use just lint
to check the code style.
Upgrade dependencies if you need.
$ cargo upgrade
$ cargo upgrade --incompatible
$ cargo upgrade --dry-run
Benchmark with-antd example.
$ cargo build --release
$ time ./target/release/mako examples/with-antd
# or using hyperfine
$ hyperfine --runs 10 "./target/release/mako examples/with-antd"
Benchmark three10x.
$ just setup-bench
# default: --baseline master --case tmp/three10x --warmup 3 --runs 10
$ just bench
$ just bench --multiChunks
$ just bench --baseline v0.4.4
$ just bench --baseline v0.4.4 --case examples/with-antd
$ just bench --no-build
Performance analysis with puffin.
$ cargo build --release --features profile
$ ./target/release/mako examples/normal --mode=production
Performance analysis with Xcode instruments.
- Install Xcode App from Mac AppStore and switch xcode dev tool with:
$ sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
- Install cargo-instruments with:
$ cargo install cargo-instruments
# see instruments template:
$ cargo instruments --list-templates
- capture instruments trace with:
$ cargo instruments -t sys --profile release-debug --package mako --bin mako examples/with-antd
- you can open the trace file with instruments again with:
$ open target/instruments/mako_System-Trace_xxx.trace
Use mako in umi or bigfish.
$ OKAM=/PATH/TO/umijs/marko/packages/bundler-mako/index.js umi build
$ OKAM=/PATH/TO/umijs/marko/packages/bundler-mako/index.js umi dev
$ OKAM=/PATH/TO/umijs/marko/packages/bundler-mako/index.js max build
$ OKAM=/PATH/TO/umijs/marko/packages/bundler-mako/index.js bigfish build
Performance analysis with Xcode instruments in umi or bigfish.
$ XCODE_PROFILE=1 OKAM=/PATH/TO/umijs/marko/packages/bundler-mako/index.js umi build
$ XCODE_PROFILE=1 OKAM=/PATH/TO/umijs/marko/packages/bundler-mako/index.js umi dev
$ XCODE_PROFILE=1 OKAM=/PATH/TO/umijs/marko/packages/bundler-mako/index.js max build
$ XCODE_PROFILE=1 OKAM=/PATH/TO/umijs/marko/packages/bundler-mako/index.js bigfish build
Before release, please make sure everything is ok.
$ just ready
Open https://github.com/umijs/mako/actions?query=branch%3Amaster+event%3Apush to checkout the latest master push action with name "node-bind-build", and download the artifacts to packages/mako directory. If the artifacts has no commit hash in the name, you should add the commit hash manually.
$ git rev-parse HEAD
Then you can release the new version.
# Release @umijs/mako and @umijs/bundler-mako
$ npm run release
After release, you must do 2 things:
- Release the new version on github
- Update the changelog in CHANGELOG.md and CHANGELOG_zh-CN.md