Skip to content

Commit

Permalink
Load i18next plugins as ESM modules, fixes #1057
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmartel committed Dec 10, 2021
1 parent 8dd734b commit 2e9fa63
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions resources/module/intro.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,22 @@
self : typeof global !== 'undefined' ?
global : {};

// latest i18next (>v17) does not export default
// see #862 and https://github.com/i18next/i18next/commit/7c6c235
if (typeof i18next !== 'undefined' &&
typeof i18next.t === 'undefined') {
// if it has a default, treat it as ESM
var isEsmModule = function (mod) {
return typeof mod !== 'undefined' &&
typeof mod.default !== 'undefined';
}
// i18next (>v17) comes as a module, see #862
if (isEsmModule(i18next)) {
i18next = i18next.default;
}

if (isEsmModule(i18nextHttpBackend)) {
i18nextHttpBackend = i18nextHttpBackend.default;
}
if (isEsmModule(i18nextBrowserLanguageDetector)) {
i18nextBrowserLanguageDetector = i18nextBrowserLanguageDetector.default;
}
// Konva (>=v8) comes as a module, see #1044
if (typeof Konva !== 'undefined' &&
typeof Konva.Group === 'undefined') {
if (isEsmModule(Konva)) {
Konva = Konva.default;
}

0 comments on commit 2e9fa63

Please sign in to comment.