Skip to main content

moon v1.2 - Tag based task inheritance

· 2 min read
Miles Johnson
Founder, developer

In this small release, we're improving our task inheritance and performance.

Task inheritance based on project tags

In v0.23 we introduced scoped task inheritance by project type/language, and in v1.0 we introduced project tagging, but what if we combined both of these features? In this release, you can now define workspace-level tasks by tag that'll be inherited by all projects with that tag.

To demonstrate this, say you have a monorepo composed of multiple Astro applications, each duplicating the same Astro tasks. Instead of duplicating, define an astro tag in each project's moon.yml.

<project>/moon.yml
language: 'typescript'
type: 'application'
tags: ['astro']

And then create a new tasks configuration at .moon/tasks/tag-astro.yml with the following contents:

.moon/tasks/tag-astro.yml
fileGroups:
astro:
- 'public/**/*'
- 'src/**/*'
- 'astro.config.*'
- 'tsconfig.json'

tasks:
astro:
command: 'astro'
local: true

# Development server
dev:
command: 'astro dev'
local: true

# Production build
build:
command: 'astro build'
inputs: ['@group(astro)']
outputs: ['dist']

# Check .astro files
check:
command: 'astro check'
inputs: ['@group(astro)']
deps: ['typecheck']

# Preview production build locally
preview:
command: 'astro preview'
deps: ['build']
local: true

Each of these Astro applications will now inherit all 5 tasks and the file group automatically! This helps to greatly reduce maintenance overhead and help enforce consistency across projects. Jump to the official task inheritance docs for more information on tag based inheritance.

Other changes

View the official release for a full list of changes.

  • Upgraded to proto v0.6.
  • Improvements to file system operations.
  • Minor improvements to performance.