contributing.md 2.1 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
2. Install yarn: `npm install -g yarn`
3. Install the dependencies: `yarn`
4. Run `yarn run dev` to build and watch for code changes
5. The development branch is `canary`. On a release, the relevant parts of the changes in the `canary` branch are rebased into `master`.
10

11
## To run tests
12 13 14

Running all tests:

15
```sh
16 17 18 19 20
yarn testonly
```

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

21
```sh
22 23 24 25 26
yarn testonly --testPathPattern "production"
```

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

27
```sh
28 29 30
yarn testonly --testPathPattern "production" -t "should allow etag header support"
```

31
## Running the integration apps
32

33
The correct path to the compiled `next` binary can be discovered by running:
34

35 36 37
```sh
find . -name next -perm -u=x -type f
```
38

39
Running examples can be done with:
40

41 42 43 44
```sh
./packages/next/dist/bin/next ./test/integration/basic
# OR
./packages/next/dist/bin/next ./examples/basic-css/
45
```
46 47 48 49 50 51 52 53 54 55 56 57 58 59

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{} \
)
60 61
```

62
## Running your own app with locally compiled version of Next.js
63

64
1. In your app's `package.json`, replace:
65

66 67 68
   ```json
   "next": "<next-version>",
   ```
69

70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
   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.