discourse/app/views/layouts/_plugin_js.html.erb
David Taylor d77a85155b
DEV: Improve plugin js loading logic (#38278)
- Add core_features spec to ensure JS bundles are loaded correctly
- Restore data-plugin-name in old plugin system
- Fix manifest caching in js_manager
- Move *_asset_exists functions into js_manager, and cache in production
2026-03-05 14:18:40 +00:00

28 lines
845 B
Text
Vendored

<%# locals: (opts:) %>
<%- Discourse.find_plugin_js_assets(opts).tap do |plugin_assets| %>
<script type="importmap" nonce="<%= csp_nonce_placeholder %>">
<%= generate_import_map(plugin_assets) %>
</script>
<%- plugin_assets.each do |asset| %>
<% if asset[:type_module] %>
<link
rel="modulepreload"
href="<%= script_asset_path(asset[:name]) %>"
nonce="<%= csp_nonce_placeholder %>"
<%= tag.attributes **asset[:plugin_attributes] %>
>
<% else %>
<%= preload_script asset[:name], attrs: asset[:plugin_attributes] %>
<% end %>
<%- end %>
<%- plugin_assets.flat_map { it[:imports] }.compact.uniq.each do |import| %>
<link
rel="modulepreload"
href="<%= script_asset_path(import) %>"
nonce="<%= csp_nonce_placeholder %>"
>
<%- end %>
<%- end %>