From: Maggie Pint Date: Wed, 11 Oct 2017 14:53:49 +0000 (-0700) Subject: revert locale fallbacks in require, re-add react native aliasing X-Git-Tag: 2.19.1~3^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a498bb8176af773a3cf41ce335a2cef44896ee59;p=thirdparty%2Fmoment.git revert locale fallbacks in require, re-add react native aliasing --- diff --git a/src/lib/locale/locales.js b/src/lib/locale/locales.js index 7df7ae3c4..4efebb8ff 100644 --- a/src/lib/locale/locales.js +++ b/src/lib/locale/locales.js @@ -50,21 +50,12 @@ function loadLocale(name) { // TODO: Find a better way to register and load all the locales in Node if (!locales[name] && (typeof module !== 'undefined') && module && module.exports) { - oldLocale = globalLocale._abbr; try { - require('moment/locale/' + name); - } catch (e) { - // In the test environment, the external module 'moment' - // can't be resolved because we're running inside it. - // Fallback to using the old relative import - try { - require('./locale/' + name); - } catch (e) { } - } - - // because defineLocale currently also sets the global locale, we - // want to undo that for lazy loaded locales - getSetGlobalLocale(oldLocale); + oldLocale = globalLocale._abbr; + var aliasedRequire = require; + aliasedRequire('./locale/' + name); + getSetGlobalLocale(oldLocale); + } catch (e) {} } return locales[name]; }