From 64fcc9e3cfaea952cad5724d4b0e82090b92a3c4 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 16 Feb 2026 14:57:59 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Removed=20@tryghost/errors=20fro?= =?UTF-8?q?m=20i18n=20to=20fix=20SharedStorage=20deprecation=20warning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes https://github.com/TryGhost/Ghost/issues/26318 The @tryghost/errors package brings in @stdlib/utils-copy which includes @stdlib/utils-keys. This package has bug detection code that iterates over all window properties, triggering a deprecation warning when it accesses window.sharedStorage in Chromium browsers. Removed the @tryghost/errors import which was only used for control flow (throwing an error to trigger a catch block). Replaced with a simple flag to indicate when fallback is needed. This also reduces the sodo-search bundle size from ~509KB to ~290KB. --- ghost/i18n/lib/i18n.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/ghost/i18n/lib/i18n.js b/ghost/i18n/lib/i18n.js index 7f3cf84ad66..dea7bf519e6 100644 --- a/ghost/i18n/lib/i18n.js +++ b/ghost/i18n/lib/i18n.js @@ -1,7 +1,6 @@ const i18next = require('i18next'); const path = require('path'); const fs = require('fs'); -const errors = require('@tryghost/errors'); const debug = require('@tryghost/debug')('i18n'); // Locale data loaded from JSON (single source of truth) @@ -57,21 +56,23 @@ function generateThemeResources(lng, themeLocalesPath) { return locales.reduce((acc, locale) => { let res; + let needsFallback = false; // Try to load the locale file, fallback to English - try { - const localePath = path.join(themeLocalesPath, `${locale}.json`); - if (fs.existsSync(localePath)) { + const localePath = path.join(themeLocalesPath, `${locale}.json`); + if (fs.existsSync(localePath)) { + try { // Delete from require cache to ensure fresh reads for theme files delete require.cache[require.resolve(localePath)]; res = require(localePath); - } else { - throw new errors.IncorrectUsageError({ - message: `Locale file not found: ${locale}`, - context: locale - }); + } catch (err) { + debug(`Error loading theme locale file: ${locale}`); + needsFallback = true; } - } catch (err) { - debug(`Error loading theme locale file: ${locale}`); + } else { + needsFallback = true; + } + + if (needsFallback) { // Fallback to English if it's not the locale we're already trying if (locale !== 'en') { try {