Skip to content

Commit 60c1b91

Browse files
authored
Merge branch 'vuejs:main' into fix/7095
2 parents 473c7b8 + 98f1934 commit 60c1b91

File tree

323 files changed

+10947
-8651
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

323 files changed

+10947
-8651
lines changed

.eslintrc.js renamed to .eslintrc.cjs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = {
66
parserOptions: {
77
sourceType: 'module'
88
},
9-
plugins: ["jest"],
9+
plugins: ['jest'],
1010
rules: {
1111
'no-debugger': 'error',
1212
'no-unused-vars': [
@@ -17,20 +17,22 @@ module.exports = {
1717
],
1818
// most of the codebase are expected to be env agnostic
1919
'no-restricted-globals': ['error', ...DOMGlobals, ...NodeGlobals],
20-
// since we target ES2015 for baseline support, we need to forbid object
21-
// rest spread usage in destructure as it compiles into a verbose helper.
22-
// TS now compiles assignment spread into Object.assign() calls so that
23-
// is allowed.
20+
2421
'no-restricted-syntax': [
2522
'error',
23+
// since we target ES2015 for baseline support, we need to forbid object
24+
// rest spread usage in destructure as it compiles into a verbose helper.
2625
'ObjectPattern > RestElement',
26+
// tsc compiles assignment spread into Object.assign() calls, but esbuild
27+
// still generates verbose helpers, so spread assignment is also prohiboted
28+
'ObjectExpression > SpreadElement',
2729
'AwaitExpression'
2830
]
2931
},
3032
overrides: [
3133
// tests, no restrictions (runs in Node / jest with jsdom)
3234
{
33-
files: ['**/__tests__/**', 'test-dts/**'],
35+
files: ['**/__tests__/**', 'packages/dts-test/**'],
3436
rules: {
3537
'no-restricted-globals': 'off',
3638
'no-restricted-syntax': 'off',
@@ -72,7 +74,12 @@ module.exports = {
7274
},
7375
// Node scripts
7476
{
75-
files: ['scripts/**', './*.js', 'packages/**/index.js', 'packages/size-check/**'],
77+
files: [
78+
'scripts/**',
79+
'./*.js',
80+
'packages/**/index.js',
81+
'packages/size-check/**'
82+
],
7683
rules: {
7784
'no-restricted-globals': 'off',
7885
'no-restricted-syntax': 'off'

.github/contributing.md

Lines changed: 94 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ Hi! I'm really excited that you are interested in contributing to Vue.js. Before
3030

3131
- 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)`.
3232
- Provide a detailed description of the bug in the PR. Live demo preferred.
33-
- Add appropriate test coverage if applicable. You can check the coverage of your code addition by running `npm test -- --coverage`.
33+
- Add appropriate test coverage if applicable. You can check the coverage of your code addition by running `nr test-coverage`.
3434

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

3737
- Make sure tests pass!
3838

39-
- Commit messages must follow the [commit message convention](./commit-convention.md) so that changelogs can be automatically generated. Commit messages are automatically validated before commit (by invoking [Git Hooks](https://git-scm.com/docs/githooks) via [yorkie](https://github.com/yyx990803/yorkie)).
39+
- Commit messages must follow the [commit message convention](./commit-convention.md) so that changelogs can be automatically generated. Commit messages are automatically validated before commit (by invoking [Git Hooks](https://git-scm.com/docs/githooks) via [simple-git-hooks](https://github.com/toplenboren/simple-git-hooks)).
4040

41-
- No need to worry about code style as long as you have installed the dev dependencies - modified files are automatically formatted with Prettier on commit (by invoking [Git Hooks](https://git-scm.com/docs/githooks) via [yorkie](https://github.com/yyx990803/yorkie)).
41+
- No need to worry about code style as long as you have installed the dev dependencies - modified files are automatically formatted with Prettier on commit (by invoking [Git Hooks](https://git-scm.com/docs/githooks) via [simple-git-hooks](https://github.com/toplenboren/simple-git-hooks)).
4242

4343
### Advanced Pull Request Tips
4444

@@ -47,6 +47,7 @@ Hi! I'm really excited that you are interested in contributing to Vue.js. Before
4747
- Consider the performance / size impact of the changes, and whether the bug being fixes justifies the cost. If the bug being fixed is a very niche edge case, we should try to minimize the size / perf cost to make it worthwhile.
4848

4949
- Is the code perf-sensitive (e.g. in "hot paths" like component updates or the vdom patch function?)
50+
5051
- If the branch is dev-only, performance is less of a concern.
5152

5253
- Check how much extra bundle size the change introduces.
@@ -69,14 +70,36 @@ $ pnpm i # install the dependencies of the project
6970
A high level overview of tools used:
7071

7172
- [TypeScript](https://www.typescriptlang.org/) as the development language
72-
- [Rollup](https://rollupjs.org) for bundling
73-
- [Jest](https://jestjs.io/) for unit testing
73+
- [Vite](https://vitejs.dev/) and [ESBuild](https://esbuild.github.io/) for development bundling
74+
- [Rollup](https://rollupjs.org) for production bundling
75+
- [Vitest](https://vitest.dev/) for unit testing
7476
- [Prettier](https://prettier.io/) for code formatting
77+
- [ESLint](https://eslint.org/) for static error prevention (outside of types)
78+
79+
## Git Hooks
80+
81+
The project uses [simple-git-hooks](https://github.com/toplenboren/simple-git-hooks) to enforce the following on each commit:
82+
83+
- Type check the entire project
84+
- Automatically format changed files using Prettier
85+
- Verify commit message format (logic in `scripts/verifyCommit.js`)
7586

7687
## Scripts
7788

7889
**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`.
7990

91+
The `run-s` and `run-p` commands found in some scripts are from [npm-run-all](https://github.com/mysticatea/npm-run-all) for orchestrating multiple scripts. `run-s` means "run in sequence" while `run-p` means "run in parallel".
92+
93+
- [`nr build`](#nr-build)
94+
- [`nr build-dts`](#nr-build-dts)
95+
- [`nr check`](#nr-check)
96+
- [`nr dev`](#nr-dev)
97+
- [`nr dev-sfc`](#nr-dev-sfc)
98+
- [`nr dev-esm`](#nr-dev-esm)
99+
- [`nr dev-compiler`](#nr-dev-compiler)
100+
- [`nr test`](#nr-test)
101+
- [`nr test-dts`](#nr-test-dts)
102+
80103
### `nr build`
81104

82105
The `build` script builds all public packages (packages without `private: true` in their `package.json`).
@@ -91,6 +114,8 @@ nr build runtime-core
91114
nr build runtime --all
92115
```
93116

117+
Note that `nr build` uses `rollup-plugin-esbuild` for transpiling typescript and **does not perform type checking**. To run type check on the entire codebase, run `nr check`. Type checks are also automatically run on each commit.
118+
94119
#### Build Formats
95120

96121
By default, each package will be built in multiple distribution formats as specified in the `buildOptions.formats` field in its `package.json`. These can be overwritten via the `-f` flag. The following formats are supported:
@@ -124,13 +149,11 @@ nr build runtime-core -f esm-browser,cjs
124149

125150
Use the `--sourcemap` or `-s` flag to build with source maps. Note this will make the build much slower.
126151

127-
#### Build with Type Declarations
152+
### `nr build-dts`
128153

129-
The `--types` or `-t` flag will generate type declarations during the build and in addition:
154+
This command builds the type declarations for all packages. It first generates the raw `.d.ts` files in the `temp` directory, then uses [rollup-plugin-dts](https://github.com/Swatinem/rollup-plugin-dts) to roll the types into a single `.d.ts` file for each package.
130155

131-
- Roll the declarations into a single `.d.ts` file for each package;
132-
- Generate an API report in `<projectRoot>/temp/<packageName>.api.md`. This report contains potential warnings emitted by [api-extractor](https://api-extractor.com/).
133-
- 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.
156+
### `nr check`
134157

135158
### `nr dev`
136159

@@ -139,7 +162,7 @@ The `dev` script bundles a target package (default: `vue`) in a specified format
139162
```bash
140163
$ nr dev
141164

142-
> watching: packages/vue/dist/vue.global.js
165+
> built: packages/vue/dist/vue.global.js
143166
```
144167

145168
- **Important:** output of the `dev` script is for development and debugging only. While it has the same runtime behavior, the generated code should never be published to npm.
@@ -152,29 +175,44 @@ $ nr dev
152175

153176
- The `dev` script supports the `-i` flag for inlining all deps. This is useful when debugging `esm-bundler` builds which externalizes deps by default.
154177

178+
### `nr dev-sfc`
179+
180+
Shortcut for starting the SFC Playground in local dev mode. This provides the fastest feedback loop when debugging issues that can be reproduced in the SFC Playground.
181+
182+
### `nr dev-esm`
183+
184+
Builds and watches `vue/dist/vue-runtime.esm-bundler.js` with all deps inlined using esbuild. This is useful when debugging the ESM build in a reproductions that require real build setups: link `packages/vue` globally, then link it into the project being debugged.
185+
155186
### `nr dev-compiler`
156187

157-
The `dev-compiler` script builds, watches and serves the [Template Explorer](https://github.com/vuejs/core/tree/main/packages/template-explorer) at `http://localhost:5000`. This is extremely useful when working on the compiler.
188+
The `dev-compiler` script builds, watches and serves the [Template Explorer](https://github.com/vuejs/core/tree/main/packages/template-explorer) at `http://localhost:5000`. This is useful when working on pure compiler issues.
158189

159190
### `nr test`
160191

161-
The `test` script simply calls the `jest` binary, so all [Jest CLI Options](https://jestjs.io/docs/en/cli) can be used. Some examples:
192+
The `test` script simply calls the `vitest` binary, so all [Vitest CLI Options](https://vitest.dev/guide/cli.html#options) can be used. Some examples:
162193

163194
```bash
164-
# run all tests
195+
# run all tests in watch mode
165196
$ nr test
166197

198+
# run once and exit (equivalent to `vitest run`)
199+
$ nr test run
200+
167201
# run all tests under the runtime-core package
168202
$ nr test runtime-core
169203

170-
# run tests in a specific file
171-
$ nr test fileName
204+
# run tests in files matching the pattern
205+
$ nr test <fileNamePattern>
172206

173-
# run a specific test in a specific file
174-
$ nr test fileName -t 'test name'
207+
# run a specific test in specific files
208+
$ nr test <fileNamePattern> -t 'test name'
175209
```
176210

177-
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).
211+
Tests that test against source code are grouped under `nr test-unit`, while tests that test against built files that run in real browsers are grouped under `nr test-e2e`.
212+
213+
### `nr test-dts`
214+
215+
Runs `nr build-dts` first, then verify the type tests in `packages/dts-test` are working correctly against the actual built type declarations.
178216

179217
## Project Structure
180218

@@ -198,14 +236,20 @@ This repository employs a [monorepo](https://en.wikipedia.org/wiki/Monorepo) set
198236

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

201-
- `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.
202-
203-
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).
204-
205239
- `shared`: Internal utilities shared across multiple packages (especially environment-agnostic utils used by both runtime and compiler packages).
206240

207241
- `vue`: The public facing "full build" which includes both the runtime AND the compiler.
208242

243+
- Private utility packages:
244+
245+
- `dts-test`: Contains type-only tests against generated dts files.
246+
247+
- `sfc-playground`: The playground continuously deployed at https://sfc.vuejs.org. To run the playground locally, use [`nr dev-sfc`](#nr-dev-sfc).
248+
249+
- `template-explorer`: A development tool for debugging compiler output, continuously deployed at https://template-explorer.vuejs.org/. To run it locally, run [`nr dev-compiler`](#nr-dev-compiler).
250+
251+
- `size-check`: Used for checking built bundle sizes on CI.
252+
209253
### Importing Packages
210254

211255
The packages can import each other directly using their package names. Note that when importing a package, the name listed in its `package.json` should be used. Most of the time the `@vue/` prefix is needed:
@@ -217,32 +261,34 @@ import { h } from '@vue/runtime-core'
217261
This is made possible via several configurations:
218262

219263
- For TypeScript, `compilerOptions.paths` in `tsconfig.json`
220-
- For Jest, `moduleNameMapper` in `jest.config.js`
264+
- Vitest and Rollup share the sae set of aliases from `scripts/aliases.js`
221265
- For plain Node.js, they are linked using [PNPM Workspaces](https://pnpm.io/workspaces).
222266

223267
### Package Dependencies
224268

225-
```
226-
+---------------------+
227-
| |
228-
| @vue/compiler-sfc |
229-
| |
230-
+-----+--------+------+
231-
| |
232-
v v
233-
+---------------------+ +----------------------+
234-
| | | |
235-
+------------>| @vue/compiler-dom +--->| @vue/compiler-core |
236-
| | | | |
237-
+----+----+ +---------------------+ +----------------------+
238-
| |
239-
| vue |
240-
| |
241-
+----+----+ +---------------------+ +----------------------+ +-------------------+
242-
| | | | | | |
243-
+------------>| @vue/runtime-dom +--->| @vue/runtime-core +--->| @vue/reactivity |
244-
| | | | | |
245-
+---------------------+ +----------------------+ +-------------------+
269+
```mermaid
270+
flowchart LR
271+
compiler-sfc["@vue/compiler-sfc"]
272+
compiler-dom["@vue/compiler-dom"]
273+
compiler-core["@vue/compiler-core"]
274+
vue["vue"]
275+
runtime-dom["@vue/runtime-dom"]
276+
runtime-core["@vue/runtime-core"]
277+
reactivity["@vue/reactivity"]
278+
279+
subgraph "Runtime Packages"
280+
runtime-dom --> runtime-core
281+
runtime-core --> reactivity
282+
end
283+
284+
subgraph "Compiler Packages"
285+
compiler-sfc --> compiler-core
286+
compiler-sfc --> compiler-dom
287+
compiler-dom --> compiler-core
288+
end
289+
290+
vue ---> compiler-dom
291+
vue --> runtime-dom
246292
```
247293

248294
There are some rules to follow when importing across package boundaries:
@@ -255,21 +301,19 @@ There are some rules to follow when importing across package boundaries:
255301

256302
## Contributing Tests
257303

258-
Unit tests are collocated with the code being tested in each package, inside directories named `__tests__`. Consult the [Jest docs](https://jestjs.io/docs/en/using-matchers) and existing test cases for how to write new test specs. Here are some additional guidelines:
304+
Unit tests are collocated with the code being tested in each package, inside directories named `__tests__`. Consult the [Vitest docs](https://vitest.dev/api/) and existing test cases for how to write new test specs. Here are some additional guidelines:
259305

260306
- Use the minimal API needed for a test case. For example, if a test can be written without involving the reactivity system or a component, it should be written so. This limits the test's exposure to changes in unrelated parts and makes it more stable.
261307

262308
- If testing platform agnostic behavior or asserting low-level virtual DOM operations, use `@vue/runtime-test`.
263309

264310
- Only use platform-specific runtimes if the test is asserting platform-specific behavior.
265311

266-
Test coverage is continuously deployed at https://vue-next-coverage.netlify.app/. PRs that improve test coverage are welcome, but in general the test coverage should be used as a guidance for finding API use cases that are not covered by tests. We don't recommend adding tests that only improve coverage but not actually test a meaning use case.
312+
Test coverage is continuously deployed at https://coverage.vuejs.org. PRs that improve test coverage are welcome, but in general the test coverage should be used as a guidance for finding API use cases that are not covered by tests. We don't recommend adding tests that only improve coverage but not actually test a meaning use case.
267313

268314
### Testing Type Definition Correctness
269315

270-
This project uses [tsd](https://github.com/SamVerschueren/tsd) to test the built definition files (`*.d.ts`).
271-
272-
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`.
316+
Type tests are located in the `packages/dts-test` 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 running `nr test-dts-only`.
273317

274318
## Financial Contribution
275319

.github/workflows/ci.yml

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ jobs:
1717
- uses: actions/checkout@v3
1818

1919
- name: Install pnpm
20-
uses: pnpm/action-setup@v3
20+
uses: pnpm/action-setup@v2
2121

22-
- name: Set node version to 16
22+
- name: Set node version to 18
2323
uses: actions/setup-node@v3
2424
with:
25-
node-version: 16
25+
node-version: 18
2626
cache: 'pnpm'
2727

28-
- run: pnpm install
28+
- run: PUPPETEER_SKIP_DOWNLOAD=1 pnpm install
2929

3030
- name: Run unit tests
3131
run: pnpm run test-unit
@@ -35,13 +35,19 @@ jobs:
3535
steps:
3636
- uses: actions/checkout@v3
3737

38+
- name: Setup cache for Chromium binary
39+
uses: actions/cache@v3
40+
with:
41+
path: ~/.cache/puppeteer/chrome
42+
key: chromium-${{ hashFiles('pnpm-lock.yaml') }}
43+
3844
- name: Install pnpm
3945
uses: pnpm/action-setup@v2
4046

41-
- name: Set node version to 16
47+
- name: Set node version to 18
4248
uses: actions/setup-node@v3
4349
with:
44-
node-version: 16
50+
node-version: 18
4551
cache: 'pnpm'
4652

4753
- run: pnpm install
@@ -57,17 +63,20 @@ jobs:
5763
- name: Install pnpm
5864
uses: pnpm/action-setup@v2
5965

60-
- name: Set node version to 16
66+
- name: Set node version to 18
6167
uses: actions/setup-node@v3
6268
with:
63-
node-version: 16
69+
node-version: 18
6470
cache: 'pnpm'
6571

66-
- run: pnpm install
72+
- run: PUPPETEER_SKIP_DOWNLOAD=1 pnpm install
6773

6874
- name: Run eslint
6975
run: pnpm run lint
7076

77+
# - name: Run prettier
78+
# run: pnpm run format-check
79+
7180
- name: Run type declaration tests
7281
run: pnpm run test-dts
7382

@@ -81,13 +90,13 @@ jobs:
8190
- name: Install pnpm
8291
uses: pnpm/action-setup@v2
8392

84-
- name: Set node version to 16
93+
- name: Set node version to 18
8594
uses: actions/setup-node@v3
8695
with:
87-
node-version: 16
96+
node-version: 18
8897
cache: 'pnpm'
8998

90-
- run: pnpm install
99+
- run: PUPPETEER_SKIP_DOWNLOAD=1 pnpm install
91100
- run: pnpm run size
92101

93102
# - name: Check build size

0 commit comments

Comments
 (0)