]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Rename dynamic require to avoid React Native crash 4213/head
authorIskren Chernev <iskren.chernev@gmail.com>
Mon, 9 Oct 2017 23:16:08 +0000 (02:16 +0300)
committerIskren Chernev <iskren.chernev@gmail.com>
Mon, 9 Oct 2017 23:16:08 +0000 (02:16 +0300)
src/lib/locale/locales.js

index 7df7ae3c40266e5e783217759efabafafd2e5cf5..d8bb937c95516a773ec8e7a119a0041aba801cc3 100644 (file)
@@ -46,19 +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 {
-            require('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 {
-                require('./locale/' + name);
+                pretendingNotToRequire('./locale/' + name);
             } catch (e) { }
         }