I've done it adding in the asset plugin
$this->assets->collection('mjs')
->setPrefix(APP.'/js/modules/')
->addJs("$currentPath/".((ENV==="prod") ? 'build' : 'main').'.mjs');
and in the layout
<? foreach($this->assets->collection('mjs')->getAssets() as $asset): ?>
<script type="module" src="/<?=$this->assets->collection('mjs')->getPrefix().$asset->getPath()?>?v=<?=$this->config->version?>"></script>
<? endforeach; ?>
but I would like to create a function like outputJs (outputMjs) to do the job in the layout.
How can I do this ?