Publish a plug as a package
Share a plug through npm, and use it from blaise.yml.
A package that default-exports a plug can be used from any project that depends on it.
1. Export the plug
The package's entry point default-exports the result of definePlug, as a local plug does:
import { definePlug } from "@blaiseagent/runner";
export default definePlug({
name: "acme/greeter",
// …
});2. Declare the runner as a peer dependency
{
"name": "@acme/blaise-greeter",
"version": "1.0.0",
"type": "module",
"exports": { ".": "./dist/index.js" },
"peerDependencies": { "@blaiseagent/runner": "^0.1.0" }
}A peer dependency makes the project and the plug share one copy of the runner. The loader also
checks the plug API version that definePlug stamps on the plug, so a plug built for another major
version is refused with a message that says so.
3. Use it
Install the package in the project, and name it in use:. Scoped names need quotes in YAML:
setup:
- use: "@acme/blaise-greeter"
with:
who: worldA package with several plugs lists them as exports, and use: takes the subpath:
"@acme/blaise-plugs/greeter".
Names that are ours
blaise:<name> is reserved for plugs we publish as @blaiseagent/plugs-<name>. Publish yours under
your own scope.
How use: becomes a module is in Resolving plugs.