From: Ventsislav Dimitrov <4097884+vdmtrv@users.noreply.github.com> Date: Fri, 25 Oct 2019 17:29:17 +0000 (+0100) Subject: [bugfix] Use __dirname for locale import if available X-Git-Tag: 2.25.0~59^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e5105e4462cb9238fbf1e54de17112e8e91fb27f;p=thirdparty%2Fmoment.git [bugfix] Use __dirname for locale import if available React native doesn't like relative require calls. So use __dirname and replace relative requires with absolute ones. Fall back to relative require if __dirname is not present (for whatever reason). Fixes #5252 and #5214 --- diff --git a/src/lib/locale/locales.js b/src/lib/locale/locales.js index 86b933d66..7de3ec572 100644 --- a/src/lib/locale/locales.js +++ b/src/lib/locale/locales.js @@ -52,7 +52,7 @@ function loadLocale(name) { try { oldLocale = globalLocale._abbr; var aliasedRequire = require; - aliasedRequire('./locale/' + name); + aliasedRequire((typeof __dirname !== undefined ? __dirname : '.') + '/locale/' + name); getSetGlobalLocale(oldLocale); } catch (e) { // mark as not found to avoid repeating expensive file require call causing high CPU