embed

// Embed files into a generated MoonBit source file.

moon runwasm
moon runwasm moonbit-community/embed@0.1.1
$ files
SKILL.md
SKILL.md
readonly

embed

Use this skill when a MoonBit project needs small fixture files, examples, templates, or other static assets checked in as generated MoonBit source.

Workflow

  1. Choose the exact file or directory to embed. Do not embed build outputs, dependency caches, secrets, or large generated trees unless the user explicitly asks for them.
  2. Choose an output .mbt path in the package that should own the embedded data. The output path is required; missing parent directories are created.
  3. Run the tool:

moon runwasm moonbit-community/embed <path> -o <output.mbt> [--prune <path> ...]

Use repeated --prune <path> / -p <path> options for paths relative to the input directory:

moon runwasm moonbit-community/embed ./fixtures -o test/fixtures_bundle.mbt --prune _build --prune .mooncakes

  1. Inspect the generated file before handoff. Check that the public names are usable for the surrounding code and that no unintended files were embedded.
  2. Run the package or module checks that cover the output file, normally moon check and the relevant moon test.

Guidance

  • Prefer embedding stable, small inputs used by tests, examples, or code generation. Keep large assets as external files unless embedding is intentional.
  • Prune common project noise such as _build, .mooncakes, tmp, node_modules, coverage output, downloaded dependencies, and editor caches.
  • Binary files are supported, but inspect the generated size before committing.
  • Directory inputs are recursive and keep their nested structure in the generated MoonBit API.
  • If generated names collide or are awkward, rename the source files or choose a narrower input directory, then regenerate.

$ cat moon.mod
skill path
Module
moonbit-community/embed
Package
(root)
Published
last month

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io