···11+# Development
22+33+Thanks for contributing! We want to ensure that `urql` evolves and fulfills
44+its idea of extensibility and flexibility by seeing continuous improvements
55+and enhancements, no matter how small or big they might be.
66+77+If you're about to add a new exchange, please consider publishing it as
88+a separate package.
99+1010+## How to contribute?
1111+1212+We follow fairly standard but lenient rules around pull requests and issues.
1313+Please pick a title that describes your change briefly, optionally in the imperative
1414+mood if possible.
1515+1616+If you have an idea for a feature or want to fix a bug, consider opening an issue
1717+first. We're also happy to discuss and help you open a PR and get your changes
1818+in!
1919+2020+## How do I set up the project?
2121+2222+Luckily it's not hard to get started. You can install dependencies using yarn.
2323+Please don't use `npm` to respect the lockfile.
2424+2525+```sh
2626+yarn
2727+```
2828+2929+There are multiple commands you can run in the root folder to test your changes:
3030+3131+```sh
3232+# TypeScript checks:
3333+yarn run check
3434+3535+# Linting (prettier & eslint):
3636+yarn run lint
3737+3838+# Jest Tests (for all packages):
3939+yarn run test
4040+4141+# Builds (for all packages):
4242+yarn run build
4343+```
4444+4545+You can find the main packages in `packages/*` and the addon exchanges in `exchanges/*`.
4646+Each package also has its own scripts that are common and shared between all packages.
4747+4848+```sh
4949+# Jest Tests for the current package:
5050+yarn run test
5151+5252+# Builds for the current package:
5353+yarn run build
5454+5555+# TypeScript checks for the current package:
5656+yarn run check
5757+```
5858+5959+While you can run `build` globally in the interest of time it's advisable to only run it
6060+on the packages you're working on. Note that TypeScript checks don't require any packages
6161+to be built.
6262+6363+## How do I test my changes?
6464+6565+It's always good practice to run the tests when making changes. If you're unsure which packages
6666+may be affected by your new tests or changes you may run `yarn test --watch` in the root of
6767+the repository.
6868+6969+If your editor is not set up with type checks you may also want to run `yarn run check` on your
7070+changes.
7171+7272+Additionally you can head to any example in the `examples/` folder
7373+and run them. There you'll also need to run `yarn` to install their
7474+dependencies. All examples are started using `yarn start`.
7575+7676+## How do I lint my code?
7777+7878+We ensure consistency in `urql`'s codebase using `eslint` and `prettier`.
7979+They are run on a `precommit` hook, so if something's off they'll try
8080+to automatically fix up your code, or display an error.
8181+8282+If you have them set up in your editor, even better!
8383+8484+## How do I upgrade all dependencies?
8585+8686+It may be a good idea to keep all dependencies on the `urql` repository up-to-date every now and
8787+then. Typically we do this by running `yarn upgrade-interactive --latest` and checking one-by-one
8888+which dependencies will need to be bumped. In case of any security issues it may make sense to
8989+just run `yarn upgrade [package]`.
9090+9191+Afterwards `yarn` may accidentally introduce duplicate packages due to some transitive dependencies
9292+having been upgraded separately. This can be fixed by running:
9393+9494+```sh
9595+npx yarn-deduplicate yarn.lock
9696+yarn
9797+```
9898+9999+## How do I add a new package?
100100+101101+When adding a new package, start by copying a `package.json` file from another project.
102102+You may want to alter the following fields first:
103103+104104+- `name`
105105+- `version` (either start at `0.1.0` or `1.0.0`)
106106+- `description`
107107+- `repository.directory`
108108+- `keywords`
109109+110110+Make sure to also alter the `devDependencies`, `peerDependencies`, and `dependencies` to match
111111+the new package's needs.
112112+113113+**The `main` and `module` fields follow a convention:**
114114+All output bundles will always be output in the `./dist` folder by `rollup`, which is set up in
115115+the `build` script. Their filenames are a "kebab case" (dash-cased) version of the `name` field with
116116+an appropriate extension (`.esm.js` for `module` and `.cjs.js` for `main`).
117117+118118+If your entrypoint won't be at `src/index.ts` you may alter it. But the `types` field has to match
119119+the same file relative to the `dist/types` folder, where `rollup` will output the TypeScript
120120+declaration files. When setting up your package make sure to create a `src/index.ts` file (or a file
121121+at what you've set `source` to)
122122+123123+The `scripts.prepare` task is set up to check your new `package.json` file for correctness. So in
124124+case you get anything wrong, you'll get a short error when running `yarn` after setting your new
125125+project up. Just in case! 😄
126126+127127+Lastly, your new package will need to be added to the `tsconfig.json` in the root of the repository.
128128+Add a new entry to `compilerOptions.paths` where the key is the `name` you've used in your
129129+`package.json` and the value is an array with a single entry, the path to your package + `src/`.
130130+131131+Afterwards you can check whether everything is working correctly by running:
132132+133133+```sh
134134+yarn
135135+yarn run check
136136+```