mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-24 09:13:50 +02:00
various bundle optimizations (#1549)
* fix: missing "@element-plus/icons-vue" dependency * fix: update vite (40% faster builds) * fix: don't include sentry in non-nightly builds * fix: swap to variable fonts & don't include font files in repo * fix: lazy load languages to not keep them in memory * nit: revert vite to stable * nit: retain `.json` message files in bundle * nit: remove bundle analyzer * fix: availableLocales does not include unloaded locales
This commit is contained in:
@@ -1,18 +1,9 @@
|
||||
import { createI18n } from 'vue-i18n';
|
||||
|
||||
import { getLocalizationStrings } from '../localization/index.js';
|
||||
|
||||
const localizedStrings = await getLocalizationStrings();
|
||||
import { getLocalizedStrings, languageCodes } from '../localization';
|
||||
|
||||
const i18n = createI18n({
|
||||
locale: 'en',
|
||||
fallbackLocale: 'en',
|
||||
messages: Object.fromEntries(
|
||||
Object.entries(localizedStrings).map(([key, value]) => [
|
||||
key.replaceAll('_', '-'),
|
||||
value
|
||||
])
|
||||
),
|
||||
legacy: false,
|
||||
globalInjection: false,
|
||||
missingWarn: false,
|
||||
@@ -20,11 +11,13 @@ const i18n = createI18n({
|
||||
fallbackWarn: false
|
||||
});
|
||||
|
||||
async function updateLocalizedStrings() {
|
||||
const newStrings = await getLocalizationStrings();
|
||||
Object.entries(newStrings).forEach(([key, value]) => {
|
||||
i18n.global.setLocaleMessage(key.replaceAll('_', '-'), value);
|
||||
});
|
||||
async function loadLocalizedStrings(code) {
|
||||
const messages = await getLocalizedStrings(code);
|
||||
i18n.global.setLocaleMessage(code, messages);
|
||||
}
|
||||
|
||||
export { i18n, updateLocalizedStrings };
|
||||
async function updateLocalizedStrings() {
|
||||
await loadLocalizedStrings(i18n.global.locale.value);
|
||||
}
|
||||
|
||||
export { i18n, loadLocalizedStrings, updateLocalizedStrings };
|
||||
|
||||
@@ -2,26 +2,23 @@ import { router } from './router';
|
||||
|
||||
import configRepository from '../service/config';
|
||||
|
||||
let version = '';
|
||||
export async function isSentryOptedIn() {
|
||||
return NIGHTLY && configRepository.getBool('VRCX_SentryEnabled', false);
|
||||
}
|
||||
|
||||
export async function isSentryEnabled() {
|
||||
const enabled = await configRepository.getString(
|
||||
'VRCX_SentryEnabled',
|
||||
'false'
|
||||
);
|
||||
version = await AppApi.GetVersion();
|
||||
const isNightly = version.includes('Nightly');
|
||||
if (enabled !== 'true' || !isNightly) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
/**
|
||||
* Guarded import, prevents leaking Sentry into non-nightly bundles.
|
||||
*/
|
||||
export function getSentry() {
|
||||
return NIGHTLY ? import('@sentry/vue') : null;
|
||||
}
|
||||
|
||||
export async function initSentry(app) {
|
||||
if (!NIGHTLY) return;
|
||||
|
||||
try {
|
||||
if (!(await isSentryEnabled())) {
|
||||
return;
|
||||
}
|
||||
if (!(await isSentryOptedIn())) return;
|
||||
|
||||
const vrcxId = await configRepository.getString('VRCX_id', '');
|
||||
const response = await webApiService.execute({
|
||||
url: 'https://api0.vrcx.app/errorreporting/getdsn',
|
||||
@@ -40,12 +37,12 @@ export async function initSentry(app) {
|
||||
return;
|
||||
}
|
||||
const dsn = atob(response.data);
|
||||
const Sentry = await import('@sentry/vue');
|
||||
const Sentry = await getSentry();
|
||||
Sentry.init({
|
||||
app,
|
||||
dsn,
|
||||
environment: 'nightly',
|
||||
release: version,
|
||||
release: VERSION,
|
||||
replaysSessionSampleRate: 0,
|
||||
replaysOnErrorSampleRate: 1.0,
|
||||
tracesSampleRate: 0.0001,
|
||||
|
||||
Reference in New Issue
Block a user