You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/contributing.md
+49-24Lines changed: 49 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ Hi! I'm really excited that you are interested in contributing to Vue.js. Before
30
30
31
31
- 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)`.
32
32
- 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`.
34
34
35
35
- It's OK to have multiple small commits as you work on the PR - GitHub can automatically squash them before merging.
36
36
@@ -70,16 +70,28 @@ $ pnpm i # install the dependencies of the project
70
70
A high level overview of tools used:
71
71
72
72
-[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
75
76
-[Prettier](https://prettier.io/) for code formatting
77
+
-[ESLint](https://eslint.org/) for static error prevention (outside of types)
76
78
77
79
## Scripts
78
80
79
81
**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`.
80
82
81
83
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".
82
84
85
+
-[`nr build`](#nr-build)
86
+
-[`nr build-dts`](#nr-build-dts)
87
+
-[`nr check`](#nr-check)
88
+
-[`nr dev`](#nr-dev)
89
+
-[`nr dev-sfc`](#nr-dev-sfc)
90
+
-[`nr dev-esm`](#nr-dev-esm)
91
+
-[`nr dev-compiler`](#nr-dev-compiler)
92
+
-[`nr test`](#nr-test)
93
+
-[`nr test-dts`](#nr-test-dts)
94
+
83
95
### `nr build`
84
96
85
97
The `build` script builds all public packages (packages without `private: true` in their `package.json`).
@@ -94,6 +106,8 @@ nr build runtime-core
94
106
nr build runtime --all
95
107
```
96
108
109
+
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`.
110
+
97
111
#### Build Formats
98
112
99
113
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 +141,11 @@ nr build runtime-core -f esm-browser,cjs
127
141
128
142
Use the `--sourcemap` or `-s` flag to build with source maps. Note this will make the build much slower.
129
143
130
-
#### Build with Type Declarations
144
+
###`nr build-dts`
131
145
132
-
The `--types` or `-t` flag will generate type declarations during the build and in addition:
146
+
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.
133
147
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.
148
+
### `nr check`
137
149
138
150
### `nr dev`
139
151
@@ -142,7 +154,7 @@ The `dev` script bundles a target package (default: `vue`) in a specified format
142
154
```bash
143
155
$ nr dev
144
156
145
-
>watching: packages/vue/dist/vue.global.js
157
+
>built: packages/vue/dist/vue.global.js
146
158
```
147
159
148
160
-**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.
@@ -169,23 +181,30 @@ The `dev-compiler` script builds, watches and serves the [Template Explorer](htt
169
181
170
182
### `nr test`
171
183
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:
184
+
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:
173
185
174
186
```bash
175
-
# run all tests
187
+
# run all tests in watch mode
176
188
$ nr test
177
189
190
+
# run once and exit (equivalent to `vitest run`)
191
+
$ nr test run
192
+
178
193
# run all tests under the runtime-core package
179
194
$ nr test runtime-core
180
195
181
-
# run tests in a specific file
182
-
$ nr testfileName
196
+
# run tests in files matching the pattern
197
+
$ nr test<fileNamePattern>
183
198
184
-
# run a specific test in a specific file
185
-
$ nr testfileName -t 'test name'
199
+
# run a specific test in specific files
200
+
$ nr test<fileNamePattern> -t 'test name'
186
201
```
187
202
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).
203
+
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`.
204
+
205
+
### `nr test-dts`
206
+
207
+
Runs `nr build-dts` first, then verify the type tests in `packages/dts-test` are working correctly against the actual built type declarations.
189
208
190
209
## Project Structure
191
210
@@ -209,14 +228,20 @@ This repository employs a [monorepo](https://en.wikipedia.org/wiki/Monorepo) set
209
228
210
229
-`compiler-ssr`: Compiler that produces render functions optimized for server-side rendering.
211
230
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
-
216
231
-`shared`: Internal utilities shared across multiple packages (especially environment-agnostic utils used by both runtime and compiler packages).
217
232
218
233
-`vue`: The public facing "full build" which includes both the runtime AND the compiler.
219
234
235
+
- Private utility packages:
236
+
237
+
-`dts-test`: Contains type-only tests against generated dts files.
238
+
239
+
-`sfc-playground`: The playground continuously deployed at https://sfc.vuejs.org. To run the playground locally, use [`nr dev-sfc`](#nr-dev-sfc).
240
+
241
+
-`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).
242
+
243
+
-`size-check`: Used for checking built bundle sizes on CI.
244
+
220
245
### Importing Packages
221
246
222
247
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 +253,7 @@ import { h } from '@vue/runtime-core'
228
253
This is made possible via several configurations:
229
254
230
255
- For TypeScript, `compilerOptions.paths` in `tsconfig.json`
231
-
-For Jest, `moduleNameMapper` in `jest.config.js`
256
+
-Vitest and Rollup share the sae set of aliases from `scripts/aliases.mjs`
232
257
- For plain Node.js, they are linked using [PNPM Workspaces](https://pnpm.io/workspaces).
233
258
234
259
### Package Dependencies
@@ -268,19 +293,19 @@ There are some rules to follow when importing across package boundaries:
268
293
269
294
## Contributing Tests
270
295
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:
296
+
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:
272
297
273
298
- 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.
274
299
275
300
- If testing platform agnostic behavior or asserting low-level virtual DOM operations, use `@vue/runtime-test`.
276
301
277
302
- Only use platform-specific runtimes if the test is asserting platform-specific behavior.
278
303
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.
304
+
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.
280
305
281
306
### Testing Type Definition Correctness
282
307
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`.
308
+
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`.
Copy file name to clipboardExpand all lines: packages/dts-test/README.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -4,4 +4,4 @@ Tests Typescript types to ensure the types remain as expected.
4
4
5
5
- This directory is included in the root `tsconfig.json`, where package imports are aliased to `src` directories, so in IDEs and the `pnpm check` script the types are validated against source code.
6
6
7
-
- When runnong`tsc` with `packages/dts-test/tsconfig.test.json`, packages are resolved using using normal `node` resolution, so the types are validated against actual **built** types. This requires the types to be built first via `pnpm build-types`.
7
+
- When running`tsc` with `packages/dts-test/tsconfig.test.json`, packages are resolved using using normal `node` resolution, so the types are validated against actual **built** types. This requires the types to be built first via `pnpm build-types`.
0 commit comments