Bundle Blocklet
The blocklet bundle command is the essential step for packaging your blocklet's source code, assets, and metadata into a single, deployable unit. This process prepares your blocklet for deployment to a Blocklet Server instance or for distribution via a blocklet store.
blocklet bundle [options]This command reads your blocklet.yml configuration, gathers all necessary files, and places them into a .blocklet/bundle directory within your project.
Bundling Modes#
The CLI offers several bundling modes. It automatically selects an appropriate mode based on your blocklet's group type, but you can also specify one manually. For most modern JavaScript/TypeScript blocklets, compact mode is recommended as it provides significant optimizations.
Mode | Description | Best For | Manual Flag |
|---|---|---|---|
| (Recommended) Transpiles and bundles all JS/TS source code into a minimal set of files, with options for minification and source maps. | Most blocklets, especially DApps and services. |
|
| Copies all necessary files into the bundle directory without any compilation or archiving. Ideal for Node.js based services. |
|
|
| Copies files and then creates a compressed |
|
|
The Bundling Process#
The bundling process follows a clear sequence to ensure all dependencies and assets are correctly included.
What's Included in the Bundle?#
The bundler intelligently includes only the necessary files to run your blocklet, based on several sources:
- Metadata: Your
blocklet.ymlfile and other meta files likeblocklet.md. - Main Entry: The file specified in the
mainproperty ofblocklet.yml. - NPM Files: Files included by default according to
package.json'sfilesfield and.npmignorerules, determined bynpm-packlist. - Blocklet Files: Any additional files or glob patterns specified in the
filesarray of yourblocklet.yml. - Scripts: JavaScript files referenced in your blocklet's lifecycle scripts (e.g.,
pre-start,post-start). - Migrations: All scripts located in the
migration/*.jsdirectory. - Specifications:
api.yml(OpenAPI) andcomponents.yml(Open Components) if they exist. - Rewritten
package.json: A minimalpackage.jsonis generated inside the bundle, containing only essential keys likename,version,description, and processed external dependencies.
Command Options#
You can customize the bundling process with the following options:
Option | Description |
|---|---|
| (Recommended) Activates the |
| Forces the bundler to use the |
| Forces the bundler to use the |
| Creates a compressed |
| Creates a release asset after bundling (typically used in CI/CD pipelines). |
| Excludes the specified module from the bundle in |
`--minify <true | false>` |
| Generates a source map for the bundled code in |
| Disables the inclusion of a changelog in the release. |
Examples#
Recommended: Compact Mode with External Dependencies
When using a framework like React, you'll want to exclude it from your bundle and treat it as an external dependency. This is common when the blocklet will run in an environment where React is already provided.
blocklet bundle --compact --external react --external react-domDefault Bundling
For a simple blocklet, running the command without arguments is sufficient. The CLI will choose an appropriate mode automatically.
blocklet bundleCreating a Release Archive
To generate a .zip file ready for upload, use the --create-archive flag.
blocklet bundle --create-archiveThis will create a file like example-blocklet-1.0.0.zip in the .blocklet directory.
After successfully bundling your blocklet, the next step is to version and distribute it. You can learn more in the Manage Version section or proceed directly to Deploy Blocklet.