fix require.context bug
This commit is contained in:
parent
45993e423d
commit
66fc1dd739
@ -31,6 +31,12 @@ function getKeyForNameSpaces(key) {
|
||||
}
|
||||
|
||||
function getLocales() {
|
||||
const isWebpackEnv = typeof require.context === 'function';
|
||||
// require.context is exclusive from webpack, it's needed to escape inside jest
|
||||
if (!isWebpackEnv) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const context = require.context(`./locales`, true, /\.json$/);
|
||||
const locales = {};
|
||||
|
||||
@ -85,10 +91,6 @@ customDebug(`version ${pkg.version} loaded.`, 'info');
|
||||
|
||||
initI18n();
|
||||
|
||||
export {
|
||||
translate as t,
|
||||
addLocales,
|
||||
initI18n
|
||||
};
|
||||
export { translate as t, addLocales, initI18n };
|
||||
|
||||
export default i18n;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user