diff --git a/app/soapbox/service-worker/entry.ts b/app/soapbox/service-worker/entry.ts index b760579c7..6fa5afecc 100644 --- a/app/soapbox/service-worker/entry.ts +++ b/app/soapbox/service-worker/entry.ts @@ -3,14 +3,14 @@ import IntlMessageFormat from 'intl-messageformat'; import 'intl-pluralrules'; import unescape from 'lodash/unescape'; -import locales from './web-push-locales'; - import type { Account as AccountEntity, Notification as NotificationEntity, Status as StatusEntity, } from 'soapbox/types/entities'; +const locales = import.meta.compileTime('./web-push-locales.ts'); + /** Limit before we start grouping device notifications into a single notification. */ const MAX_NOTIFICATIONS = 5; /** Tag for the grouped notification. */ diff --git a/app/soapbox/service-worker/web-push-locales.js b/app/soapbox/service-worker/web-push-locales.ts similarity index 86% rename from app/soapbox/service-worker/web-push-locales.js rename to app/soapbox/service-worker/web-push-locales.ts index 172bbe4b5..f80e6ae32 100644 --- a/app/soapbox/service-worker/web-push-locales.js +++ b/app/soapbox/service-worker/web-push-locales.ts @@ -1,16 +1,14 @@ -/* @preval */ +import fs from 'node:fs'; +import path from 'path'; -const fs = require('fs'); -const path = require('path'); - -const filtered = {}; +const filtered: Record> = {}; const filenames = fs.readdirSync(path.resolve(__dirname, '../locales')); filenames.forEach(filename => { if (!filename.match(/\.json$/) || filename.match(/defaultMessages|whitelist/)) return; const content = fs.readFileSync(path.resolve(__dirname, `../locales/${filename}`), 'utf-8'); - const full = JSON.parse(content); + const full = JSON.parse(content) as Record; const locale = filename.split('.')[0]; filtered[locale] = { @@ -35,4 +33,6 @@ filenames.forEach(filename => { }; }); -module.exports = JSON.parse(JSON.stringify(filtered)); +export default () => ({ + data: filtered, +}); \ No newline at end of file