]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
revert locale fallbacks in require, re-add react native aliasing maggie/fixBuild 4232/head
authorMaggie Pint <magpint@microsoft.com>
Wed, 11 Oct 2017 14:53:49 +0000 (07:53 -0700)
committerMaggie Pint <magpint@microsoft.com>
Wed, 11 Oct 2017 14:53:49 +0000 (07:53 -0700)
src/lib/locale/locales.js

index 7df7ae3c40266e5e783217759efabafafd2e5cf5..4efebb8fff90a3c39a395f3faac54682ee86cad6 100644 (file)
@@ -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];
 }