feat: add plugin build command (#10935)

Fixes: FRMW-2863

Adds the `plugin:build` command that is used to compile the source code of a plugin for publishing it to a package registry. The command is similar to the `build` command, except it does not copy the `package.json` and the `lock` files to the build output
This commit is contained in:
Harminder Virk
2025-01-13 13:33:54 +00:00
committed by GitHub
parent b0cfb05bd1
commit b0f581cc7c
4 changed files with 89 additions and 3 deletions
@@ -0,0 +1,22 @@
import { logger } from "@medusajs/framework/logger"
import { Compiler } from "@medusajs/framework/build-tools"
export default async function build({
directory,
adminOnly,
}: {
directory: string
adminOnly: boolean
}): Promise<boolean> {
logger.info("Starting build...")
const compiler = new Compiler(directory, logger)
const tsConfig = await compiler.loadTSConfigFile()
if (!tsConfig) {
logger.error("Unable to compile plugin")
return false
}
await compiler.buildPluginBackend(tsConfig)
return true
}