vue/.github/CONTRIBUTING.md

134 lines
7.3 KiB
Markdown
Raw Normal View History

2016-07-30 11:08:02 +08:00
# Vue.js Contributing Guide
Hi! I'm really excited that you are interested in contributing to Vue.js. Before submitting your contribution, please make sure to take a moment and read through the following guidelines:
2016-07-30 11:08:02 +08:00
2016-08-19 03:56:24 +08:00
- [Code of Conduct](https://github.com/vuejs/vue/blob/dev/.github/CODE_OF_CONDUCT.md)
2016-07-30 11:17:32 +08:00
- [Issue Reporting Guidelines](#issue-reporting-guidelines)
- [Pull Request Guidelines](#pull-request-guidelines)
- [Development Setup](#development-setup)
- [Project Structure](#project-structure)
2016-07-30 11:08:02 +08:00
## Issue Reporting Guidelines
2017-03-17 16:21:27 +08:00
- Always use [https://new-issue.vuejs.org/](https://new-issue.vuejs.org/) to create new issues.
2016-12-15 01:42:28 +08:00
2016-07-30 11:08:02 +08:00
## Pull Request Guidelines
- The `master` branch is just a snapshot of the latest stable release. All development should be done in dedicated branches. **Do not submit PRs against the `master` branch.**
2016-07-30 11:08:02 +08:00
- Checkout a topic branch from the relevant branch, e.g. `dev`, and merge back against that branch.
- Work in the `src` folder and **DO NOT** checkin `dist` in the commits.
- It's OK to have multiple small commits as you work on the PR - GitHub will automatically squash it before merging.
2016-07-30 11:08:02 +08:00
- Make sure `npm test` passes. (see [development setup](#development-setup))
- If adding a new feature:
2016-07-30 11:08:02 +08:00
- Add accompanying test case.
- Provide a convincing reason to add this feature. Ideally, you should open a suggestion issue first and have it approved before working on it.
2016-07-30 11:08:02 +08:00
- If fixing bug:
- 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)`.
- Provide a detailed description of the bug in the PR. Live demo preferred.
2016-07-30 11:08:02 +08:00
- Add appropriate test coverage if applicable.
## Development Setup
You will need [Node.js](http://nodejs.org) **version 8+**, [Java Runtime Environment](http://www.oracle.com/technetwork/java/javase/downloads/index.html) (for running Selenium server during e2e tests) and [yarn](https://yarnpkg.com/en/docs/install).
2016-07-30 11:08:02 +08:00
After cloning the repo, run:
``` bash
$ yarn # install the dependencies of the project
2016-07-30 11:08:02 +08:00
```
### Committing Changes
2016-11-26 02:16:11 +08:00
2018-01-06 23:08:47 +08:00
Commit messages should follow the [commit message convention](./COMMIT_CONVENTION.md) so that changelogs can be automatically generated. Commit messages will be automatically validated upon commit. If you are not familiar with the commit message convention, you can use `npm run commit` instead of `git commit`, which provides an interactive CLI for generating proper commit messages.
2016-11-26 02:16:11 +08:00
2016-07-30 11:08:02 +08:00
### Commonly used NPM scripts
``` bash
# watch and auto re-build dist/vue.js
$ npm run dev
# watch and auto re-run unit tests in Chrome
$ npm run dev:test
# build all dist files, including npm packages
$ npm run build
# run the full test suite, including linting/type checking
2016-07-30 11:08:02 +08:00
$ npm test
```
There are some other scripts available in the `scripts` section of the `package.json` file.
The default test script will do the following: lint with ESLint -> type check with Flow -> unit tests with coverage -> e2e tests. **Please make sure to have this pass successfully before submitting a PR.** Although the same tests will be run against your PR on the CI server, it is better to have it working locally.
2016-07-30 11:08:02 +08:00
## Project Structure
- **`scripts`**: contains build-related scripts and configuration files. Usually, you don't need to touch them. However, it would be helpful to familiarize yourself with the following files:
2017-12-22 09:17:47 +08:00
- `scripts/alias.js`: module import aliases used across all source code and tests.
2017-12-22 09:17:47 +08:00
- `scripts/config.js`: contains the build configurations for all files found in `dist/`. Check this file if you want to find out the entry source file for a dist file.
2016-07-30 11:08:02 +08:00
- **`dist`**: contains built files for distribution. Note this directory is only updated when a release happens; they do not reflect the latest changes in development branches.
See [dist/README.md](https://github.com/vuejs/vue/blob/dev/dist/README.md) for more details on dist files.
2016-07-30 11:08:02 +08:00
- **`flow`**: contains type declarations for [Flow](https://flowtype.org/). These declarations are loaded **globally** and you will see them used in type annotations in normal source code.
- **`packages`**: contains `vue-server-renderer` and `vue-template-compiler`, which are distributed as separate NPM packages. They are automatically generated from the source code and always have the same version with the main `vue` package.
- **`test`**: contains all tests. The unit tests are written with [Jasmine](http://jasmine.github.io/2.3/introduction.html) and run with [Karma](http://karma-runner.github.io/0.13/index.html). The e2e tests are written for and run with [Nightwatch.js](http://nightwatchjs.org/).
- **`src`**: contains the source code. The codebase is written in ES2015 with [Flow](https://flowtype.org/) type annotations.
2016-07-30 11:08:02 +08:00
- **`compiler`**: contains code for the template-to-render-function compiler.
The compiler consists of a parser (converts template strings to element ASTs), an optimizer (detects static trees for vdom render optimization), and a code generator (generate render function code from element ASTs). Note that codegen directly generates code strings from the element AST - it's done this way for smaller code size because the compiler is shipped to the browser in the standalone build.
2016-07-30 11:08:02 +08:00
- **`core`**: contains universal, platform-agnostic runtime code.
The Vue 2.0 core is platform-agnostic. That is, the code inside `core` is able to be run in any JavaScript environment, be it the browser, Node.js, or an embedded JavaScript runtime in native applications.
2016-07-30 11:08:02 +08:00
- **`observer`**: contains code related to the reactivity system.
2016-07-30 11:15:33 +08:00
- **`vdom`**: contains code related to vdom element creation and patching.
- **`instance`**: contains Vue instance constructor and prototype methods.
- **`global-api`**: contains Vue global api.
2016-07-30 11:15:33 +08:00
- **`components`**: contains universal abstract components.
2016-07-30 11:08:02 +08:00
- **`server`**: contains code related to server-side rendering.
- **`platforms`**: contains platform-specific code.
Entry files for dist builds are located in their respective platform directory.
Each platform module contains three parts: `compiler`, `runtime` and `server`, corresponding to the three directories above. Each part contains platform-specific modules/utilities which are imported and injected to the core counterparts in platform-specific entry files. For example, the code implementing the logic behind `v-bind:class` is in `platforms/web/runtime/modules/class.js` - which is imported in `entries/web-runtime.js` and used to create the browser-specific vdom patching function.
2016-07-30 11:08:02 +08:00
- **`sfc`**: contains single-file component (`*.vue` files) parsing logic. This is used in the `vue-template-compiler` package.
- **`shared`**: contains utilities shared across the entire codebase.
- **`types`**: contains TypeScript type definitions
- **`test`**: contains type definitions tests
## Financial Contribution
2022-02-07 13:22:17 +08:00
As a pure community-driven project without major corporate backing, we also welcome financial contributions via GitHub Sponsors and OpenCollective. Please consult the [Sponsor Page](https://vuejs.org/sponsor/) for more details.
## Credits
Thank you to all the people who have already contributed to Vue.js!
<a href="https://github.com/vuejs/vue/graphs/contributors"><img src="https://opencollective.com/vuejs/contributors.svg?width=890" /></a>