This guide describes how to migrate a SilverBullet plug from the old Deno-based build system to the new Node/npm-based one.
Note: you can do this at your leasure, your old Deno builds should continue to work. However, newer versions of the APIs will no longer be published to JSR, just as an npm package.
What changes
| Before (Deno) | After (Node) |
|---|---|
deno.jsonc with tasks and import map |
package.json with scripts and dependencies |
deno.lock |
package-lock.json |
deno run -A <url>/plug-compile.js |
npx plug-compile |
jsr:@silverbulletmd/[email protected] |
@silverbulletmd/silverbullet from npm |
What stays the same: Your .plug.yaml manifest, your .ts source files, and the @silverbulletmd/silverbullet/... import paths all remain unchanged.
Steps
1. Delete Deno files
rm deno.jsonc deno.lock
2. Create package.json
{
"name": "silverbullet-yourplug",
"version": "0.1.0",
"private": true,
"scripts": {
"build": "npx plug-compile yourplug.plug.yaml"
},
"dependencies": {
"@silverbulletmd/silverbullet": ">=2.5.3"
}
}
Replace yourplug with your plug name matching your .plug.yaml file.
3. Create .gitignore
node_modules/
*.map
4. Install and build
npm install
npm run build
This produces yourplug.plug.js (and a .map sourcemap file) in the current directory. Use --dist <path> in the build script if you want the output elsewhere.
See the silverbullet-mermaid repository (to-node branch) for a complete example of this migration.