javascript module question
I'm not sure this is possible, but another approach would be to create a new extendable block in your parent template:
// layout.twig

{% block scripts %}

{% endblock %}

// component.twig

{% extends 'layout.twig' %}

{% block scripts %}
    &lt;script type=&quot;module&quot;&gt;
        // script here
    &lt;/script&gt;
{% endblock %}