Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workflow: switch to pnpm #5060

Merged
merged 32 commits into from
Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
39c7ac8
wip: some tests are not passing
yyx990803 Sep 23, 2021
36dc8da
build: link vite to root
yyx990803 Sep 23, 2021
bcd89da
wip: some progress
yyx990803 Sep 23, 2021
c06da90
wip: some test progress
yyx990803 Sep 23, 2021
3af0c1e
wip: fix more tests
yyx990803 Sep 23, 2021
8d67732
wip: more progress
yyx990803 Sep 23, 2021
aff8b20
wip: all tests pass!
yyx990803 Sep 23, 2021
f9fc4c1
ci: use pnpm on ci
yyx990803 Sep 23, 2021
02ad3f5
chore: lockfile
yyx990803 Sep 23, 2021
149b816
ci: update config
yyx990803 Sep 23, 2021
a79ca27
ci: make pnpm happy
yyx990803 Sep 23, 2021
9021caf
wip: save
yyx990803 Sep 23, 2021
3887379
ci: workaround pnpm file protocol issues
yyx990803 Sep 23, 2021
d86ec6e
ci: install pnpm first
yyx990803 Sep 23, 2021
96994d5
ci: fix pnpm run flags
yyx990803 Sep 23, 2021
8cc134b
ci: fix lint
yyx990803 Sep 23, 2021
110ffa7
ci: fix nested workspace package
yyx990803 Sep 23, 2021
3f64161
ci: simplify workspace config
yyx990803 Sep 23, 2021
e359558
chore: update yarn references
yyx990803 Sep 23, 2021
2ccaff6
docs: add note about pnpm file protocol
yyx990803 Sep 23, 2021
2b51670
ci: attemp to fix test case on windows
yyx990803 Sep 23, 2021
e90886d
ci: use consistent steps for lint
yyx990803 Sep 24, 2021
7017dae
docs: force docs to use locally built vite + use pnpm for netlify
yyx990803 Sep 24, 2021
b7dc93f
docs: fix netlify npm flags
yyx990803 Sep 24, 2021
f7ff379
fix: remove yarn usage in vite build script
yyx990803 Sep 24, 2021
6af8527
workflow: update release script [ci skip]
yyx990803 Sep 24, 2021
41356c5
chore: revert unintended test case change
yyx990803 Sep 24, 2021
3eadde3
chore: ignore pnpm files from prettier
yyx990803 Sep 24, 2021
a5cb940
chore: update jest ignore pattern
yyx990803 Sep 24, 2021
fd16627
ci: fix lint workflow
yyx990803 Sep 24, 2021
2a8b559
Merge branch 'main' into pnpm
yyx990803 Sep 24, 2021
7d86fde
Update CONTRIBUTING.md
yyx990803 Sep 24, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 15 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,22 @@ module.exports = defineConfig({
'node/no-missing-import': [
'error',
{
allowModules: ['types', 'estree', 'testUtils', 'stylus'],
allowModules: [
'types',
'estree',
'testUtils',
'less',
'sass',
'stylus'
],
tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts']
}
],
'node/no-missing-require': [
'error',
{
// for try-catching yarn pnp
allowModules: ['pnpapi'],
allowModules: ['pnpapi', 'vite'],
tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts']
}
],
Expand Down Expand Up @@ -91,6 +98,12 @@ module.exports = defineConfig({
'no-console': ['error']
}
},
{
files: ['packages/vite/types/**'],
rules: {
'node/no-extraneous-import': 'off'
}
},
{
files: ['packages/playground/**'],
rules: {
Expand Down
62 changes: 28 additions & 34 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,44 +33,34 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Install pnpm
uses: pnpm/action-setup@v2.0.1
with:
version: 6.15.1

- name: Set node version to ${{ matrix.node_version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node_version }}
cache: "pnpm"
Shinigami92 marked this conversation as resolved.
Show resolved Hide resolved

- name: Get yarn cache directory
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Set dependencies cache
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.node_version }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.node_version }}-${{ hashFiles('yarn.lock') }}
${{ runner.os }}-${{ matrix.node_version }}-

- name: Versions
run: yarn versions

- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Install deps
run: pnpm install

- name: Build vite
run: yarn ci-build-vite
run: pnpm run ci-build-vite
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you may actually keep the Yarn syntax here if you wish. run is optional with pnpm as well.

Though you still have to escape options with -- like you did. We will probably make that work without -- in the future (pnpm/pnpm#3778)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm just doing it for consistency's sake


- name: Build plugin-vue
run: yarn build-plugin-vue
run: pnpm run build-plugin-vue

- name: Build plugin-react
run: yarn build-plugin-react
run: pnpm run build-plugin-react

- name: Test serve
run: yarn test-serve --runInBand
run: pnpm run test-serve -- --runInBand

- name: Test build
run: yarn test-build --runInBand
run: pnpm run test-build -- --runInBand

lint:
runs-on: ubuntu-latest
Expand All @@ -85,20 +75,24 @@ jobs:
with:
node-version: 14

- name: Set dependencies cache
uses: actions/cache@v2
- name: Install pnpm
uses: pnpm/action-setup@v2.0.1
with:
path: ~/.cache/yarn
key: lint-dependencies-${{ hashFiles('yarn.lock') }}
restore-keys: |
lint-dependencies-${{ hashFiles('yarn.lock') }}
lint-dependencies-
version: 6.15.1

- name: Set node version to ${{ matrix.node_version }}
yyx990803 marked this conversation as resolved.
Show resolved Hide resolved
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node_version }}
cache: "pnpm"

