From: Iskren Chernev Date: Tue, 10 Oct 2017 08:22:33 +0000 (+0300) Subject: Revert "Move require rename inside try/catch" X-Git-Tag: 2.19.1~5^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5125099babb22d0847e5d95566bae7ee9b412fe1;p=thirdparty%2Fmoment.git Revert "Move require rename inside try/catch" This reverts commit 79e9131fdab17d0afe4211b068a353b2bb5749b5. --- diff --git a/src/lib/locale/locales.js b/src/lib/locale/locales.js index 2f5f2d8b0..d8bb937c9 100644 --- a/src/lib/locale/locales.js +++ b/src/lib/locale/locales.js @@ -46,23 +46,22 @@ function chooseLocale(names) { } function loadLocale(name) { - var oldLocale = null; + var oldLocale = null, + // workaround for React Native 0.49+ + pretendingNotToRequire = require; // 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 { - // workaround for React Native 0.49+ - var pretendingNotToRequireV1 = require; - pretendingNotToRequireV1('moment/locale/' + name); + pretendingNotToRequire('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 { - var pretendingNotToRequireV2 = require; - pretendingNotToRequireV2('./locale/' + name); + pretendingNotToRequire('./locale/' + name); } catch (e) { } }