From abefc4f80970db3ad57105e61bcfeec703dc1c8b Mon Sep 17 00:00:00 2001 From: Suneet Tipirneni <77477100+suneettipirneni@users.noreply.github.com> Date: Sat, 19 Nov 2022 16:17:19 -0500 Subject: [PATCH] docs: add section on testing local changes (#8802) * docs: add section on testing local changes * chore: use the root command for watching * Update .github/CONTRIBUTING.md Co-authored-by: Almeida * Update .github/CONTRIBUTING.md Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> * Update .github/CONTRIBUTING.md Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> * Update .github/CONTRIBUTING.md Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> Co-authored-by: Almeida Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .github/CONTRIBUTING.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index fd96ed502..68360bdaa 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -17,6 +17,25 @@ To get ready to work on the codebase, please do the following: 5. Run `yarn test` to run ESLint and ensure any JSDoc changes are valid 6. [Submit a pull request](https://github.com/discordjs/discord.js/compare) (Make sure you follow the [conventional commit format](https://github.com/discordjs/discord.js/blob/main/.github/COMMIT_CONVENTION.md)) +## Testing changes locally + +If you want to test changes you've made locally, you can do so by using `yarn link`. This will create a symlink to your local copy of the discord.js libraries. + +1. Create a new directory `mkdir discordjs-test` and move into it `cd discordjs-test` +2. Initialize a new yarn 3 project `yarn init -2` +3. Disable pnp `yarn config set nodeLinker node-modules` +4. Now link the local discord.js project you cloned earlier `yarn link -A {PATH_TO_DISCORDJS_REPO}` +5. Install packages you'd like to test locally `yarn add discord.js@latest`, `yarn add @discordjs/rest@latest`, etc. **Note: Make sure you use `latest` tag or else yarn will try to install the remote package from npm** +6. Import the package in your source code and test them out! + +### Working with TypeScript packages + +When testing local changes, you may notice you need to manually recompile TypeScript projects on every change in order to get the latest code changes to test locally. + +To avoid this you can use the `--watch` parameter in the package build script to automatically recompile the project when changes are detected. + +For example, to automatically recompile the `@discordjs/rest` project when changes are detected, run `yarn turbo run build --filter=@discordjs/rest -- --watch` in the root folder of where you cloned the discord.js repo. + ## Adding new packages If you'd like to create another package under the `@discordjs` organization run the following command: