-
Notifications
You must be signed in to change notification settings - Fork 1
Tutorial Writing a Pack
Adrian Burlacu edited this page Feb 6, 2026
·
2 revisions
This tutorial covers how to write, bundle, and deploy packs for Stark Orchestrator, from simple scripts to complex applications.
A pack is a self-contained JavaScript bundle that can be deployed to any Stark node. Packs can be:
- Simple scripts
- API servers
- Workers and processors
- UI applications (for browser nodes)
Packs must be:
- Self-contained: All dependencies bundled
- Versioned: Semantic versioning required
-
Runtime-targeted: Specify
nodeorbrowser
Create counter.js:
// counter.js - A simple counter that runs for 10 iterations
let count = 0;
const interval = setInterval(() => {
count++;
console.log(`Count: ${count}`);
if (count >= 10) {
clearInterval(interval);
console.log('Counter complete!');
}
}, 1000);# Bundle
node packages/cli/dist/index.js pack bundle ./counter.js --out ./counter-bundle.js
# Register
node packages/cli/dist/index.js pack register ./counter-bundle.js \
--name counter \
--ver 1.0.0 \
--runtime nodenode packages/cli/dist/index.js pod create --pack counter --node my-nodeFor packs that use npm packages, the bundler will resolve and include them.
Create a project structure:
my-pack/
├── package.json
├── src/
│ └── index.js
package.json:
{
"name": "my-pack",
"version": "1.0.0",
"main": "src/index.js",
"dependencies": {
"lodash": "^4.17.21"
}
}src/index.js:
const _ = require('lodash');
const data = [1, 2, 3, 4, 5];
const sum = _.sum(data);
console.log(`Sum of ${data.join(', ')} = ${sum}`);cd my-pack
npm install # or pnpm install
# Bundle from the project directory
node ../packages/cli/dist/index.js pack bundle ./src/index.js --out ./bundle.js
# Register
node ../packages/cli/dist/index.js pack register ./bundle.js \
--name my-pack \
--ver 1.0.0 \
--runtime nodeFor services that run continuously:
// api-server.js
const http = require('http');
const PORT = process.env.PORT || 3000;
const server = http.createServer((req, res) => {
console.log(`${new Date().toISOString()} - ${req.method} ${req.url}`);
if (req.url === '/health') {
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ status: 'healthy' }));
return;
}
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello from Stark Pack!\n');
});
server.listen(PORT, () => {
console.log(`Server listening on port ${PORT}`);
});
// Graceful shutdown
process.on('SIGTERM', () => {
console.log('Received SIGTERM, shutting down...');
server.close(() => {
console.log('Server closed');
process.exit(0);
});
});For Nuxt/Vue applications, special configuration is needed.
| Requirement | Description |
|---|---|
| pnpm | Project must use pnpm as package manager |
| Static output | Must generate static HTML/JS/CSS (no SSR) |
| No code-splitting | Disable dynamic imports (inlineDynamicImports: true) |
| Inline assets | Assets must be inlined as base64 data URIs |
nuxt.config.ts:
export default defineNuxtConfig({
ssr: false,
nitro: { preset: 'static' },
vite: {
build: {
assetsInlineLimit: 100 * 1024, // 100KB - inline assets under this size
rollupOptions: {
output: {
inlineDynamicImports: true,
manualChunks: undefined,
},
},
},
},
})See examples/nuxt-pack for a complete example.
# From the Nuxt project directory
node packages/cli/dist/index.js pack bundle . --out ./nuxt-bundle.js
# Register for browser runtime
node packages/cli/dist/index.js pack register ./nuxt-bundle.js \
--name my-nuxt-app \
--ver 1.0.0 \
--runtime browserControl who can deploy your pack:
# Private (default) - only you can deploy
node packages/cli/dist/index.js pack register ./bundle.js \
--name my-private-pack \
--ver 1.0.0 \
--runtime node
# Public - anyone can deploy
node packages/cli/dist/index.js pack register ./bundle.js \
--name my-public-pack \
--ver 1.0.0 \
--runtime node \
--visibility publicFollow semver for pack versions:
- MAJOR (1.0.0 → 2.0.0): Breaking changes
- MINOR (1.0.0 → 1.1.0): New features, backward compatible
- PATCH (1.0.0 → 1.0.1): Bug fixes
# List all versions of a pack
node packages/cli/dist/index.js pack versions my-pack
# Deploy specific version
node packages/cli/dist/index.js pod create --pack my-pack --ver 1.2.3
# Rollback to previous version
node packages/cli/dist/index.js pod rollback <pod-id> --ver 1.0.0- Home
- Getting Started
- Concepts
- Core Architecture
- Tutorials
- Reference
- Advanced Topics
- Contribution