Skip to content

Commit 61c5fbd

Browse files
authored
workflow: move to pnpm (vuejs#4766)
1 parent 3c500e4 commit 61c5fbd

19 files changed

+7097
-6844
lines changed

.github/contributing.md

+25-22
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Hi! I'm really excited that you are interested in contributing to Vue.js. Before
2828

2929
- If you are resolving a special issue, add `(fix #xxxx[,#xxxx])` (#xxxx is the issue id) in your PR title for a better release log, e.g. `update entities encoding/decoding (fix #3899)`.
3030
- Provide a detailed description of the bug in the PR. Live demo preferred.
31-
- Add appropriate test coverage if applicable. You can check the coverage of your code addition by running `yarn test --coverage`.
31+
- Add appropriate test coverage if applicable. You can check the coverage of your code addition by running `npm test -- --coverage`.
3232

3333
- It's OK to have multiple small commits as you work on the PR - GitHub can automatically squash them before merging.
3434

@@ -40,12 +40,14 @@ Hi! I'm really excited that you are interested in contributing to Vue.js. Before
4040

4141
## Development Setup
4242

43-
You will need [Node.js](https://nodejs.org) **version 10+**, and [Yarn 1.x](https://yarnpkg.com/en/docs/install).
43+
You will need [Node.js](https://nodejs.org) **version 10+**, and [PNPM](https://pnpm.io).
44+
45+
We also recommend installing [ni](https://github.com/antfu/ni) to help switching between repos using different package managers. `ni` also provides the handy `nr` command which running npm scripts easier.
4446

4547
After cloning the repo, run:
4648

4749
```bash
48-
$ yarn # install the dependencies of the project
50+
$ pnpm i # install the dependencies of the project
4951
```
5052

5153
A high level overview of tools used:
@@ -57,18 +59,20 @@ A high level overview of tools used:
5759

5860
## Scripts
5961

60-
### `yarn build`
62+
**The examples below will be using the `nr` command from the [ni](https://github.com/antfu/ni) package.** You can also use plain `npm run`, but you will need to pass all additional arguments after the command after an extra `--`. For example, `nr build runtime --all` is equivalent to `npm run build -- runtime --all`.
63+
64+
### `nr build`
6165

6266
The `build` script builds all public packages (packages without `private: true` in their `package.json`).
6367

6468
Packages to build can be specified with fuzzy matching:
6569

6670
```bash
6771
# build runtime-core only
68-
yarn build runtime-core
72+
nr build runtime-core
6973

7074
# build all packages matching "runtime"
71-
yarn build runtime --all
75+
nr build runtime --all
7276
```
7377

7478
#### Build Formats
@@ -91,13 +95,13 @@ More details about each of these formats can be found in the [`vue` package READ
9195
For example, to build `runtime-core` with the global build only:
9296

9397
```bash
94-
yarn build runtime-core -f global
98+
nr build runtime-core -f global
9599
```
96100

97101
Multiple formats can be specified as a comma-separated list:
98102

99103
```bash
100-
yarn build runtime-core -f esm-browser,cjs
104+
nr build runtime-core -f esm-browser,cjs
101105
```
102106

103107
#### Build with Source Maps
@@ -112,12 +116,12 @@ The `--types` or `-t` flag will generate type declarations during the build and
112116
- Generate an API report in `<projectRoot>/temp/<packageName>.api.md`. This report contains potential warnings emitted by [api-extractor](https://api-extractor.com/).
113117
- Generate an API model json in `<projectRoot>/temp/<packageName>.api.json`. This file can be used to generate a Markdown version of the exported APIs.
114118

115-
### `yarn dev`
119+
### `nr dev`
116120

117121
The `dev` script bundles a target package (default: `vue`) in a specified format (default: `global`) in dev mode and watches for changes. This is useful when you want to load up a build in an HTML page for quick debugging:
118122

119123
```bash
120-
$ yarn dev
124+
$ nr dev
121125

122126
> rollup v1.19.4
123127
> bundles packages/vue/src/index.ts → packages/vue/dist/vue.global.js...
@@ -129,31 +133,30 @@ $ yarn dev
129133

130134
- The `dev` script also supports the `-s` flag for generating source maps, but it will make rebuilds slower.
131135

132-
### `yarn dev-compiler`
136+
### `nr dev-compiler`
133137

134138
The `dev-compiler` script builds, watches and serves the [Template Explorer](https://github.com/vuejs/vue-next/tree/master/packages/template-explorer) at `http://localhost:5000`. This is extremely useful when working on the compiler.
135139

136-
### `yarn test`
140+
### `nr test`
137141

138142
The `test` script simply calls the `jest` binary, so all [Jest CLI Options](https://jestjs.io/docs/en/cli) can be used. Some examples:
139143

140144
```bash
141145
# run all tests
142-
$ yarn test
143-
144-
# run tests in watch mode
145-
$ yarn test --watch
146+
$ nr test
146147

147148
# run all tests under the runtime-core package
148-
$ yarn test runtime-core
149+
$ nr test runtime-core
149150

150151
# run tests in a specific file
151-
$ yarn test fileName
152+
$ nr test fileName
152153

153154
# run a specific test in a specific file
154-
$ yarn test fileName -t 'test name'
155+
$ nr test fileName -t 'test name'
155156
```
156157

158+
The default `test` script includes the `--runInBand` jest flag to improve test stability, especially for the CSS transition related tests. When you are testing specific test specs, you can also run `npx jest` with flags directly to speed up tests (jest runs them in parallel by default).
159+
157160
## Project Structure
158161

159162
This repository employs a [monorepo](https://en.wikipedia.org/wiki/Monorepo) setup which hosts a number of associated packages under the `packages` directory:
@@ -174,7 +177,7 @@ This repository employs a [monorepo](https://en.wikipedia.org/wiki/Monorepo) set
174177

175178
- `compiler-ssr`: Compiler that produces render functions optimized for server-side rendering.
176179

177-
- `template-explorer`: A development tool for debugging compiler output. You can run `yarn dev template-explorer` and open its `index.html` to get a repl of template compilation based on current source code.
180+
- `template-explorer`: A development tool for debugging compiler output. You can run `nr dev template-explorer` and open its `index.html` to get a repl of template compilation based on current source code.
178181

179182
A [live version](https://vue-next-template-explorer.netlify.com) of the template explorer is also available, which can be used for providing reproductions for compiler bugs. You can also pick the deployment for a specific commit from the [deploy logs](https://app.netlify.com/sites/vue-next-template-explorer/deploys).
180183

@@ -194,7 +197,7 @@ This is made possible via several configurations:
194197

195198
- For TypeScript, `compilerOptions.path` in `tsconfig.json`
196199
- For Jest, `moduleNameMapper` in `jest.config.js`
197-
- For plain Node.js, they are linked using [Yarn Workspaces](https://yarnpkg.com/blog/2017/08/02/introducing-workspaces/).
200+
- For plain Node.js, they are linked using [PNPM Workspaces](https://pnpm.io/workspaces).
198201

199202
### Package Dependencies
200203

@@ -245,7 +248,7 @@ Test coverage is continuously deployed at https://vue-next-coverage.netlify.app/
245248

246249
This project uses [tsd](https://github.com/SamVerschueren/tsd) to test the built definition files (`*.d.ts`).
247250

248-
Type tests are located in the `test-dts` directory. To run the dts tests, run `yarn test-dts`. Note that the type test requires all relevant `*.d.ts` files to be built first (and the script does it for you). Once the `d.ts` files are built and up-to-date, the tests can be re-run by simply running `yarn test-dts`.
251+
Type tests are located in the `test-dts` directory. To run the dts tests, run `nr test-dts`. Note that the type test requires all relevant `*.d.ts` files to be built first (and the script does it for you). Once the `d.ts` files are built and up-to-date, the tests can be re-run by simply running `nr test-dts`.
249252

250253
## Financial Contribution
251254

.github/workflows/ci.yml

+39-14
Original file line numberDiff line numberDiff line change
@@ -11,43 +11,68 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v2
14+
15+
- name: Install pnpm
16+
uses: pnpm/[email protected]
17+
with:
18+
version: 6.15.1
19+
1420
- name: Set node version to 16
1521
uses: actions/setup-node@v2
1622
with:
1723
node-version: 16
18-
cache: 'yarn'
19-
- run: yarn install --frozen-lockfile
24+
cache: 'pnpm'
25+
26+
- run: pnpm install
27+
2028
- name: Run unit tests
21-
run: yarn test --ci
29+
run: pnpm run test -- --ci
2230

2331
test-dts:
2432
runs-on: ubuntu-latest
2533
steps:
2634
- uses: actions/checkout@v2
35+
36+
- name: Install pnpm
37+
uses: pnpm/[email protected]
38+
with:
39+
version: 6.15.1
40+
2741
- name: Set node version to 16
2842
uses: actions/setup-node@v2
2943
with:
3044
node-version: 16
31-
cache: 'yarn'
32-
- run: yarn install --frozen-lockfile
45+
cache: 'pnpm'
46+
47+
- run: pnpm install
48+
3349
- name: Run type declaration tests
34-
run: yarn test-dts
50+
run: pnpm run test-dts
3551

3652
size:
3753
runs-on: ubuntu-latest
3854
env:
3955
CI_JOB_NUMBER: 1
4056
steps:
4157
- uses: actions/checkout@v1
58+
59+
- name: Install pnpm
60+
uses: pnpm/[email protected]
61+
with:
62+
version: 6.15.1
63+
4264
- name: Set node version to 16
4365
uses: actions/setup-node@v2
4466
with:
4567
node-version: 16
46-
cache: 'yarn'
47-
- run: yarn install --frozen-lockfile
48-
- name: Check build size
49-
uses: posva/[email protected]
50-
with:
51-
github_token: ${{ secrets.GITHUB_TOKEN }}
52-
build_script: size
53-
files: packages/vue/dist/vue.global.prod.js packages/runtime-dom/dist/runtime-dom.global.prod.js packages/size-check/dist/index.js
68+
cache: 'pnpm'
69+
70+
- run: pnpm install
71+
- run: pnpm run size
72+
73+
# - name: Check build size
74+
# uses: posva/[email protected]
75+
# with:
76+
# github_token: ${{ secrets.GITHUB_TOKEN }}
77+
# build_script: size
78+
# files: packages/vue/dist/vue.global.prod.js packages/runtime-dom/dist/runtime-dom.global.prod.js packages/size-check/dist/index.js

netlify.toml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build.environment]
2+
NODE_VERSION = "16"
3+
NPM_FLAGS = "--version" # prevent Netlify npm install

package.json

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
{
22
"private": true,
33
"version": "3.2.20",
4-
"workspaces": [
5-
"packages/*"
6-
],
74
"scripts": {
85
"dev": "node scripts/dev.js",
96
"build": "node scripts/build.js",
@@ -13,16 +10,16 @@
1310
"lint": "eslint --ext .ts packages/*/src/**.ts",
1411
"format": "prettier --write --parser typescript \"packages/**/*.ts?(x)\"",
1512
"test": "node scripts/build.js vue -f global -d && jest --runInBand",
16-
"test-dts": "node scripts/build.js shared reactivity runtime-core runtime-dom -dt -f esm-bundler && yarn test-dts-only",
13+
"test-dts": "node scripts/build.js shared reactivity runtime-core runtime-dom -dt -f esm-bundler && npm run test-dts-only",
1714
"test-dts-only": "tsc -p ./test-dts/tsconfig.json && tsc -p ./test-dts/tsconfig.build.json",
1815
"release": "node scripts/release.js",
1916
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
2017
"dev-compiler": "run-p \"dev template-explorer\" serve",
21-
"dev-sfc": "run-p \"dev compiler-sfc -f esm-browser\" \"dev runtime-core -f esm-bundler\" \"dev runtime-dom -f esm-bundler\" serve-sfc-playground",
18+
"dev-sfc": "run-p \"dev compiler-sfc -- -f esm-browser\" \"dev runtime-core -- -f esm-bundler\" \"dev runtime-dom -- -f esm-bundler\" serve-sfc-playground",
2219
"serve-sfc-playground": "vite packages/sfc-playground --host",
2320
"serve": "serve",
2421
"open": "open http://localhost:5000/packages/template-explorer/local.html",
25-
"preinstall": "node ./scripts/checkYarn.js",
22+
"preinstall": "node ./scripts/preinstall.js",
2623
"prebuild-sfc-playground": "node scripts/build.js compiler ref-transform shared -af cjs && node scripts/build.js runtime reactivity shared -af esm-bundler && node scripts/build.js vue -f esm-bundler-runtime && node scripts/build.js vue -f esm-browser-runtime && node scripts/build.js compiler-sfc -f esm-browser",
2724
"build-sfc-playground": "cd packages/sfc-playground && vite build"
2825
},
@@ -47,6 +44,10 @@
4744
"node": ">=16.5.0"
4845
},
4946
"devDependencies": {
47+
"vue": "workspace:*",
48+
"@vue/runtime-dom": "workspace:*",
49+
"@vue/runtime-core": "workspace:*",
50+
"@vue/reactivity": "workspace:*",
5051
"@babel/types": "^7.12.0",
5152
"@microsoft/api-extractor": "^7.15.1",
5253
"@rollup/plugin-commonjs": "^18.0.0",
@@ -85,6 +86,7 @@
8586
"yorkie": "^2.0.0",
8687
"lodash": "^4.17.15",
8788
"marked": "^0.7.0",
88-
"todomvc-app-css": "^2.3.0"
89+
"todomvc-app-css": "^2.3.0",
90+
"vite": "^2.6.0"
8991
}
9092
}

packages/sfc-playground/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
"serve": "vite preview"
99
},
1010
"devDependencies": {
11-
"@vitejs/plugin-vue": "^1.8.1",
12-
"vite": "^2.5.10"
11+
"@vitejs/plugin-vue": "^1.9.3"
1312
},
1413
"dependencies": {
14+
"vue": "workspace:*",
1515
"@vue/repl": "^0.4.3",
1616
"file-saver": "^2.0.5",
1717
"jszip": "^3.6.0"

packages/sfc-playground/vite.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function copyVuePlugin(): Plugin {
2828
if (!fs.existsSync(filePath)) {
2929
throw new Error(
3030
`vue.runtime.esm-browser.js not built. ` +
31-
`Run "yarn build vue -f esm-browser" first.`
31+
`Run "nr build vue -f esm-browser" first.`
3232
)
3333
}
3434
this.emitFile({

packages/size-check/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
"build": "vite build"
77
},
88
"devDependencies": {
9-
"vite": "^2.5.10"
9+
"vite": "^2.6.0"
1010
}
1111
}

packages/size-check/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { h, createApp } from 'vue'
1+
import { h, createApp } from '@vue/runtime-dom'
22

33
// The bare minimum code required for rendering something to the screen
44
createApp({

packages/size-check/vite.config.js

-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
export default {
2-
resolve: {
3-
alias: {
4-
vue: '@vue/runtime-dom/dist/runtime-dom.esm-bundler.js'
5-
}
6-
},
72
build: {
83
rollupOptions: {
94
input: ['src/index.ts'],

packages/template-explorer/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Live explorer for template compilation output.
44

55
To run:
66

7-
- `yarn dev-compiler`
8-
- When the compilation is done, in another terminal run `yarn open`
7+
- `npm run dev-compiler` in repo root
8+
- When the compilation is done, in another terminal run `npm run open`
99

1010
Note: `index.html` uses CDN for dependencies and is continuously deployed at [https://vue-next-template-explorer.netlify.com/](https://vue-next-template-explorer.netlify.com/). For local development, use the scripts above.

0 commit comments

Comments
 (0)