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
+48-17Lines changed: 48 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,10 +19,12 @@ Hi! I'm really excited that you are interested in contributing to Vue.js. Before
19
19
- Checkout a topic branch from a base branch, e.g. `master`, and merge back against that branch.
20
20
21
21
- If adding a new feature:
22
+
22
23
- Add accompanying test case.
23
24
- Provide a convincing reason to add this feature. Ideally, you should open a suggestion issue first and have it approved before working on it.
24
25
25
26
- If fixing bug:
27
+
26
28
- 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)`.
27
29
- Provide a detailed description of the bug in the PR. Live demo preferred.
28
30
- Add appropriate test coverage if applicable. You can check the coverage of your code addition by running `yarn test --coverage`.
@@ -41,7 +43,7 @@ You will need [Node.js](http://nodejs.org) **version 10+**, and [Yarn](https://y
41
43
42
44
After cloning the repo, run:
43
45
44
-
```bash
46
+
```bash
45
47
$ yarn # install the dependencies of the project
46
48
```
47
49
@@ -60,46 +62,72 @@ The `build` script builds all public packages (packages without `private: true`
60
62
61
63
Packages to build can be specified with fuzzy matching:
62
64
63
-
```bash
65
+
```bash
64
66
# build runtime-core only
65
67
yarn build runtime-core
66
68
67
69
# build all packages matching "runtime"
68
70
yarn build runtime --all
69
71
```
70
72
73
+
#### Build Formats
74
+
71
75
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:
72
76
73
-
-**`global`**: for direct use via `<script>` in the browser. The global variable exposed is specified via the `buildOptions.name` field in a package's `package.json`.
74
-
-**`esm-bundler`**: for use with bundlers like `webpack`, `rollup` and `parcel`.
75
-
-**`esm`**: for usage via native ES modules imports (in browser via `<script type="module">`, or via Node.js native ES modules support in the future)
76
-
-**`cjs`**: for use in Node.js via `require()`.
77
+
-**`global`**:
78
+
79
+
- For direct use via `<script>` in the browser. The global variable exposed is specified via the `buildOptions.name` field in a package's `package.json`.
80
+
- Note: global builds are not [UMD](https://github.com/umdjs/umd) builds. Instead they are built as [IIFEs](https://developer.mozilla.org/en-US/docs/Glossary/IIFE).
81
+
82
+
-**`esm-bundler`**:
83
+
84
+
- Leaves prod/dev branches with `process.env.NODE_ENV` guards (to be replaced by bundler)
85
+
- Does not ship a minified build (to be done together with the rest of the code after bundling)
86
+
- For use with bundlers like `webpack`, `rollup` and `parcel`.
- Imported dependencies are also `esm-bundler` builds and will in turn import their dependencies (e.g. `@vue/runtime-core` imports `@vue/reactivity`)
89
+
- This means you **can** install/import these deps without ending up with different instances of these dependencies
90
+
91
+
-**`esm`**:
92
+
93
+
- For usage via native ES modules imports (in browser via `<script type="module">`, or via Node.js native ES modules support in the future)
94
+
- Inlines all dependencies - i.e. it's a single ES module with no imports from other files
95
+
- This means you **must** import everything from this file and this file only to ensure you are getting the same instance of code.
96
+
- Hard-coded prod/dev branches, and the prod build is pre-minified (you will have to use different paths/aliases for dev/prod)
97
+
98
+
-**`cjs`**:
99
+
- For use in Node.js server-side rendering via `require()`.
100
+
- The dev/prod files are pre-built, but are dynamically required based on `process.env.NODE_ENV` in `index.js`, which is the default entry when you do `require('vue')`.
77
101
78
102
For example, to build `runtime-core` with the global build only:
79
103
80
-
```bash
104
+
```bash
81
105
yarn build runtime-core -f global
82
106
```
83
107
84
108
Multiple formats can be specified as a comma-separated list:
85
109
86
-
```bash
110
+
```bash
87
111
yarn build runtime-core -f esm,cjs
88
112
```
89
113
114
+
#### Build with Source Maps
115
+
116
+
Use the `--sourcemap` or `-s` flag to build with source maps. Note this will make the build much slower.
117
+
90
118
#### Build with Type Declarations
91
119
92
-
The `--types` flag will generate type declarations during the build and in addition:
120
+
The `--types`or `-t`flag will generate type declarations during the build and in addition:
93
121
94
-
- Roll the declarations into a single `.dts` file for each package;
122
+
- Roll the declarations into a single `.d.ts` file for each package;
95
123
- Generate an API report in `<projectRoot>/temp/<packageName>.api.md`. This report contains potential warnings emitted by [api-extractor](https://api-extractor.com/).
96
-
- Generate an API model json in `<projectRoot>/temp/<packageName>.api.md`. This file can be used to generate a Markdown version of the exported APIs.
124
+
- 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.
97
125
98
126
### `yarn dev`
99
127
100
128
The `dev` script bundles a target package (default: `vue`) in a specified format (default: `global`) in dev mode and watches for changes. This is useful when you want to load up a build in an HTML page for quick debugging:
101
129
102
-
```bash
130
+
```bash
103
131
$ yarn dev
104
132
105
133
> rollup v1.19.4
@@ -110,11 +138,13 @@ $ yarn dev
110
138
111
139
- The `dev` script supports specifying build format via the `-f` flag just like the `build` script.
112
140
141
+
- The `dev` script also supports the `-s` flag for generating source maps, but it will make rebuilds slower.
142
+
113
143
### `yarn test`
114
144
115
145
The `yarn test` script simply calls the `jest` binary, so all [Jest CLI Options](https://jestjs.io/docs/en/cli) can be used. Some examples:
116
146
117
-
```bash
147
+
```bash
118
148
# run all tests
119
149
$ yarn test
120
150
@@ -149,32 +179,33 @@ This repository employs a [monorepo](https://en.wikipedia.org/wiki/Monorepo) set
149
179
150
180
-`compiler-dom`: Compiler with additional plugins specifically targeting the browser.
151
181
182
+
-`compiler-ssr`: Compiler that produces render functions optimized for server-side rendering.
183
+
152
184
-`template-explorer`: A development tool for debugging compiler output. You can run `yarn dev template-explorer` and open its `index.html` to get a repl of template compilation based on current source code.
153
185
154
186
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).
155
187
156
-
-`shared`: **Private.** Platform-agnostic internal utilities shared across multiple packages. This package is private and not published.
188
+
-`shared`: Internal utilities shared across multiple packages (especially environment-agnostic utils used by both runtime and compiler packages).
157
189
158
190
-`vue`: The public facing "full build" which includes both the runtime AND the compiler.
159
191
160
192
### Importing Packages
161
193
162
194
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:
163
195
164
-
```js
196
+
```js
165
197
import { h } from'@vue/runtime-core'
166
198
```
167
199
168
200
This is made possible via several configurations:
169
201
170
202
- For TypeScript, `compilerOptions.path` in `tsconfig.json`
171
-
- For Jest, `moduleNameMapping` in `jest.config.js`
203
+
- For Jest, `moduleNameMapper` in `jest.config.js`
172
204
- For plain Node.js, they are linked using [Yarn Workspaces](https://yarnpkg.com/blog/2017/08/02/introducing-workspaces/).
0 commit comments