Skip to content

Commit

Permalink
[bugfix] Use __dirname for locale import if available
Browse files Browse the repository at this point in the history
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
  • Loading branch information
vdmtrv authored and ichernev committed Apr 24, 2020
1 parent 0d0eabd commit e5105e4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/locale/locales.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e5105e4

Please sign in to comment.