Skip to content

Commit 45c11e5

Browse files
committed
Tweaks and rewords
1 parent af0a87b commit 45c11e5

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

frontend/asset_mapper.rst

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,16 +1095,19 @@ both ``app`` and ``checkout``:
10951095
{{ importmap(['app', 'checkout']) }}
10961096
{% endblock %}
10971097
1098-
By passing both ``app`` and ``checkout``, the ``importmap()`` function will
1099-
output the ``importmap`` and also add a ``<script type="module">`` tag that
1100-
loads the ``app.js`` file *and* the ``checkout.js`` file. It's important
1101-
to *not* call ``parent()`` in the ``importmap`` block. Each page can only
1102-
have *one* importmap, so ``importmap()`` must be called exactly once.
1103-
1104-
If you want to execute *only* ``checkout.js``
1105-
and *not* ``app.js``, pass only ``checkout`` to ``importmap()``.
1106-
In this case, still **both** files are added to ``<script type="importmap">``,
1107-
but only ``checkout`` is executed (via ``<script type="module">import 'checkout';</script>``).
1098+
The ``importmap()`` function always includes the full import map to ensure all
1099+
module definitions are available on the page. It also adds a ``<script type="module">``
1100+
tag to load the specific JavaScript entry files you pass to it (in the example
1101+
above, the ``app.js`` file *and* the ``checkout.js`` file).
1102+
1103+
.. warning::
1104+
1105+
Do not call ``parent()`` inside the ``{% block importmap %}`` Twig block. Each
1106+
page can include only one import map, so ``importmap()`` must be called exactly once.
1107+
1108+
If you want to execute *only* ``checkout.js`` (and not ``app.js``), call
1109+
``{{ importmap('checkout') }}``. In this case, the full import map will still be
1110+
included in the page, but only the ``checkout.js`` file will actually be loaded.
11081111

11091112
Using a Content Security Policy (CSP)
11101113
-------------------------------------

0 commit comments

Comments
 (0)