- name: Install deps
run: pnpm install

- name: Prepare
run: |
yarn install --frozen-lockfile
yarn ci-build-vite
yarn build-plugin-vue
pnpm run ci-build-vite
pnpm run build-plugin-vue

- name: Lint
run: yarn lint
run: pnpm run lint
35 changes: 25 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ Hi! We are really excited that you are interested in contributing to Vite. Befor

## Repo Setup

The Vite repo is a monorepo using Yarn workspaces. The package manager used to install and link dependencies must be [Yarn v1](https://classic.yarnpkg.com/).
The Vite repo is a monorepo using pnpm workspaces. The package manager used to install and link dependencies must be [pnpm](https://pnpm.io/).

To development and test the core `vite` package:

1. Go to `packages/vite` and run `yarn dev`. This starts `tsc` in watch mode.
1. Go to `packages/vite` and run `pnpm run dev`. This starts `tsc` in watch mode.

2. Run `yarn link` in `packages/vite`. This links `vite` globally so that you can:
2. Run `pnpm link` in `packages/vite`. This links `vite` globally so that you can:

- Run `yarn link vite` in another Vite project to use the locally built Vite;
- Run `pnpm link vite` in another Vite project to use the locally built Vite;
- Use the `vite` binary anywhere.

## Running Tests
Expand All @@ -21,15 +21,15 @@ Each package under `packages/playground/` contains a `__tests__` directory. The

Each test can be run under either dev server mode or build mode.

- `yarn test` by default runs every test in both serve and build mode.
- `pnpm test` by default runs every test in both serve and build mode.

- `yarn test-serve` runs tests only under serve mode.
- `pnpm run test-serve` runs tests only under serve mode. This is just calling `jest` so you can pass any Jest flags to this command. Since Jest will attempt to run tests in parallel, if your machine has many cores this may cause flaky test failures with multiple Playwright instances running at the same time. You can force the tests to run in series with `pnpm run test-serve -- --runInBand`.

- `yarn test-build` runs tests only under build mode.
- `pnpm run test-build` runs tests only under build mode.

- You can also use `yarn test-serve [match]` or `yarn test-build [match]` to run tests in a specific playground package, e.g. `yarn test-serve css` will run tests for both `playground/css` and `playground/css-codesplit` under serve mode.
- You can also use `pnpm run test-serve -- [match]` or `pnpm run test-build -- [match]` to run tests in a specific playground package, e.g. `pnpm run test-serve -- css` will run tests for both `playground/css` and `playground/css-codesplit` under serve mode.

Note package matching is not available for the `yarn test` script, which always runs all tests.
Note package matching is not available for the `pnpm test` script, which always runs all tests.

### Test Env and Helpers

Expand Down Expand Up @@ -75,6 +75,21 @@ test('?raw import', async () => {
})
```

## Note on Test Dependencies

In many test cases we need to mock dependencies using `link:` and `file:` protocols (which are supported by package managers like `yarn` and `pnpm`). However, `pnpm` treats `link:` and `file:` the same way and always use symlinks. This can be undesirable in cases where we want the dependency to be actually copied into `node_modules`.

To work around this, playground packages that uses the `file:` protocol should also include the following `postinstall` script:

```json
"scripts": {
...
"postinstall": "node ../../../scripts/patchFileDeps"
}
```
yyx990803 marked this conversation as resolved.
Show resolved Hide resolved

This script patches the dependencies using `file:` protocol to match the copying behavior instead of linking.

## Debug Logging

You can set the `DEBUG` environment variable to turn on debugging logs. E.g. `DEBUG="vite:resolve"`. To see all debug logs you can set `DEBUG="vite:*"`, but be warned that it will be quite noisy. You can run `grep -r "createDebugger('vite:" packages/vite/src/` to see a list of available debug scopes.
Expand All @@ -92,7 +107,7 @@ You can set the `DEBUG` environment variable to turn on debugging logs. E.g. `DE

- 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. `fix: update entities encoding/decoding (fix #3899)`.
- Provide a detailed description of the bug in the PR. Live demo preferred.
- Add appropriate test coverage if applicable. You can check the coverage of your code addition by running `yarn test --coverage`.
- Add appropriate test coverage if applicable.

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

Expand Down
10 changes: 5 additions & 5 deletions docs/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,18 @@ You can specify additional CLI options like `--port` or `--https`. For a full li

## Using Unreleased Commits

If you can't wait for a new release to test the latest features, you will need to clone the [vite repo](https://github.com/vitejs/vite) to your local machine and then build and link it yourself ([Yarn 1.x](https://classic.yarnpkg.com/lang/en/) is required):
If you can't wait for a new release to test the latest features, you will need to clone the [vite repo](https://github.com/vitejs/vite) to your local machine and then build and link it yourself ([pnpm](https://pnpm.io/) is required):

```bash
git clone https://github.com/vitejs/vite.git
cd vite
yarn
pnpm install
cd packages/vite
yarn build
yarn link
pnpm run build
pnpm link # you can use your preferred package manager for this step
```

Then go to your Vite based project and run `yarn link vite`. Now restart the development server (`yarn dev`) to ride on the bleeding edge!
Then go to your Vite based project and run `pnpm link vite` (or the package manager that you used to link `vite` globally). Now restart the development server to ride on the bleeding edge!

## Community

Expand Down
6 changes: 6 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[build.environment]
NODE_VERSION = "16"
NPM_FLAGS = "--version" # prevent Netlify npm install
[build]
publish = "docs/.vitepress/dist"
command = "npx pnpm i --store=node_modules/.pnpm-store && npm run ci-docs"
20 changes: 15 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"node": ">=12.0.0"
},
"scripts": {
"preinstall": "node scripts/preinstall",
"format": "prettier --write .",
"lint": "eslint packages/*/{src,types}/**",
"test": "run-s test-serve test-build",
Expand All @@ -20,10 +21,10 @@
"build-docs": "vitepress build docs",
"serve-docs": "vitepress serve docs",
"build": "run-s build-vite build-plugin-vue build-plugin-react",
"build-vite": "cd packages/vite && yarn build",
"build-plugin-vue": "cd packages/plugin-vue && yarn build",
"build-plugin-react": "cd packages/plugin-react && yarn build",
"ci-build-vite": "cd packages/vite && yarn ci-build",
"build-vite": "cd packages/vite && npm run build",
"build-plugin-vue": "cd packages/plugin-vue && npm run build",
"build-plugin-react": "cd packages/plugin-react && npm run build",
"ci-build-vite": "cd packages/vite && npm run ci-build",
"ci-docs": "run-s build-vite build-plugin-vue build-docs"
},
"devDependencies": {
Expand Down Expand Up @@ -57,7 +58,10 @@
"ts-node": "^10.1.0",
"typescript": "~4.3.5",
"vitepress": "^0.19.1",
"yorkie": "^2.0.0"
"yorkie": "^2.0.0",
"rollup": "^2.57.0",
"esbuild": "^0.13.2",
"vite": "workspace:*"
},
"gitHooks": {
"pre-commit": "lint-staged --concurrent false",
Expand All @@ -73,5 +77,11 @@
"packages/**/*.d.ts": [
"eslint --ext .ts"
]
},
"pnpm": {
"overrides": {
"vite": "workspace:*",
"@vitejs/plugin-vue": "workspace:*"
}
}
}
2 changes: 1 addition & 1 deletion packages/create-vite/template-vue-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"serve": "vite preview"
},
"dependencies": {
"vue": "^3.2.13"
"vue": "^3.2.16"
},
"devDependencies": {
"@vitejs/plugin-vue": "^1.9.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-vite/template-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"serve": "vite preview"
},
"dependencies": {
"vue": "^3.2.13"
"vue": "^3.2.16"
},
"devDependencies": {
"@vitejs/plugin-vue": "^1.9.0",
Expand Down
5 changes: 4 additions & 1 deletion packages/playground/alias/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"serve": "vite preview"
},
"dependencies": {
"vue": "^3.2.13"
"vue": "^3.2.16"
},
"devDependencies": {
"resolve-linked": "workspace:*"
}
}
2 changes: 1 addition & 1 deletion packages/playground/extensions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"serve": "vite preview"
},
"dependencies": {
"vue": "^3.2.13"
"vue": "^3.2.16"
yyx990803 marked this conversation as resolved.
Show resolved Hide resolved
}
}
2 changes: 1 addition & 1 deletion packages/playground/file-delete-restore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
"react-dom": "^17.0.1"
},
"devDependencies": {
"@vitejs/plugin-react": "^1.0.0"
"@vitejs/plugin-react": "workspace:*"
}
}
2 changes: 1 addition & 1 deletion packages/playground/json/__tests__/json.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { isBuild } from '../../testUtils'

