Feat/plugin develop (#10926)

Fixes: FRMW-2865

In this PR we add support for developing a plugin in watch mode. During the file change, we re-compile the source code (incrementally), publishes the package, and updates the installations of the plugin. 

We are using `yalc` under the hood and it must be installed as a dev dependency in the plugin project and the main Medusa app.
This commit is contained in:
Harminder Virk authored and GitHub committed 2025-01-13 13:08:02 +00:00
1 parent ecf73780e0
commit 69e2a6d695
6 files changed
+217 -27

No files matched your search

+9 -2
View File
@@ -57,7 +57,8 @@
"@types/multer": "^1.4.7",
"jest": "^29.7.0",
"rimraf": "^5.0.1",
"typescript": "^5.6.2"
"typescript": "^5.6.2",
"yalc": "1.0.0-pre.53"
},
"dependencies": {
"@inquirer/checkbox": "^2.3.11",
@@ -130,7 +131,13 @@
"@mikro-orm/knex": "5.9.7",
"@mikro-orm/migrations": "5.9.7",
"@mikro-orm/postgresql": "5.9.7",
"awilix": "^8.0.1"
"awilix": "^8.0.1",
"yalc": "1.0.0-pre.53"
},
"peerDependenciesMeta": {
"yalc": {
"optional": true
}
},
"gitHead": "cd1f5afa5aa8c0b15ea957008ee19f1d695cbd2e"
}
@@ -0,0 +1,19 @@
import * as yalc from "yalc"
import { logger } from "@medusajs/framework/logger"
import { Compiler } from "@medusajs/framework/build-tools"
export default async function developPlugin({
directory,
}: {
directory: string
}) {
const compiler = new Compiler(directory, logger)
await compiler.developPluginBackend(async () => {
await yalc.publishPackage({
push: true,
workingDir: directory,
changed: true,
replace: true,
})
})
}