contributing.md 3.0 KB
Newer Older
T
Tim Neutkens 已提交
1 2 3 4 5
# Contributing to Next.js

Our Commitment to Open Source can be found [here](https://zeit.co/blog/oss)

1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device.
6 7 8 9 10 11
2. Create a new branch `git checkout -b MY_BRANCH_NAME`
3. Install yarn: `npm install -g yarn`
4. Install the dependencies: `yarn`
5. Run `yarn dev` to build and watch for code changes
6. In a new terminal, run `yarn types` to compile declaration files from TypeScript
7. The development branch is `canary` (this is the branch pull requests should be made against). On a release, the relevant parts of the changes in the `canary` branch are rebased into `master`.
12 13

> You may need to run `yarn types` again if your types get outdated.
14

15
## To run tests
16

17 18
Make sure you have `chromedriver` installed for your Chrome version. You can install it with

T
Tim Neutkens 已提交
19
- `brew cask install chromedriver` on Mac OS X
20 21 22
- `chocolatey install chromedriver` on Windows
- Or manually downloading it from the [chromedriver repo](https://chromedriver.storage.googleapis.com/index.html) and adding the binary to `<next-repo>/node_modules/.bin`

23 24
Running all tests:

25
```sh
26 27 28
yarn testonly
```

29 30 31 32 33 34 35 36 37 38 39 40
If you would like to run the tests in headless mode (with the browser windows hidden) you can do

```sh
yarn testheadless
```

If you would like to use a specific Chrome/Chromium binary to run tests you can specify it with

```sh
CHROME_BIN='path/to/chrome/bin' yarn testonly
```

41 42
Running a specific test suite inside of the `test/integration` directory:

43
```sh
44 45 46 47 48
yarn testonly --testPathPattern "production"
```

Running just one test in the `production` test suite:

49
```sh
50 51 52
yarn testonly --testPathPattern "production" -t "should allow etag header support"
```

53
## Running the integration apps
54

55
Running examples can be done with:
56

57
```sh
58
yarn next ./test/integration/basic
59
# OR
60
yarn next ./examples/basic-css/
61
```
62 63 64 65 66 67 68 69 70 71 72 73 74 75

To figure out which pages are available for the given example, you can run:

```sh
EXAMPLE=./test/integration/basic
(\
  cd $EXAMPLE/pages; \
  find . -type f \
  | grep -v '\.next' \
  | sed 's#^\.##' \
  | sed 's#index\.js##' \
  | sed 's#\.js$##' \
  | xargs -I{} echo localhost:3000{} \
)
76 77
```

78
## Running your own app with locally compiled version of Next.js
79

80
1. In your app's `package.json`, replace:
81

82 83 84
   ```json
   "next": "<next-version>",
   ```
85

86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
   with:

   ```json
   "next": "file:<local-path-to-cloned-nextjs-repo>/packages/next",
   ```

2. In your app's root directory, make sure to remove `next` from `node_modules` with:

   ```sh
   rm -rf ./node_modules/next
   ```

3. In your app's root directory, run:

   ```sh
   yarn
   ```

   to re-install all of the dependencies.

   Note that Next will be copied from the locally compiled version as opposed to from being downloaded from the NPM registry.

4. Run your application as you normally would.
109 110 111 112 113 114

5. To update your app's dependencies, after you've made changes to your local `next` repository. In your app's root directory, run:

   ```sh
   yarn install --force
   ```