Fix polyfills naming and tag missing a source (#34768)

This commit is contained in:
Renaud Chaput 2025-05-22 14:54:47 +02:00 committed by GitHub
parent 12c8a6498c
commit ef1bf8e9f2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 8 additions and 6 deletions

View file

@ -28,7 +28,7 @@
= theme_style_tags current_theme
= vite_client_tag
= vite_react_refresh_tag
= vite_polyfill_tag crossorigin: 'anonymous'
= vite_polyfills_tag
-# Needed for the wicg-inert polyfill. It needs to be on it's own <style> tag, with this `id`
= vite_stylesheet_tag 'styles/entrypoints/inert.scss', media: 'all', id: 'inert-style'
= vite_typescript_tag 'common.ts', crossorigin: 'anonymous'

View file

@ -13,7 +13,7 @@
= vite_client_tag
= vite_react_refresh_tag
= vite_polyfill_tag crossorigin: 'anonymous'
= vite_polyfills_tag
= theme_style_tags 'mastodon-light'
= vite_preload_file_tag "mastodon/locales/#{I18n.locale}.json"
= render_initial_state

View file

@ -7,7 +7,7 @@
%meta{ content: 'width=device-width,initial-scale=1', name: 'viewport' }/
= vite_client_tag
= vite_react_refresh_tag
= vite_polyfill_tag crossorigin: 'anonymous'
= vite_polyfills_tag
= theme_style_tags Setting.default_settings['theme']
= vite_typescript_tag 'error.ts', crossorigin: 'anonymous'
%body.error

View file

@ -120,10 +120,12 @@ module ViteRails::TagHelpers::IntegrityExtension
# Ignore this error, it is not critical if the file is not preloaded
end
def vite_polyfill_tag(**)
entry = vite_manifest.path_and_integrity_for('polyfill', type: :virtual)
def vite_polyfills_tag(crossorigin: 'anonymous', **)
return if ViteRuby.instance.dev_server_running?
javascript_include_tag(type: 'module', src: entry[:path], integrity: entry[:integrity], **)
entry = vite_manifest.path_and_integrity_for('polyfills', type: :virtual)
javascript_include_tag(entry[:path], type: 'module', integrity: entry[:integrity], crossorigin: crossorigin, **)
end
end