Skip to content

Commit 2cded6d

Browse files
committed
Merge branch 'main' into format-component-name
2 parents f8b2513 + aacb66d commit 2cded6d

File tree

452 files changed

+25177
-16382
lines changed

Some content is hidden

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

452 files changed

+25177
-16382
lines changed

.eslintrc.js renamed to .eslintrc.cjs

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable no-restricted-globals */
2+
13
const DOMGlobals = ['window', 'document']
24
const NodeGlobals = ['module', 'require']
35

@@ -6,31 +8,27 @@ module.exports = {
68
parserOptions: {
79
sourceType: 'module'
810
},
9-
plugins: ["jest"],
11+
plugins: ['jest'],
1012
rules: {
1113
'no-debugger': 'error',
12-
'no-unused-vars': [
13-
'error',
14-
// we are only using this rule to check for unused arguments since TS
15-
// catches unused variables but not args.
16-
{ varsIgnorePattern: '.*', args: 'none' }
17-
],
1814
// most of the codebase are expected to be env agnostic
1915
'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.
16+
2417
'no-restricted-syntax': [
2518
'error',
19+
// since we target ES2015 for baseline support, we need to forbid object
20+
// rest spread usage in destructure as it compiles into a verbose helper.
2621
'ObjectPattern > RestElement',
22+
// tsc compiles assignment spread into Object.assign() calls, but esbuild
23+
// still generates verbose helpers, so spread assignment is also prohiboted
24+
'ObjectExpression > SpreadElement',
2725
'AwaitExpression'
2826
]
2927
},
3028
overrides: [
3129
// tests, no restrictions (runs in Node / jest with jsdom)
3230
{
33-
files: ['**/__tests__/**', 'test-dts/**'],
31+
files: ['**/__tests__/**', 'packages/dts-test/**'],
3432
rules: {
3533
'no-restricted-globals': 'off',
3634
'no-restricted-syntax': 'off',
@@ -70,9 +68,17 @@ module.exports = {
7068
'no-restricted-syntax': 'off'
7169
}
7270
},
71+
// JavaScript files
72+
{
73+
files: ['*.js', '*.cjs'],
74+
rules: {
75+
// We only do `no-unused-vars` checks for js files, TS files are checked by TypeScript itself.
76+
'no-unused-vars': ['error', { vars: 'all', args: 'none' }]
77+
}
78+
},
7379
// Node scripts
7480
{
75-
files: ['scripts/**', './*.js', 'packages/**/index.js', 'packages/size-check/**'],
81+
files: ['scripts/**', '*.{js,ts}', 'packages/**/index.js'],
7682
rules: {
7783
'no-restricted-globals': 'off',
7884
'no-restricted-syntax': 'off'

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ body:
2828
attributes:
2929
label: Link to minimal reproduction
3030
description: |
31-
The easiest way to provide a reproduction is by showing the bug in [The SFC Playground](https://sfc.vuejs.org/).
31+
The easiest way to provide a reproduction is by showing the bug in [The SFC Playground](https://play.vuejs.org/).
3232
If it cannot be reproduced in the playground and requires a proper build setup, try [StackBlitz](https://vite.new/vue).
3333
If neither of these are suitable, you can always provide a GitHub repository.
3434

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
blank_issues_enabled: false
22
contact_links:
3+
- name: Feature Request
4+
url: https://github.com/vuejs/rfcs/discussions
5+
about: Suggest new features for consideration
36
- name: Discord Chat
47
url: https://chat.vuejs.org
58
about: Ask questions and discuss with other Vue users in real time.

.github/ISSUE_TEMPLATE/feature_request.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

.github/bug-repro-guidelines.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ A minimal reproduction means it demonstrates the bug, and the bug only. It shoul
2222

2323
### How to create a repro
2424

25-
For Vue 3 core reproductions, try reproducing it in [The SFC Playground](https://sfc.vuejs.org/).
25+
For Vue 3 core reproductions, try reproducing it in [The SFC Playground](https://play.vuejs.org/).
2626

2727
If it cannot be reproduced in the playground and requires a proper build setup, try [StackBlitz](https://vite.new/vue).
2828

.github/contributing.md

Lines changed: 58 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ 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

@@ -57,7 +57,7 @@ Hi! I'm really excited that you are interested in contributing to Vue.js. Before
5757

5858
## Development Setup
5959

60-
You will need [Node.js](https://nodejs.org) **version 16+**, and [PNPM](https://pnpm.io) **version 7+**.
60+
You will need [Node.js](https://nodejs.org) **version 18.12+**, and [PNPM](https://pnpm.io) **version 8+**.
6161

6262
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.
6363

@@ -70,16 +70,36 @@ $ pnpm i # install the dependencies of the project
7070
A high level overview of tools used:
7171

7272
- [TypeScript](https://www.typescriptlang.org/) as the development language
73-
- [Rollup](https://rollupjs.org) for bundling
74-
- [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
7576
- [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`)
7686

7787
## Scripts
7888

7989
**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`.
8090

8191
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".
8292

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+
83103
### `nr build`
84104

85105
The `build` script builds all public packages (packages without `private: true` in their `package.json`).
@@ -94,6 +114,8 @@ nr build runtime-core
94114
nr build runtime --all
95115
```
96116

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+
97119
#### Build Formats
98120

99121
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:
@@ -127,13 +149,11 @@ nr build runtime-core -f esm-browser,cjs
127149

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

130-
#### Build with Type Declarations
152+
### `nr build-dts`
131153

132-
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.
133155

134-
- Roll the declarations into a single `.d.ts` file for each package;
135-
- Generate an API report in `<projectRoot>/temp/<packageName>.api.md`. This report contains potential warnings emitted by [api-extractor](https://api-extractor.com/).
136-
- 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`
137157

138158
### `nr dev`
139159

@@ -142,7 +162,7 @@ The `dev` script bundles a target package (default: `vue`) in a specified format
142162
```bash
143163
$ nr dev
144164

145-
> watching: packages/vue/dist/vue.global.js
165+
> built: packages/vue/dist/vue.global.js
146166
```
147167

148168
- **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.
@@ -165,27 +185,34 @@ Builds and watches `vue/dist/vue-runtime.esm-bundler.js` with all deps inlined u
165185

166186
### `nr dev-compiler`
167187

168-
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.
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:3000`. This is useful when working on pure compiler issues.
169189

170190
### `nr test`
171191

172-
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:
173193

174194
```bash
175-
# run all tests
195+
# run all tests in watch mode
176196
$ nr test
177197

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

181-
# run tests in a specific file
182-
$ nr test fileName
204+
# run tests in files matching the pattern
205+
$ nr test <fileNamePattern>
183206

184-
# run a specific test in a specific file
185-
$ nr test fileName -t 'test name'
207+
# run a specific test in specific files
208+
$ nr test <fileNamePattern> -t 'test name'
186209
```
187210

188-
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.
189216

190217
## Project Structure
191218

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

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

212-
- `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.
213-
214-
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).
215-
216239
- `shared`: Internal utilities shared across multiple packages (especially environment-agnostic utils used by both runtime and compiler packages).
217240

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

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://play.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+
220251
### Importing Packages
221252

222253
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:
@@ -228,7 +259,7 @@ import { h } from '@vue/runtime-core'
228259
This is made possible via several configurations:
229260

230261
- For TypeScript, `compilerOptions.paths` in `tsconfig.json`
231-
- For Jest, `moduleNameMapper` in `jest.config.js`
262+
- Vitest and Rollup share the same set of aliases from `scripts/aliases.js`
232263
- For plain Node.js, they are linked using [PNPM Workspaces](https://pnpm.io/workspaces).
233264

234265
### Package Dependencies
@@ -268,19 +299,19 @@ There are some rules to follow when importing across package boundaries:
268299

269300
## Contributing Tests
270301

271-
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:
302+
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:
272303

273304
- 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.
274305

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

277308
- Only use platform-specific runtimes if the test is asserting platform-specific behavior.
278309

279-
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.
310+
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.
280311

281312
### Testing Type Definition Correctness
282313

283-
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`.
314+
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`.
284315

285316
## Financial Contribution
286317

@@ -297,4 +328,4 @@ Funds donated via Patreon go directly to support Evan You's full-time work on Vu
297328

298329
Thank you to all the people who have already contributed to Vue.js!
299330

300-
<a href="https://github.com/vuejs/vue/graphs/contributors"><img src="https://opencollective.com/vuejs/contributors.svg?width=890" /></a>
331+
<a href="https://github.com/vuejs/core/graphs/contributors"><img src="https://opencollective.com/vuejs/contributors.svg?width=890" /></a>

.github/dependabot.yml

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)