mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-02-23 19:49:56 +01:00
core: don't use require in desktop app
This commit is contained in:
committed by
Abdullah Atta
parent
a24447d569
commit
0cd1ce3431
@@ -95,5 +95,5 @@ async function preprocessHTML(templateData) {
|
||||
export default { buildHTML };
|
||||
|
||||
function hasRequire() {
|
||||
return typeof require === "function";
|
||||
return typeof require === "function" && !("IS_DESKTOP_APP" in globalThis);
|
||||
}
|
||||
|
||||
@@ -42,14 +42,18 @@ for (const name in pathsToCopy) {
|
||||
}
|
||||
|
||||
const languagesList = await langen(ROOT_DIR, path.join(ROOT_DIR, "languages"));
|
||||
const languageIndex = `export async function loadLanguage(language) {
|
||||
const languageIndex = `function hasRequire() {
|
||||
return typeof require === "function" && !("IS_DESKTOP_APP" in globalThis);
|
||||
}
|
||||
|
||||
export async function loadLanguage(language) {
|
||||
switch (language) {
|
||||
${languagesList
|
||||
.map(({ filename, alias }) => {
|
||||
return [
|
||||
...(alias || []).map((a) => `case "${a}":`),
|
||||
`case "${filename}":`,
|
||||
`return typeof require === "function" ? require("./${filename}.js") : await import("./${filename}.js");`
|
||||
`return hasRequire() ? require("./${filename}.js") : await import("./${filename}.js");`
|
||||
].join("\n");
|
||||
})
|
||||
.join("\n\n")}
|
||||
|
||||
Reference in New Issue
Block a user