Skip to main content

moon v1.20 - Extension plugins, default task options, and more

· 3 min read
Miles Johnson
Founder, developer

In this release, we're excited to introduce extensions, our first type of plugin!

New extension plugins

In our 2024 roadmap blog post, we talked heavily about plugins, as we believe they're the future of moon and its ecosystem. What we didn't talk about is that we plan to have many types of plugins, and not just language/platform specific ones. And with that, we're excited to introduce extensions!

An extension is a WASM plugin that allows you to extend moon with additional functionality, have whitelisted access to the file system, and receive partial information about the current workspace. Extensions are extremely useful in offering new and unique functionality that doesn't need to be built into moon's core.

Once such extension is our built-in download extension, which is a basic extension that simply downloads a file from a URL into the current moon workspace.

$ moon ext download -- --url https://github.com/moonrepo/proto/releases/latest/download/proto_cli-aarch64-apple-darwin.tar.xz

Shipping alongside extensions are the following new features:

Configure default options for tasks

Task options provide a way to apply granular changes to a task's behavior when running in the pipeline. However, they can become tedious when you need to apply them to many tasks, especially when inheritance is involved. To help with this, you can now configure the taskOptions setting in task related configs, like .moon/tasks.yml and .moon/tasks/*.yml, which acts as the base/default options for all inherited tasks.

For example, the following config:

.moon/tasks.yml
tasks:
build:
# ...
options:
outputStyle: 'stream'
retryCount: 2
lint:
# ...
options:
outputStyle: 'stream'
retryCount: 2
test:
# ...
options:
outputStyle: 'stream'
retryCount: 2

Can simply be rewritten as:

.moon/tasks.yml
taskOptions:
outputStyle: 'stream'
retryCount: 2

tasks:
build:
# ...
lint:
# ...
test:
# ...

Because these options are defined at the workspace-level, they adhere to the same merge and inheritance rules as other settings. Just be aware that these options are inherited first in the chain, and can be overwritten by other layers, or by project-level tasks.

Optional task dependencies

By default, all task deps are required to exist when tasks are being built and expanded, but this isn't always true when dealing with composition and inheritance. For example, say you're using tag-based inheritance, and a global task relies on one of these tagged tasks, but not all projects may define the appropriate tags. In previous versions of moon, this is a hard failure, as the dependent task does not exist.

To remedy this, we're introducing a new optional flag for task dependencies. When set to true, moon will no longer error when the task doesn't exist, and instead will omit the dependency.

.moon/tasks.yml
tasks:
build:
command: 'vite'
deps:
- target: '#components:build'
optional: true

Thanks to @maastrich for this contribution!

Other changes

View the official release for a full list of changes.

  • Added a "Tags" view to the VSCode extension.
  • Updated proto to v0.29.1 (from v0.26.4).
  • Updated proto installation to trigger for all applicable commands, not just moon run, moon check, and moon ci.