-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Adding importmap_polyfill
#18537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding importmap_polyfill
#18537
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -289,17 +289,27 @@ Preloading and Initializing "app.js" | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
In addition to the importmap, the ``{{ importmap() }}`` Twig function also renders | ||
an `ES module shim`_ and a few other things, like a set of "preloads": | ||
an `ES module shim`_ by default. You can configure this in your ``config/packages/asset_mapper.yaml`` | ||
configuration file: | ||
|
||
.. code-block:: html | ||
.. code-block:: yaml | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should have the configuration block for all supported formats, like elsewhere There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I don't know the other formats' syntax :-( But starting with YAML is certainly better than nothing... |
||
|
||
<link rel="modulepreload" href="/assets/app-4e986c1a2318dd050b1d47db8d856278.js"> | ||
<link rel="modulepreload" href="/assets/duck-1b7a64b3b3d31219c262cf72521a5267.js"> | ||
framework: | ||
asset_mapper: | ||
importmap_polyfill: false # disable the shim ... | ||
# importmap_polyfill: 'https://...' # ... or pass some custom URL | ||
|
||
In ``importmap.php``, each entry can have a ``preload`` option. If set to ``true``, | ||
a ``<link rel="modulepreload">`` tag is rendered for that entry as well as for | ||
any JavaScript files it imports (this happens for "relative" - ``./`` or ``../`` - | ||
imports only). This is a performance optimization and you can learn more about below | ||
imports only): | ||
|
||
.. code-block:: html | ||
|
||
<link rel="modulepreload" href="/assets/app-4e986c1a2318dd050b1d47db8d856278.js"> | ||
<link rel="modulepreload" href="/assets/duck-1b7a64b3b3d31219c262cf72521a5267.js"> | ||
|
||
This is a performance optimization and you can learn more about below | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would keep this in the same paragraph than before instead of moving the code block in the middle of the explanation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I'm not sure what you mean. And (more important) I can't quite imagine what it will finally look like, just by looking at GitHub's diff. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When moving the existing code block, you split the existing paragraph in 2, putting the code block in the middle. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So you want me to move the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have a different idea: A) Add all of this to a new section under B) Leave this section unchanged, except change the top to point to that config section In addition to the importmap, the ``{{ importmap() }}`` Twig function also renders
an `ES module shim`_ (see the :ref:`config-importmap-polyfill <polyfill config>` and
a few other things, like a set of "preloads": (below, above the new section, you'd add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, I opened a new PR: #18554 |
||
in :ref:`Performance: Add Preloading <performance-preloading>`. | ||
|
||
.. _importmap-app-entry: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably also document the fact that we can customize the source of the shim, not just disabling it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added it as comment inside the code block. Not very elegant - I have to admit ;-)