top level await in iife build mode is not supported, so let's do import.meta.glob instead (we just need the build step not to see await, the code doesn't actually ever get loaded because it's DEV only)

This commit is contained in:
rash
2026-02-23 16:43:11 +01:00
parent 99bd78f2c6
commit 00cb77de8f

View File

@@ -15,7 +15,10 @@ let django: Django
if (import.meta.env.DEV) {
// TODO this does not actually grab the correct language strings
const raw = (await import(`../../../jsi18n/${LANG}/djangojs.js?raw`)).default
const modules = import.meta.glob('../../../jsi18n/*/djangojs.js', { eager: true, query: '?raw', import: 'default' }) as Record<string, string>
const key = `../../../jsi18n/${LANG}/djangojs.js`
const raw = modules[key]
if (!raw) throw new Error(`Missing i18n module for lang "${LANG}": ${key}`)
const context: { django?: Django } = {}
new Function(raw).call(context)
django = context.django!