malv build
Build your apps for development or publishing. This compiles TypeScript, bundles with Rollup, and generates type declarations.
Usage
# From within an app directory
cd packages/apps/my-app
malv build
# From project root - builds all workspace apps
malv build
# Build all workspace apps explicitly
malv build --all
# Build a specific app by name
malv build @my-org/my-app
# Skip code generation (faster rebuilds)
malv build --skip-gen
What It Does
The build command runs three steps:
- Generation - Runs code generators to create TypeScript types from JSON schemas
- Bundle - Runs
rollup -cto bundle JavaScript - Types - Runs
tsc --emitDeclarationOnlyto generate.d.tsfiles
Options
| Option | What It Does |
|---|---|
--all |
Build all workspace apps from malv.json |
--skip-gen |
Skip the generation step |
--help, -h |
Show help |
Behavior
From an app directory (has tools.json):
Builds that specific app.
From project root (has malv.json):
Builds all apps with workspace:* versions. Registry-installed apps are skipped since they're already built.
Generation Step
Before bundling, the build runs code generators automatically:
- types - Tool input/output types from
tools.json - tokens - TokenPayloads from
tokens.json - events - EventHandlerTypes from
events.json - env - Environment types from
environment.json - exports - Package.json exports from tools/objects
- objects - Object type definitions from
objects.json - tools - tools.json from tool TypeScript files
Use --skip-gen to skip this step when you haven't changed any JSON schemas:
malv build --skip-gen
Rollup Configuration
Your app needs a rollup.config.js file. The build command validates that it includes the required TypeScript plugin settings:
import typescript from '@rollup/plugin-typescript';
export default {
input: 'src/tools/index.ts',
output: {
dir: 'dist',
format: 'esm'
},
plugins: [
typescript({
tsconfigOverride: {
compilerOptions: {
declaration: false,
declarationMap: false,
},
}
})
]
};
The declaration: false setting ensures type declarations for bundled dependencies aren't included in your output. Type declarations are generated separately by tsc.
Output
$ malv build
Building @my-org/notes...
✓ Generated types
✓ Generated exports
✓ Bundled with Rollup
✓ Generated type declarations
Build complete: dist/
Build Output
After building, your dist/ directory contains:
dist/
├── tools/
│ ├── create_note.js # Bundled tool
│ ├── create_note.d.ts # Type declarations
│ ├── edit_note.js
│ └── edit_note.d.ts
└── index.js # Main entry
Before Publishing
Always build before publishing:
malv build
malv publish
The publish command requires the dist/ directory to exist.
Common Issues
Missing rollup.config.js
Error: No rollup.config.js found
Create a Rollup configuration file in your app directory.
TypeScript errors
Build failures from type errors. Fix the errors or run malv validate to see all issues across your project.
Generation errors
If generation fails, check your JSON schema files (tools.json, tokens.json, etc.) for syntax errors.