moon icon indicating copy to clipboard operation
moon copied to clipboard

Enhance the `.mbt.md` file's front matter `deps` config

Open sv158 opened this issue 8 months ago • 3 comments

Feature Request

Summary

This feature request includes two enhancement in different case:

  1. Extend .mbt.md file's front matter config deps target to local Moonbit module as its dependency.
  2. [optional] Allow a .mbt.md file refer other .mbt.md files (aliasing as its context, like virtual package).

Motivation

  1. Simplify the workaround for markdown test mode, make the moon test for .mbt.md file works offline.
  2. make .mbt.md file more flexible on distribution.

Detailed Description

.mbt.md file can run (test) by moon test command, which convenience for simple demo and POC. Although the deps can be config in Markdown front matter area, it can only refer to the module already published on mooncakes.io using module's name and version number, while the moon.mod.json can config local Moonbit module as package dependency using a path field.

case-1: extend deps config

we can extend deps config in this way:

moonbit:
    deps:
        moon/bit: 1.0
        moon/bot: {path: ../bot} # <- local deps

Since most related code have been implemented, this enhancement would not take a hard work on it.

case-2: markdown file as 'virtual package'

First, aliasing each markdown file as a single package:

moonbit:
    libs:
        foo: ./foo/export.mbt.md  # local file
        foo.bar: https://example.com/b.mbt.md  # remote file

then we can use these package in .mbt.md files' Moonbit code blocks:

let b = @foo.echo("ok")

This enhancement is very different compare to case 1, which need a lot of works on dependency check. Both two case can take a better experience on doc-oriented programming.

Related Issues

Checklist

  • [x] I have added all necessary details to make it easy for the maintainers to understand my request.

sv158 avatar Aug 15 '25 15:08 sv158

@Young-Flash

sv158 avatar Aug 15 '25 15:08 sv158

Young-flash is no longer maintaining this project. As of this request, I currently do not have enough bandwidth to maintain it as I am working hard on #802. I'll re-review it after things are mostly settled.

lynzrand avatar Aug 18 '25 02:08 lynzrand

Sorry for the late update! The rewrite is mostly done, but I am leaving the maintainer position soon. Case 1 should be a relative easy implementation, so I will keep this issue open. I'm unsure about the semantics of case 2. If you have time, maybe you can explain it more to our other colleagues via comments in this issue. I will redirect the feature request to them.

lynzrand avatar Dec 01 '25 03:12 lynzrand