embed

    Embed files into a generated MoonBit source file.

    wasm
    skill
    agent
    Download zip
    Version
    0.1.5
    License
    Apache-2.0
    Last updated
    3 days ago
    Downloads
    67

    Dependencies

    #embed

    Embed a file or all files under a directory into one MoonBit source file.

    moon runwasm moonbit-community/embed ./fixtures -o fixtures_bundle.mbt

    The -o <output.mbt> option is required. Missing parent directories for the output path are created recursively. Use --prune <path> or -p <path> to skip files or directories relative to the input directory. The option can be repeated:

    moon runwasm moonbit-community/embed ./fixtures -o fixtures_bundle.mbt --prune _build --prune cache/tmp.bin

    For a directory input like ./fixtures, files become fields on a generated fixture record, and subdirectories become nested fixture records. UTF-8 text files become String fields, and binary files become Bytes fields. File contents are emitted as private top-level constants so the final fixture value stays short:

    let _embed_readme_md : String =
    #|...

    let _embed_image_png : Bytes =
    ([
    0xFF, 0xAA,
    ] : Bytes)

    pub struct FixturesFixture {
    readme_md : String
    nested : NestedFixture
    }

    pub struct NestedFixture {
    image_png : Bytes
    }

    pub let fixtures : FixturesFixture = {
    readme_md: _embed_readme_md,
    nested: {
    image_png: _embed_image_png,
    },
    }

    For a single file input like ./fixtures/readme.md, the generated output has one top-level constant:

    let _embed_readme_md : String =
    #|...

    pub let readme_md : String = _embed_readme_md

    For a single binary file input, the generated constant has type Bytes:

    let _embed_image_png : Bytes =
    ([
    0xFF, 0xAA,
    ] : Bytes)

    pub let image_png : Bytes = _embed_image_png

    Source Files

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io