Development
This page shows how to run the plugin linked into a Medusa project while you change it. It is for contributors. Tests covers the tests, and SDLC.md covers how a change reaches a release.
Requirements
- Node.js
>=22.22.0 - Yarn 4, through Corepack:
corepack enable - A Medusa v2 project to link the plugin into
Linking the plugin into a project
In the plugin:
yarn install
npx medusa plugin:publish # once, to the local yalc registry
yarn dev # recompiles and pushes on every change In the project, once:
npx medusa plugin:add @mostrajs/cms Register the plugin in the project’s medusa-config.ts, as Basic setup in the README shows. Then start the project with medusa develop.
How yarn dev reaches the project
yarn dev runs medusa plugin:develop. On every change, it compiles the backend into .medusa/server and pushes the result to the linked project, which restarts on its own. The plugin’s Admin is not bundled. The project serves the Admin straight from src/admin in the plugin, so you see an Admin change when you reload the page.
- Do not run
yarn buildwhileyarn devruns.yarn buildreplaces.medusa/serverwith a bundled Admin and cuts the link to the source until you startyarn devagain. yarn devwrites no type declarations. When the project’s typecheck must see a change to a config type, runnpx tsc -p tsconfig.json --emitDeclarationOnly, thennpx yalc publish --push --no-scripts.- When you push to the project, you push what
yarn devcompiled last. Ifyarn devis stopped, start it before you push. - Vite in the project keeps its own pre-bundled copy of
@mostrajs/cms/admin-extensions. After you change that entry point, or afteryarn devrestarts, stop the project, deletenode_modules/.vitein the project, and start the project again.
Before you open a pull request
Run the validation gate, as SDLC.md lists it:
yarn lint
yarn typecheck
yarn typecheck:admin
yarn format:check
yarn test:unit When a project would notice your change, add a changeset with yarn changeset.