1 import { Prerequisites } from "docs-ui"
2
3 export const metadata = {
4 title: `Code Contribution Guidelines`,
5 }
6
7 # {metadata.title}
8
9 Thank you for your interest in contributing to Medusa's codebase! This guide walks you through setting up a local development environment, linking your fork to a test project, and iterating on changes with hot reload.
10
11 <Note title="Tip">
12
13 This guide is specific to contributing to Medusa's codebase. If you're interested in contributing to the documentation, check out the [Docs Contribution Guidelines](../docs/page.mdx).
14
15 </Note>
16
17 ## What Can You Contribute?
18
19 You can contribute to Medusa's codebase in the following ways:
20
21 - Bug fixes to packages, modules, or plugins.
22 - New features, after opening an issue to confirm the approach with the team.
23 - Improvements to tooling and the contributor developer experience.
24
25 <Note>
26
27 Before writing code, make sure there's an [issue](https://github.com/medusajs/medusa/issues) for your change. This lets others weigh in before you invest time. See [Issues before PRs](https://github.com/medusajs/medusa/blob/develop/CONTRIBUTING.md#issues-before-prs).
28
29 </Note>
30
31 ---
32
33 ## Prerequisites
34
35 <Prerequisites
36 items={[
37 {
38 text: "Forked Medusa repository cloned locally.",
39 link: "https://github.com/medusajs/medusa"
40 },
41 {
42 text: "A local Medusa application for testing.",
43 link: "https://docs.medusajs.com/learn/installation"
44 }
45 ]}
46 />
47
48 The snippets below assume your forked Medusa project and your test project are sibling directories:
49
50 ```bash
51 |
52 |__ medusa // forked repository
53 |
54 |__ test-project // Medusa application for testing
55 ```
56
57 ---
58
59 ## Linking Your Fork to a Test Project
60
61 To test local changes, point your test project's `@medusajs/*` dependencies at your local packages and resolve every transitive dependency locally.
62
63 1. In your test project's `package.json`, replace the `@medusajs/*` entries in `dependencies` and `devDependencies` with `file:` references to your fork:
64
65 ```json
66 "dependencies": {
67 "@medusajs/cli": "file:../medusa/packages/cli/medusa-cli",
68 "@medusajs/framework": "file:../medusa/packages/core/framework",
69 "@medusajs/medusa": "file:../medusa/packages/medusa"
70 }
71 ```
72
73 2. Add the full set of packages under `resolutions` so transitive dependencies also resolve locally. See the complete list in [`CONTRIBUTING.md`](https://github.com/medusajs/medusa/blob/develop/CONTRIBUTING.md#local-development).
74
75 ---
76
77 ## Iterating with Watch Mode
78
79 After building your fork, you can iterate without a full rebuild on each change.
80
81 - For most packages, use the package's `dev` or `watch` script.
82 - For plugin packages (`packages/plugins/*`), use the watch flow:
83
84 ```bash
85 # inside the plugin package
86 yarn watch # swc watch + yalc publish on change (medusa plugin:develop)
87 yarn link:watch # publish once, then watch
88 ```
89
90 Under the hood, `medusa plugin:develop` watches your source, transforms it with `@swc/core`, and republishes via `yalc` so your linked test project picks up changes automatically.
91
92 ---
93
94 ## Opening a Pull Request
95
96 Branch out from `develop`, make your changes, and [open a pull request against `develop`](https://github.com/medusajs/medusa/blob/develop/CONTRIBUTING.md#issues-before-prs). A team member will review within a few days.