const json = require('../test.json')
const deepJson = require('@vue/runtime-core/package.json')
const deepJson = require('vue/package.json')
const stringified = JSON.stringify(json)
const deepStringified = JSON.stringify(deepJson)

Expand Down
2 changes: 1 addition & 1 deletion packages/playground/json/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h2>Raw Import</h2>

<script type="module">
import json, { hello } from './test.json'
import deepJson, { name } from '@vue/runtime-core/package.json'
import deepJson, { name } from 'vue/package.json'

text('.full', JSON.stringify(json))
text('.named', hello)
Expand Down
3 changes: 3 additions & 0 deletions packages/playground/json/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@
"build": "vite build",
"debug": "node --inspect-brk ../../vite/bin/vite",
"serve": "vite preview"
},
"devDependencies": {
"vue": "^3.2.16"
}
}
2 changes: 1 addition & 1 deletion packages/playground/legacy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"serve": "vite preview"
},
"devDependencies": {
"@vitejs/plugin-legacy": "^1.0.0"
"@vitejs/plugin-legacy": "workspace:*"
}
}
2 changes: 1 addition & 1 deletion packages/playground/nested-deps/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
'test-package-b',
'test-package-c',
'test-package-c/side',
'test-package-d > test-package-d-nested'
'test-package-d > test-package-d-nested'
yyx990803 marked this conversation as resolved.
Show resolved Hide resolved
],
exclude: ['test-package-d']
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"version": "1.0.0",
"main": "index.js",
"dependencies": {
"nested-include": "file:./nested-include"
"nested-include": "link:./nested-include"
}
}